Move foodcoop/ordergroups into nwe namespace foodcoop. Made it more restful.
This commit is contained in:
parent
709425855e
commit
1a8026c5a7
8 changed files with 175 additions and 29 deletions
29
app/controllers/foodcoop/ordergroups_controller.rb
Normal file
29
app/controllers/foodcoop/ordergroups_controller.rb
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
class Foodcoop::OrdergroupsController < ApplicationController
|
||||||
|
|
||||||
|
def index
|
||||||
|
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 (params[:only_active].to_i == 1)
|
||||||
|
if (! params[:query].blank?)
|
||||||
|
conditions = ["orders.starts >= ? AND name LIKE ?", Time.now.months_ago(3), "%#{params[:query]}%"]
|
||||||
|
else
|
||||||
|
conditions = ["orders.starts >= ?", Time.now.months_ago(3)]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
# if somebody uses the search field:
|
||||||
|
conditions = ["name LIKE ?", "%#{params[:query]}%"] unless params[:query].blank?
|
||||||
|
end
|
||||||
|
|
||||||
|
@total = Ordergroup.count(:conditions => conditions, :include => "orders")
|
||||||
|
@ordergroups = Ordergroup.paginate(:page => params[:page], :per_page => @per_page, :conditions => conditions, :order => "name", :include => "orders")
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # index.html.erb
|
||||||
|
format.js { render :partial => "ordergroups" }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -44,34 +44,6 @@ class FoodcoopController < ApplicationController
|
||||||
@groups = Workgroup.find :all, :order => "name"
|
@groups = Workgroup.find :all, :order => "name"
|
||||||
end
|
end
|
||||||
|
|
||||||
def ordergroups
|
|
||||||
#@order_groups = Ordergroup.find :all, :order => "name"
|
|
||||||
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 (params[:only_active].to_i == 1)
|
|
||||||
if (! params[:query].blank?)
|
|
||||||
conditions = ["orders.starts >= ? AND name LIKE ?", Time.now.months_ago(3), "%#{params[:query]}%"]
|
|
||||||
else
|
|
||||||
conditions = ["orders.starts >= ?", Time.now.months_ago(3)]
|
|
||||||
end
|
|
||||||
else
|
|
||||||
# if somebody uses the search field:
|
|
||||||
conditions = ["name LIKE ?", "%#{params[:query]}%"] unless params[:query].blank?
|
|
||||||
end
|
|
||||||
|
|
||||||
@total = Ordergroup.count(:conditions => conditions, :include => "orders")
|
|
||||||
@ordergroups = Ordergroup.paginate(:page => params[:page], :per_page => @per_page, :conditions => conditions, :order => "name", :include => "orders")
|
|
||||||
|
|
||||||
respond_to do |format|
|
|
||||||
format.html # index.html.erb
|
|
||||||
format.js { render :partial => "ordergroups" }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def group
|
def group
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
{ :name => "Mein Profil", :url => "/home/profile"}
|
{ :name => "Mein Profil", :url => "/home/profile"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{ :name => "Foodcoop", :url => "/tasks", :active => ["foodcoop", "tasks", "messages"],
|
{ :name => "Foodcoop", :url => "/tasks", :active => ["foodcoop", "tasks", "messages", "foodcoop/ordergroups"],
|
||||||
:subnav => [
|
:subnav => [
|
||||||
{ :name => "Mitglieder", :url => "/foodcoop/members"},
|
{ :name => "Mitglieder", :url => "/foodcoop/members"},
|
||||||
{ :name => "Abeitsgruppen", :url => "/foodcoop/workgroups"},
|
{ :name => "Abeitsgruppen", :url => "/foodcoop/workgroups"},
|
||||||
|
|
88
app/views/ordergroups/edit.html.erb
Normal file
88
app/views/ordergroups/edit.html.erb
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
<% title "Edit Ordergroup" %>
|
||||||
|
|
||||||
|
<% form_for @ordergroup do |f| %>
|
||||||
|
<%= f.error_messages %>
|
||||||
|
<p>
|
||||||
|
<%= f.label :type %><br />
|
||||||
|
<%= f.text_field :type %>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<%= f.label :name %><br />
|
||||||
|
<%= f.text_field :name %>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<%= f.label :description %><br />
|
||||||
|
<%= f.text_field :description %>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<%= f.label :account_balance %><br />
|
||||||
|
<%= f.text_field :account_balance %>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<%= f.label :account_updated %><br />
|
||||||
|
<%= f.datetime_select :account_updated %>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<%= f.label :created_on %><br />
|
||||||
|
<%= f.datetime_select :created_on %>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<%= f.label :role_admin %><br />
|
||||||
|
<%= f.check_box :role_admin %>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<%= f.label :role_suppliers %><br />
|
||||||
|
<%= f.check_box :role_suppliers %>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<%= f.label :role_article_meta %><br />
|
||||||
|
<%= f.check_box :role_article_meta %>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<%= f.label :role_finance %><br />
|
||||||
|
<%= f.check_box :role_finance %>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<%= f.label :role_orders %><br />
|
||||||
|
<%= f.check_box :role_orders %>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<%= f.label :weekly_task %><br />
|
||||||
|
<%= f.check_box :weekly_task %>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<%= f.label :weekday %><br />
|
||||||
|
<%= f.text_field :weekday %>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<%= f.label :task_name %><br />
|
||||||
|
<%= f.text_field :task_name %>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<%= f.label :task_description %><br />
|
||||||
|
<%= f.text_field :task_description %>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<%= f.label :task_required_users %><br />
|
||||||
|
<%= f.text_field :task_required_users %>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<%= f.label :deleted_at %><br />
|
||||||
|
<%= f.datetime_select :deleted_at %>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<%= f.label :contact_person %><br />
|
||||||
|
<%= f.text_field :contact_person %>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<%= f.label :contact_phone %><br />
|
||||||
|
<%= f.text_field :contact_phone %>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<%= f.label :contact_address %><br />
|
||||||
|
<%= f.text_field :contact_address %>
|
||||||
|
</p>
|
||||||
|
<p><%= f.submit "Submit" %></p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
|
52
app/views/ordergroups/index.html.erb
Normal file
52
app/views/ordergroups/index.html.erb
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
<% title "Ordergroups" %>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>Type</th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Description</th>
|
||||||
|
<th>Account Balance</th>
|
||||||
|
<th>Account Updated</th>
|
||||||
|
<th>Created On</th>
|
||||||
|
<th>Role Admin</th>
|
||||||
|
<th>Role Suppliers</th>
|
||||||
|
<th>Role Article Meta</th>
|
||||||
|
<th>Role Finance</th>
|
||||||
|
<th>Role Orders</th>
|
||||||
|
<th>Weekly Task</th>
|
||||||
|
<th>Weekday</th>
|
||||||
|
<th>Task Name</th>
|
||||||
|
<th>Task Description</th>
|
||||||
|
<th>Task Required Users</th>
|
||||||
|
<th>Deleted At</th>
|
||||||
|
<th>Contact Person</th>
|
||||||
|
<th>Contact Phone</th>
|
||||||
|
<th>Contact Address</th>
|
||||||
|
</tr>
|
||||||
|
<% for ordergroup in @ordergroups %>
|
||||||
|
<tr>
|
||||||
|
<td><%=h ordergroup.type %></td>
|
||||||
|
<td><%=h ordergroup.name %></td>
|
||||||
|
<td><%=h ordergroup.description %></td>
|
||||||
|
<td><%=h ordergroup.account_balance %></td>
|
||||||
|
<td><%=h ordergroup.account_updated %></td>
|
||||||
|
<td><%=h ordergroup.created_on %></td>
|
||||||
|
<td><%=h ordergroup.role_admin %></td>
|
||||||
|
<td><%=h ordergroup.role_suppliers %></td>
|
||||||
|
<td><%=h ordergroup.role_article_meta %></td>
|
||||||
|
<td><%=h ordergroup.role_finance %></td>
|
||||||
|
<td><%=h ordergroup.role_orders %></td>
|
||||||
|
<td><%=h ordergroup.weekly_task %></td>
|
||||||
|
<td><%=h ordergroup.weekday %></td>
|
||||||
|
<td><%=h ordergroup.task_name %></td>
|
||||||
|
<td><%=h ordergroup.task_description %></td>
|
||||||
|
<td><%=h ordergroup.task_required_users %></td>
|
||||||
|
<td><%=h ordergroup.deleted_at %></td>
|
||||||
|
<td><%=h ordergroup.contact_person %></td>
|
||||||
|
<td><%=h ordergroup.contact_phone %></td>
|
||||||
|
<td><%=h ordergroup.contact_address %></td>
|
||||||
|
<td><%= link_to "Edit", edit_ordergroup_path(ordergroup) %></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</table>
|
||||||
|
|
|
@ -10,6 +10,11 @@ ActionController::Routing::Routes.draw do |map|
|
||||||
map.resources :messages, :only => [:index, :show, :new, :create],
|
map.resources :messages, :only => [:index, :show, :new, :create],
|
||||||
:member => { :reply => :get, :user => :get, :group => :get }
|
:member => { :reply => :get, :user => :get, :group => :get }
|
||||||
|
|
||||||
|
map.namespace :foodcoop do |foodcoop|
|
||||||
|
foodcoop.root :controller => "foodcoop", :action => "members"
|
||||||
|
foodcoop.resources :ordergroups, :only => [:index]
|
||||||
|
end
|
||||||
|
|
||||||
map.namespace :admin do |admin|
|
map.namespace :admin do |admin|
|
||||||
admin.resources :users
|
admin.resources :users
|
||||||
admin.resources :workgroups, :member => { :memberships => :get }
|
admin.resources :workgroups, :member => { :memberships => :get }
|
||||||
|
|
Loading…
Reference in a new issue