diff --git a/app/controllers/foodcoop/workgroups_controller.rb b/app/controllers/foodcoop/workgroups_controller.rb new file mode 100644 index 00000000..8bbd88ae --- /dev/null +++ b/app/controllers/foodcoop/workgroups_controller.rb @@ -0,0 +1,26 @@ +class Foodcoop::WorkgroupsController < ApplicationController + + before_filter :authenticate_membership_or_admin, + :except => [:index] + + def index + @workgroups = Workgroup.all :order => "name" + end + + def edit + @workgroup = Workgroup.find(params[:id]) + end + + def update + @workgroup = Workgroup.find(params[:id]) + if @workgroup.update_attributes(params[:workgroup]) + flash[:notice] = "Arbeitsgruppe wurde aktualisiert" + redirect_to foodcoop_workgroups_url + else + render :action => 'edit' + end + end + + def memberships + end +end diff --git a/app/controllers/foodcoop_controller.rb b/app/controllers/foodcoop_controller.rb index 0c22d44d..77f30f52 100644 --- a/app/controllers/foodcoop_controller.rb +++ b/app/controllers/foodcoop_controller.rb @@ -1,8 +1,7 @@ class FoodcoopController < ApplicationController - before_filter :authenticate_membership_or_admin, - :only => [:edit_group, :update_group, :memberships, :invite, :send_invitation] - + before_filter :authenticate_membership_or_admin, :except => [:members] + # gives a view to list all members of the foodcoop def members @@ -39,25 +38,11 @@ class FoodcoopController < ApplicationController end end - # gives an overview for the workgroups and its members - def workgroups - @groups = Workgroup.find :all, :order => "name" - end - - def group - end - - def edit_group - end - - def memberships - end - # Invites a new user to join foodsoft in this group. def invite @invite = Invite.new end - + # Sends an email def send_invitation @invite = Invite.new(:user => @current_user, :group => @group, :email => params[:invite][:email]) diff --git a/app/models/workgroup.rb b/app/models/workgroup.rb index 56d0e897..add7d169 100644 --- a/app/models/workgroup.rb +++ b/app/models/workgroup.rb @@ -32,6 +32,9 @@ class Workgroup < Group # returns all non-finished tasks has_many :open_tasks, :class_name => 'Task', :conditions => ['done = ?', false], :order => 'due_date ASC' + validates_presence_of :task_name, :weekday, :task_required_users, + :if => Proc.new {|workgroup| workgroup.weekly_task } + def self.weekdays [["Montag", "1"], ["Dienstag", "2"], ["Mittwoch","3"],["Donnerstag","4"],["Freitag","5"],["Samstag","6"],["Sonntag","0"]] end diff --git a/app/views/foodcoop/_workgroup.html.haml b/app/views/foodcoop/_workgroup.html.haml deleted file mode 100644 index 15bac4f6..00000000 --- a/app/views/foodcoop/_workgroup.html.haml +++ /dev/null @@ -1,14 +0,0 @@ -.single_column{:style => "width:55em"} - .box_title - %h2= workgroup.name - .column_content - = render :partial => 'shared/group', :locals => { :group => workgroup } - %p - = link_to "Alle Aufgaben zeigen", :controller => "tasks", :action => "workgroup", :id => workgroup - | - = link_to "Mitgliedern eine Nachricht schicken", :controller => 'messages', :action => 'group', :id => workgroup - - if workgroup.member?(@current_user) - | - = link_to "Gruppe bearbeiten", :action => "edit_group", :id => workgroup - | - = link_to "Mitglieder bearbeiten", :action => "memberships", :id => workgroup diff --git a/app/views/foodcoop/memberships.rhtml b/app/views/foodcoop/memberships.rhtml deleted file mode 100644 index a34f8997..00000000 --- a/app/views/foodcoop/memberships.rhtml +++ /dev/null @@ -1 +0,0 @@ -<%= render :partial => 'shared/memberships/members' %> \ No newline at end of file diff --git a/app/views/foodcoop/workgroups/_workgroup.html.haml b/app/views/foodcoop/workgroups/_workgroup.html.haml new file mode 100644 index 00000000..ead035b7 --- /dev/null +++ b/app/views/foodcoop/workgroups/_workgroup.html.haml @@ -0,0 +1,14 @@ +.single_column{:style => "width:55em"} + .box_title + %h2= workgroup.name + .column_content + = render :partial => 'shared/group', :locals => { :group => workgroup } + %p + = link_to "Alle Aufgaben zeigen", :controller => "/tasks", :action => "workgroup", :id => workgroup + | + = link_to "Mitgliedern eine Nachricht schicken", :controller => '/messages', :action => 'group', :id => workgroup + - if workgroup.member?(@current_user) + | + = link_to "Gruppe bearbeiten", edit_foodcoop_workgroup_path(workgroup) + | + = link_to "Mitglieder bearbeiten", memberships_foodcoop_workgroup_path(workgroup) diff --git a/app/views/foodcoop/edit_group.html.haml b/app/views/foodcoop/workgroups/edit.html.haml similarity index 54% rename from app/views/foodcoop/edit_group.html.haml rename to app/views/foodcoop/workgroups/edit.html.haml index 3f213f52..556bb6e2 100644 --- a/app/views/foodcoop/edit_group.html.haml +++ b/app/views/foodcoop/workgroups/edit.html.haml @@ -3,13 +3,14 @@ %p %i Mitglieder kannst du - = link_to "hier", :action => "memberships", :id => @group + = link_to "hier", :action => "memberships", :id => @workgroup hinzufügen. + .edit_form{:style => "width:35em"} - - form_for(@group, :url => {:action => 'update_group', :id => @group}) do |@form| + - form_for [:foodcoop, @workgroup] do |@form| = render :partial => "shared/group_form" %p{:style => "clear:both"} = submit_tag 'Speichern' | - = link_to "Abbrechen", :action => "workgroups" \ No newline at end of file + = link_to "Abbrechen", foodcoop_workgroups_path \ No newline at end of file diff --git a/app/views/foodcoop/workgroups.html.haml b/app/views/foodcoop/workgroups/index.html.haml similarity index 80% rename from app/views/foodcoop/workgroups.html.haml rename to app/views/foodcoop/workgroups/index.html.haml index 67784905..60a469f2 100644 --- a/app/views/foodcoop/workgroups.html.haml +++ b/app/views/foodcoop/workgroups/index.html.haml @@ -6,7 +6,7 @@ %br/ Wenn du einer Gruppe beitreten willst, dann schreib doch den Mitgliedern eine Nachricht. -= render :partial => "workgroup", :collection => @groups += render :partial => "workgroup", :collection => @workgroups diff --git a/app/views/foodcoop/workgroups/memberships.html.haml b/app/views/foodcoop/workgroups/memberships.html.haml new file mode 100644 index 00000000..66e86694 --- /dev/null +++ b/app/views/foodcoop/workgroups/memberships.html.haml @@ -0,0 +1 @@ += render "shared/memberships/members" \ No newline at end of file diff --git a/app/views/layouts/_main_tabnav.html.erb b/app/views/layouts/_main_tabnav.html.erb index c6822a2c..6041df20 100644 --- a/app/views/layouts/_main_tabnav.html.erb +++ b/app/views/layouts/_main_tabnav.html.erb @@ -8,7 +8,8 @@ { :name => "Mein Profil", :url => "/home/profile"} ] }, - { :name => "Foodcoop", :url => "/tasks", :active => ["foodcoop", "tasks", "messages", "foodcoop/ordergroups"], + { :name => "Foodcoop", :url => "/tasks", + :active => ["foodcoop", "tasks", "messages", "foodcoop/ordergroups", "foodcoop/workgroups"], :subnav => [ { :name => "Mitglieder", :url => "/foodcoop/members"}, { :name => "Abeitsgruppen", :url => "/foodcoop/workgroups"}, diff --git a/app/views/workgroups/edit.html.erb b/app/views/workgroups/edit.html.erb new file mode 100644 index 00000000..59c4d480 --- /dev/null +++ b/app/views/workgroups/edit.html.erb @@ -0,0 +1,88 @@ +<% title "Edit Workgroup" %> + +<% form_for @workgroup do |f| %> + <%= f.error_messages %> +
+ <%= f.label :type %>
+ <%= f.text_field :type %>
+
+ <%= f.label :name %>
+ <%= f.text_field :name %>
+
+ <%= f.label :description %>
+ <%= f.text_field :description %>
+
+ <%= f.label :account_balance %>
+ <%= f.text_field :account_balance %>
+
+ <%= f.label :account_updated %>
+ <%= f.datetime_select :account_updated %>
+
+ <%= f.label :created_on %>
+ <%= f.datetime_select :created_on %>
+
+ <%= f.label :role_admin %>
+ <%= f.check_box :role_admin %>
+
+ <%= f.label :role_suppliers %>
+ <%= f.check_box :role_suppliers %>
+
+ <%= f.label :role_article_meta %>
+ <%= f.check_box :role_article_meta %>
+
+ <%= f.label :role_finance %>
+ <%= f.check_box :role_finance %>
+
+ <%= f.label :role_orders %>
+ <%= f.check_box :role_orders %>
+
+ <%= f.label :weekly_task %>
+ <%= f.check_box :weekly_task %>
+
+ <%= f.label :weekday %>
+ <%= f.text_field :weekday %>
+
+ <%= f.label :task_name %>
+ <%= f.text_field :task_name %>
+
+ <%= f.label :task_description %>
+ <%= f.text_field :task_description %>
+
+ <%= f.label :task_required_users %>
+ <%= f.text_field :task_required_users %>
+
+ <%= f.label :deleted_at %>
+ <%= f.datetime_select :deleted_at %>
+
+ <%= f.label :contact_person %>
+ <%= f.text_field :contact_person %>
+
+ <%= f.label :contact_phone %>
+ <%= f.text_field :contact_phone %>
+
+ <%= f.label :contact_address %>
+ <%= f.text_field :contact_address %>
+
<%= f.submit "Submit" %>
+<% end %> + + diff --git a/app/views/workgroups/index.html.erb b/app/views/workgroups/index.html.erb new file mode 100644 index 00000000..1025a124 --- /dev/null +++ b/app/views/workgroups/index.html.erb @@ -0,0 +1,52 @@ +<% title "Workgroups" %> + +Type | +Name | +Description | +Account Balance | +Account Updated | +Created On | +Role Admin | +Role Suppliers | +Role Article Meta | +Role Finance | +Role Orders | +Weekly Task | +Weekday | +Task Name | +Task Description | +Task Required Users | +Deleted At | +Contact Person | +Contact Phone | +Contact Address | +|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
<%=h workgroup.type %> | +<%=h workgroup.name %> | +<%=h workgroup.description %> | +<%=h workgroup.account_balance %> | +<%=h workgroup.account_updated %> | +<%=h workgroup.created_on %> | +<%=h workgroup.role_admin %> | +<%=h workgroup.role_suppliers %> | +<%=h workgroup.role_article_meta %> | +<%=h workgroup.role_finance %> | +<%=h workgroup.role_orders %> | +<%=h workgroup.weekly_task %> | +<%=h workgroup.weekday %> | +<%=h workgroup.task_name %> | +<%=h workgroup.task_description %> | +<%=h workgroup.task_required_users %> | +<%=h workgroup.deleted_at %> | +<%=h workgroup.contact_person %> | +<%=h workgroup.contact_phone %> | +<%=h workgroup.contact_address %> | +<%= link_to "Edit", edit_workgroup_path(workgroup) %> | +