From 23868446a798324e33270eeaa5026aa06522e7a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Sch=C3=A4fer?= Date: Sat, 26 Feb 2011 13:26:35 +0100 Subject: [PATCH] Add a close action to agendas. #2417 --- app/controllers/meeting_agendas_controller.rb | 5 +++++ app/controllers/meetings_controller.rb | 1 + app/models/meeting_agenda.rb | 3 +++ app/views/meeting_contents/_show.html.erb | 1 + config/locales/de.yml | 1 + config/locales/en.yml | 1 + config/routes.rb | 4 ++-- ...0110224180804_add_lock_to_meeting_content.rb | 11 +++++++++++ features/meeting_close.feature | 17 ++++++++++------- init.rb | 1 + spec/factories/meeting_agenda_factory.rb | 4 ++++ spec/models/meeting_agenda_spec.rb | 17 +++++++++++++++++ 12 files changed, 57 insertions(+), 9 deletions(-) create mode 100644 db/migrate/20110224180804_add_lock_to_meeting_content.rb create mode 100644 spec/factories/meeting_agenda_factory.rb create mode 100644 spec/models/meeting_agenda_spec.rb diff --git a/app/controllers/meeting_agendas_controller.rb b/app/controllers/meeting_agendas_controller.rb index a16a4fb533..0644a2fd51 100644 --- a/app/controllers/meeting_agendas_controller.rb +++ b/app/controllers/meeting_agendas_controller.rb @@ -3,6 +3,11 @@ class MeetingAgendasController < MeetingContentsController menu_item :meetings + def close + @content.lock! + redirect_to :back + end + private def find_content diff --git a/app/controllers/meetings_controller.rb b/app/controllers/meetings_controller.rb index 3cbdce4156..d2a3244f3c 100644 --- a/app/controllers/meetings_controller.rb +++ b/app/controllers/meetings_controller.rb @@ -79,6 +79,7 @@ class MeetingsController < ApplicationController def convert_params params[:meeting][:start_time] = Date.parse(params[:meeting].delete(:start_date)) + params[:meeting].delete(:"start_time(4i)").to_i.hours + params[:meeting].delete(:"start_time(5i)").to_i.minutes params[:meeting][:duration] = params[:meeting][:duration].to_hours + # Force defaults on participants params[:meeting][:participants_attributes].each {|p| p.reverse_merge! :attended => false, :invited => false} end end diff --git a/app/models/meeting_agenda.rb b/app/models/meeting_agenda.rb index 9dd58a2837..911639a5bd 100644 --- a/app/models/meeting_agenda.rb +++ b/app/models/meeting_agenda.rb @@ -1,2 +1,5 @@ class MeetingAgenda < MeetingContent + def lock! + update_attribute :locked, true + end end \ No newline at end of file diff --git a/app/views/meeting_contents/_show.html.erb b/app/views/meeting_contents/_show.html.erb index ebb8d1ff66..2544196880 100644 --- a/app/views/meeting_contents/_show.html.erb +++ b/app/views/meeting_contents/_show.html.erb @@ -2,6 +2,7 @@
<%= link_to l(:button_edit), "#", :class => 'icon icon-edit', :accesskey => accesskey(:edit), :onclick => "Element.show(\"edit-#{content_type}\"); Element.hide(\"#{content_type}-text\"); return false;" if (authorize_for(content_type.pluralize, 'update') && (content.blank? || content.editable?)) %> <%= link_to_if_authorized(l(:label_history), {:controller => content_type.pluralize, :action => 'history', :meeting_id => @meeting}, :class => 'icon icon-history') unless content.blank? %> + <%= link_to_if_authorized l(:label_close), {:controller => content_type.pluralize, :action => 'close', :meeting_id => @meeting}, :method => :put, :class => 'icon icon-lock' %>

<%= title %>

