From bab3a90155d1b93e7083beccebe60241afa6ce51 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Tue, 14 Feb 2012 20:15:52 +0200 Subject: [PATCH] Apply approved and rejected filters for register requests. Tune abilities. Link to user profile if user have already registered. Refs #174 --- app/controllers/register_requests_controller.rb | 2 +- app/models/ability.rb | 2 ++ app/views/register_requests/index.html.haml | 7 ++++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/controllers/register_requests_controller.rb b/app/controllers/register_requests_controller.rb index 74ddd6627..85c915a52 100644 --- a/app/controllers/register_requests_controller.rb +++ b/app/controllers/register_requests_controller.rb @@ -5,7 +5,7 @@ class RegisterRequestsController < ApplicationController before_filter :find_register_request, :only => [:approve, :reject] def index - @register_requests = @register_requests.unprocessed.paginate(:page => params[:page]) + @register_requests = @register_requests.send((params[:scope] || 'unprocessed').to_sym).paginate(:page => params[:page]) end def new diff --git a/app/models/ability.rb b/app/models/ability.rb index 113b50dd1..2b58c1329 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -17,6 +17,8 @@ class Ability cannot :destroy, Subscribe cannot :create, Subscribe cannot :create, RegisterRequest + cannot :approve, RegisterRequest, :approved => true + cannot :reject, RegisterRequest, :rejected => true else # Shared rights between guests and registered users can :forbidden, Platform diff --git a/app/views/register_requests/index.html.haml b/app/views/register_requests/index.html.haml index a860887aa..9df74cd1b 100644 --- a/app/views/register_requests/index.html.haml +++ b/app/views/register_requests/index.html.haml @@ -5,6 +5,10 @@ %li= link_to t("layout.users.new"), new_user_path %li.active= link_to t("layout.users.register_requests"), register_requests_path .content + %div{:style => 'float: right; margin: 20px'} + = link_to t("layout.register_request.approved"), register_requests_path(:scope => :approved) + \| + = link_to t("layout.register_request.rejected"), register_requests_path(:scope => :rejected) %h2.title = t("layout.register_request.list_header") .inner @@ -23,7 +27,8 @@ %tr{:class => cycle("odd", "even")} %td= check_box_tag 'request_ids[]', request.id %td= request.name - %td= request.email + - @user = User.find_by_email(request.email) if request.approved + %td= link_to_if @user, request.email, @user %td= request.interest %td= request.more %td= request.created_at