Moved foodcoop/members into new foodcoop/users restful controller.
This commit is contained in:
parent
0d910dfbbd
commit
5cf75ee32a
6 changed files with 50 additions and 48 deletions
37
app/controllers/foodcoop/users_controller.rb
Normal file
37
app/controllers/foodcoop/users_controller.rb
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
class Foodcoop::UsersController < ApplicationController
|
||||||
|
|
||||||
|
def index
|
||||||
|
# sort by ordergroups
|
||||||
|
if params[:sort_by_ordergroups]
|
||||||
|
@users = []
|
||||||
|
Ordergroup.find(:all, :order => "name").each do |group|
|
||||||
|
group.users.each do |user|
|
||||||
|
@users << user
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@total = @users.size
|
||||||
|
else
|
||||||
|
# sort by nick, thats default
|
||||||
|
if (params[:per_page] && params[:per_page].to_i > 0 && params[:per_page].to_i <= 100)
|
||||||
|
@per_page = params[:per_page].to_i
|
||||||
|
else
|
||||||
|
@per_page = 20
|
||||||
|
end
|
||||||
|
|
||||||
|
# if somebody uses the search field:
|
||||||
|
unless params[:query].blank?
|
||||||
|
conditions = ["first_name LIKE ? OR last_name LIKE ? OR nick LIKE ?",
|
||||||
|
"%#{params[:query]}%", "%#{params[:query]}%", "%#{params[:query]}%"]
|
||||||
|
end
|
||||||
|
|
||||||
|
@total = User.count(:conditions => conditions)
|
||||||
|
@users = User.paginate(:page => params[:page], :per_page => @per_page, :conditions => conditions, :order => "nick", :include => :groups)
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # index.html.erb
|
||||||
|
format.js { render :partial => "users" }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -1,42 +1,6 @@
|
||||||
class FoodcoopController < ApplicationController
|
class FoodcoopController < ApplicationController
|
||||||
|
|
||||||
before_filter :authenticate_membership_or_admin, :except => [:members]
|
before_filter :authenticate_membership_or_admin
|
||||||
|
|
||||||
# gives a view to list all members of the foodcoop
|
|
||||||
def members
|
|
||||||
|
|
||||||
# sort by ordergroups
|
|
||||||
if params[:sort_by_ordergroups]
|
|
||||||
@users = []
|
|
||||||
Ordergroup.find(:all, :order => "name").each do |group|
|
|
||||||
group.users.each do |user|
|
|
||||||
@users << user
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@total = @users.size
|
|
||||||
else
|
|
||||||
# sort by nick, thats default
|
|
||||||
if (params[:per_page] && params[:per_page].to_i > 0 && params[:per_page].to_i <= 100)
|
|
||||||
@per_page = params[:per_page].to_i
|
|
||||||
else
|
|
||||||
@per_page = 20
|
|
||||||
end
|
|
||||||
|
|
||||||
# if somebody uses the search field:
|
|
||||||
unless params[:query].blank?
|
|
||||||
conditions = ["first_name LIKE ? OR last_name LIKE ? OR nick LIKE ?",
|
|
||||||
"%#{params[:query]}%", "%#{params[:query]}%", "%#{params[:query]}%"]
|
|
||||||
end
|
|
||||||
|
|
||||||
@total = User.count(:conditions => conditions)
|
|
||||||
@users = User.paginate(:page => params[:page], :per_page => @per_page, :conditions => conditions, :order => "nick", :include => :groups)
|
|
||||||
|
|
||||||
respond_to do |format|
|
|
||||||
format.html # index.html.erb
|
|
||||||
format.js { render :partial => "users" }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Invites a new user to join foodsoft in this group.
|
# Invites a new user to join foodsoft in this group.
|
||||||
def invite
|
def invite
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
%tbody
|
%tbody
|
||||||
- for user in @users
|
- for user in @users
|
||||||
%tr{:class => cycle('even','odd', :name => 'users')}
|
%tr{:class => cycle('even','odd', :name => 'users')}
|
||||||
%td= link_to user.nick, {:controller => "messages", :action => "user", :id => user}, :title => _('Send user an email')
|
%td= link_to user.nick, user_message_path(user), :title => _('Send user an email')
|
||||||
%td=h user.name if @current_user.role_admin? || user.settings["profile.nameIsPublic"] == '1'
|
%td=h user.name if @current_user.role_admin? || user.settings["profile.nameIsPublic"] == '1'
|
||||||
%td=h user.email if @current_user.role_admin? || user.settings["profile.emailIsPublic"] == '1'
|
%td=h user.email if @current_user.role_admin? || user.settings["profile.emailIsPublic"] == '1'
|
||||||
%td=h user.phone if @current_user.role_admin? || user.settings["profile.phoneIsPublic"] == '1'
|
%td=h user.phone if @current_user.role_admin? || user.settings["profile.phoneIsPublic"] == '1'
|
|
@ -20,13 +20,13 @@
|
||||||
= observe_field 'query', :frequency => 2, |
|
= observe_field 'query', :frequency => 2, |
|
||||||
:before => "Element.show('loader')", |
|
:before => "Element.show('loader')", |
|
||||||
:success => "Element.hide('loader')", |
|
:success => "Element.hide('loader')", |
|
||||||
:url => {:action => 'members'}, |
|
:url => foodcoop_users_path, |
|
||||||
:update => :users, |
|
:update => :users, |
|
||||||
:with => 'query', |
|
:with => 'query', |
|
||||||
:method => :get |
|
:method => :get |
|
||||||
|
|
||||||
=_ "Nach Bestellgruppen sortieren:"
|
=_ "Nach Bestellgruppen sortieren:"
|
||||||
- form_tag({:action => "members"}, :method => "get", :style=>"display:inline;") do
|
- form_tag(foodcoop_users_path, :method => "get", :style=>"display:inline;") do
|
||||||
= check_box_tag :sort_by_ordergroups, 1, params[:sort_by_ordergroups], :onclick => "submit();"
|
= check_box_tag :sort_by_ordergroups, 1, params[:sort_by_ordergroups], :onclick => "submit();"
|
||||||
#users
|
#users
|
||||||
= render :partial => "users"
|
= render :partial => "users"
|
|
@ -9,9 +9,9 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{ :name => "Foodcoop", :url => "/tasks",
|
{ :name => "Foodcoop", :url => "/tasks",
|
||||||
:active => ["foodcoop", "tasks", "messages", "foodcoop/ordergroups", "foodcoop/workgroups"],
|
:active => ["foodcoop", "tasks", "messages", "foodcoop/ordergroups", "foodcoop/workgroups", "foodcoop/users"],
|
||||||
:subnav => [
|
:subnav => [
|
||||||
{ :name => "Mitglieder", :url => "/foodcoop/members"},
|
{ :name => "Mitglieder", :url => "/foodcoop/users"},
|
||||||
{ :name => "Abeitsgruppen", :url => "/foodcoop/workgroups"},
|
{ :name => "Abeitsgruppen", :url => "/foodcoop/workgroups"},
|
||||||
{ :name => "Bestellgruppen", :url => "/foodcoop/ordergroups"},
|
{ :name => "Bestellgruppen", :url => "/foodcoop/ordergroups"},
|
||||||
{ :name => "Nachrichten", :url => "/messages"},
|
{ :name => "Nachrichten", :url => "/messages"},
|
||||||
|
|
|
@ -11,7 +11,8 @@ ActionController::Routing::Routes.draw do |map|
|
||||||
:member => { :reply => :get, :user => :get, :group => :get }
|
:member => { :reply => :get, :user => :get, :group => :get }
|
||||||
|
|
||||||
map.namespace :foodcoop do |foodcoop|
|
map.namespace :foodcoop do |foodcoop|
|
||||||
foodcoop.root :controller => "foodcoop", :action => "members"
|
foodcoop.root :controller => "users", :action => "index"
|
||||||
|
foodcoop.resources :users, :only => [:index]
|
||||||
foodcoop.resources :ordergroups, :only => [:index]
|
foodcoop.resources :ordergroups, :only => [:index]
|
||||||
foodcoop.resources :workgroups, :only => [:index, :edit, :update],
|
foodcoop.resources :workgroups, :only => [:index, :edit, :update],
|
||||||
:member => {:memberships => :get}
|
:member => {:memberships => :get}
|
||||||
|
|
Loading…
Reference in a new issue