<% if authorize_for(content_type.pluralize, 'update') -%> diff --git a/config/locales/de.yml b/config/locales/de.yml index e164468939..b9ed2878c4 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -5,6 +5,7 @@ de: label_meeting_new: "Neues Meeting" label_meeting_agenda: "Agenda" label_meeting_minutes: "Protokoll" + label_close: "Schließen" field_participants: "Teilnehmer" field_participants_invited: "Eingeladen" field_participants_attended: "Anwesend" diff --git a/config/locales/en.yml b/config/locales/en.yml index 66e981cc88..0281a628da 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -5,6 +5,7 @@ en: label_meeting_new: "New Meeting" label_meeting_agenda: "Agenda" label_meeting_minutes: "Minutes" + label_close: "Close" field_participants: "Participants" field_participants_invited: "Invitees" field_participants_attended: "Attendants" diff --git a/config/routes.rb b/config/routes.rb index ae9a6fd9e4..6a32ab984e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,8 +2,8 @@ ActionController::Routing::Routes.draw do |map| map.resources :projects, :only => [] do |project| project.resources :meetings, :shallow => true do |meeting| - meeting.resource :meeting_agenda, :as => 'agenda', :only => [:update, :show], :collection => {:history => :get, :diff => :get} - meeting.resource :meeting_minutes, :as => 'minutes', :only => [:update, :show], :collection => {:history => :get, :diff => :get} + meeting.resource :agenda, :controller => 'meeting_agendas', :only => [:update, :show], :member => {:history => :get, :diff => :get, :close => :put} + meeting.resource :minutes, :controller => 'meeting_minutes', :only => [:update, :show], :member => {:history => :get, :diff => :get} end end end \ No newline at end of file diff --git a/db/migrate/20110224180804_add_lock_to_meeting_content.rb b/db/migrate/20110224180804_add_lock_to_meeting_content.rb new file mode 100644 index 0000000000..38924e2831 --- /dev/null +++ b/db/migrate/20110224180804_add_lock_to_meeting_content.rb @@ -0,0 +1,11 @@ +class AddLockToMeetingContent < ActiveRecord::Migration + def self.up + add_column :meeting_contents, :locked, :boolean, :default => false + add_column :meeting_content_versions, :locked, :boolean, :default => nil + end + + def self.down + remove_column :meeting_contents, :locked + remove_column :meeting_content_versions, :locked + end +end diff --git a/features/meeting_close.feature b/features/meeting_close.feature index f19a711a4f..503f36c627 100644 --- a/features/meeting_close.feature +++ b/features/meeting_close.feature @@ -19,7 +19,7 @@ Feature: Close existing meetings @javascript Scenario: Navigate to a meeting page with no permission to close meetings Given the role "user" may have the following rights: - | view_meetings | + | view_meetings | When I login as "alice" And I go to the Meetings page for the project called "dingens" And I click on "Bobs Meeting" @@ -28,20 +28,23 @@ Feature: Close existing meetings @javascript Scenario: Navigate to a meeting page with permission to close meetings Given the role "user" may have the following rights: - | view_meetings | - | close_meetings | + | view_meetings | + | close_meeting_agendas | When I login as "alice" And I go to the Meetings page for the project called "dingens" And I click on "Bobs Meeting" Then I should see "Close" within ".meeting_agenda" @javascript - Scenario: Navigate to a meeting page with permission to close meetings and close the meeting + Scenario: Navigate to a meeting page with permission to close and edit meetings and close the meeting Given the role "user" may have the following rights: - | view_meetings | - | close_meetings | + | view_meetings | + | create_meeting_agendas | + | close_meeting_agendas | When I login as "alice" And I go to the Meetings page for the project called "dingens" And I click on "Bobs Meeting" And I click on "Close" - Then I should not see "Edit" within ".meeting_agenda" \ No newline at end of file + Then I should not see "Edit" within ".meeting_agenda" + And I should not see "Close" within ".meeting_agenda" + And I should see "Open" within ".meeting_agenda" \ No newline at end of file diff --git a/init.rb b/init.rb index ffad493577..9ef9d3659f 100644 --- a/init.rb +++ b/init.rb @@ -22,6 +22,7 @@ Redmine::Plugin.register :redmine_meeting do permission :edit_meetings, {:meetings => [:edit, :update]}, :require => :member permission :delete_meetings, {:meetings => [:destroy]}, :require => :member permission :view_meetings, {:meetings => [:index, :show], :meeting_agendas => [:history, :show, :diff], :meeting_minutes => [:history, :show, :diff]} + permission :close_meeting_agendas, {:meeting_agendas => [:close]}, :require => :member permission :create_meeting_agendas, {:meeting_agendas => [:update]}, :require => :member permission :create_meeting_minutes, {:meeting_minutes => [:update]}, :require => :member end diff --git a/spec/factories/meeting_agenda_factory.rb b/spec/factories/meeting_agenda_factory.rb new file mode 100644 index 0000000000..66c44bb577 --- /dev/null +++ b/spec/factories/meeting_agenda_factory.rb @@ -0,0 +1,4 @@ +Factory.define :meeting_agenda do |a| + # TODO: Wird das gebraucht? + #a.type "MeetingAgenda" +end \ No newline at end of file diff --git a/spec/models/meeting_agenda_spec.rb b/spec/models/meeting_agenda_spec.rb new file mode 100644 index 0000000000..bfbd3991f5 --- /dev/null +++ b/spec/models/meeting_agenda_spec.rb @@ -0,0 +1,17 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe "MeetingAgenda" do + before(:all) do + #@m = Factory.build :meeting, :title => "dingens" + @a = Factory.build :meeting_agenda, :text => "Some content...\n\nMore content!\n\nExtraordinary content!!" + end + + describe "#lock!" do + it "locks the agenda" do + @a.save + @a.lock! + @a.reload + @a.locked.should be_true + end + end +end \ No newline at end of file