approve and delete all done with registration approval notification for admin

This commit is contained in:
Harry Bomrah 2013-12-05 17:09:03 +08:00 committed by saurabhbhatia
parent 0eb8e1a305
commit 9db4c787c9
7 changed files with 111 additions and 11 deletions

View File

@ -0,0 +1,55 @@
jQuery(document).ready(function($) {
var selectAll = $( "#select_all_registration" ),
checkboxes = $( "input.select-this" ),
selectedBtns = $( "a.selected-actions" );
selectAll.bind(clickEvent,function(){
if( $( this ).is( ":checked" ) ){
checkboxes.prop( "checked", true );
selectedBtns.removeClass('hide');
}else{
checkboxes.prop( "checked", false );
selectedBtns.addClass('hide');
}
});
checkboxes.bind(clickEvent,function(){
var checkedCheckboxes = $( "input.select-this:checked" );
if( checkboxes.length == checkedCheckboxes.length ){
selectAll.prop( "checked", true );
}else{
selectAll.prop( "checked", false );
}
(checkedCheckboxes.length > 0 ? selectedBtns.removeClass('hide') : selectedBtns.addClass('hide'));
});
selectedBtns.bind(clickEvent,function(){
if( confirm("Are you sure?") ){
var userids = [],
_this = $( this ),
checkedCheckboxes = $( "input.select-this:checked" );
checkedCheckboxes.each(function(){
userids.push( $( this ).val() );
})
$.ajax({
url : _this.attr("href"),
type : "post",
dataType : "json",
data : {"userids" : userids},
success : function(data){
if( data.success == true){
window.location.href = data.url;
}
}
})
}
return false;
})
});

View File

@ -13,14 +13,37 @@ class Admin::UsersNewInterfaceController < OrbitMemberController
end
def approve_registration
user = User.find(params[:users_new_interface_id])
approve_method params[:users_new_interface_id]
redirect_to admin_users_new_interface_registration_approval_path
end
def approve_method(user_id = nil)
if !user_id.nil?
user = User.find(user_id)
user.approved = true
user.save
desk = user.desktop
desk.theme = DesktopTheme.first.id.to_s
desk.wallpaper = nil
desk.save!
redirect_to admin_users_new_interface_registration_approval_path
end
end
def approve_selected
users = params[:userids]
users.each do |user|
approve_method user
end
render :json => {"success"=>true,"url"=>admin_users_new_interface_registration_approval_path}
end
def delete_selected
users = params[:userids]
users.each do |user|
u = User.find(user)
u.destroy
end
render :json => {"success"=>true,"url"=>admin_users_new_interface_registration_approval_path}
end
def index
@ -345,6 +368,11 @@ class Admin::UsersNewInterfaceController < OrbitMemberController
flash[:error] = t(:cant_delete_self)
else
@user = User.find(params[:id])
@not_approved_count = nil
if !@user.approved
@not_approved_count = User.not_guest_and_approved_user.count - 1
end
@user.destroy
end

View File

@ -9,6 +9,7 @@
%>
<tr id="<%= dom_id not_approved_listing %>">
<td class="<%= @user_sex %>"></td>
<td><input type="checkbox" class="select-this" value="<%= not_approved_listing.id.to_s %>" /></td>
<td>
<% not_approved_listing.roles.each do |rf| %>
<% @roledata = Role.find(rf.id) %>

View File

@ -29,7 +29,7 @@
<%= content_tag :li, link_to((content_tag(:span, t(:all_member))), admin_users_new_interface_index_path), :class => active_for_action('users_new_interface', 'index') %>
<%= content_tag :li, link_to((content_tag(:span, t(:add_member))), new_admin_users_new_interface_path), :class => active_for_action('users_new_interface', 'new') if (is_admin? rescue nil) %>
<%= content_tag :li, link_to((content_tag(:span, t(:member_authorization))), '#'), :class => active_for_action('users_new_interfacexx', 'index') if (is_admin? rescue nil) %>
<%= content_tag :li, link_to((content_tag(:span, t(:member_registration))), admin_users_new_interface_registration_approval_path), :class => active_for_action('users_new_interface', 'registration_approval') if (is_admin? rescue nil) %>
<%= content_tag :li, link_to((content_tag(:span, t(:member_registration)) + (User.not_guest_and_approved_user.count > 0 ? content_tag(:span,"(#{User.not_guest_and_approved_user.count})",:style=>"margin-left:3px;", :id=>"registration_count") : "")), admin_users_new_interface_registration_approval_path), :class => active_for_action('users_new_interface', 'registration_approval') if (is_admin? rescue nil) %>
<%= content_tag :li, link_to((content_tag(:span, t(:member_role))),admin_roles_path ), :class => active_for_action('roles', 'index') if (is_admin? rescue nil) %>
<%= content_tag :li, link_to((content_tag(:span, t(:member_info))), edit_admin_info_path(Info.first.id.to_s)), :class => active_for_action('users_new_interfacexx', 'index') if (is_admin? rescue nil) and Info.first %>
<% end -%>

View File

@ -1 +1,8 @@
$("#<%= dom_id @user %>").remove();
<% if !@not_approved_count.nil? %>
<% if @not_approved_count > 0 %>
$("#registration_count").text("(<%= @not_approved_count %>)");
<% else %>
$("#registration_count").remove();
<% end %>
<% end %>

View File

@ -3,12 +3,13 @@
<% end %>
<%= render :partial => "js_and_css"%>
<%= javascript_include_tag "lib/member/registration_approval" %>
<div id="list-view">
<table id="member-list" class="table main-list">
<thead>
<tr class="sort-header">
<th class="gender"></th>
<th class="span2"><input type="checkbox" id="select_all_registration" style="margin:0;" /> Select All</th>
<th class="span3"><a href="#">Roles</a></th>
<th class="span4"><a href="#">Name</a></th>
<th><a href="#">Email</a></th>
@ -18,12 +19,18 @@
<% if !@users.blank? %>
<%= render :partial => "not_approved_listing",:collection=> @users %>
<% else %>
<tr><td colspan="4" style="text-align:center">Hooray! No pending registration approvals left.</td></tr>
<tr><td colspan="5" style="text-align:center">Hooray! No pending registration approvals left.</td></tr>
<% end %>
</tbody>
</table>
</div>
<div class="bottomnav clearfix">
<div class="action pull-right">
<% if !@users.blank? %>
<a href="<%= admin_users_new_interface_delete_selected_path %>" class="btn btn-danger selected-actions hide" >Delete Selected</a>
<a href="<%= admin_users_new_interface_approve_selected_path %>" class="btn btn-primary selected-actions hide">Approve Selected</a>
<% end -%>
</div>
<div class="pagination pagination-centered">
<%= paginate @users, :params => {:inner => false} %>
</div>

View File

@ -223,6 +223,8 @@ Orbit::Application.routes.draw do
resources :users
match "users_new_interface/registration_approval" => "users_new_interface#registration_approval"
match "users_new_interface/approve_selected" => "users_new_interface#approve_selected"
match "users_new_interface/delete_selected" => "users_new_interface#delete_selected"
resources :users_new_interface do
member do