diff options
-rw-r--r-- | app/models/event.rb | 5 | ||||
-rw-r--r-- | app/models/participant.rb | 3 | ||||
-rw-r--r-- | app/models/ressource.rb | 4 | ||||
-rw-r--r-- | app/views/admin/participants/_form.html.erb | 3 | ||||
-rw-r--r-- | app/views/admin/participants/list.html.haml | 2 | ||||
-rw-r--r-- | app/views/admin/participants/show.html.haml | 6 | ||||
-rw-r--r-- | config/ecs_config.yml | 1 | ||||
-rw-r--r-- | config/initializers/ecs_00.rb | 1 | ||||
-rw-r--r-- | db/migrate/20130813144307_add_events_to_participant.rb | 13 | ||||
-rw-r--r-- | db/schema.rb | 3 |
10 files changed, 38 insertions, 3 deletions
diff --git a/app/models/event.rb b/app/models/event.rb index ad352d2..4885f8f 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -40,9 +40,10 @@ private def self.make(options) options.assert_valid_keys(:event_type_name, :membership_message, :participant, :message) message = options[:membership_message] ? options[:membership_message].message : options[:message] - return unless message.ressource.events + participant= options[:membership_message] ? options[:membership_message].membership.participant : options[:participant] + return if not (message.ressource.events? and participant.events?) event = Event.new - event.participant_id = options[:membership_message] ? options[:membership_message].membership.participant.id : options[:participant].id + event.participant_id = participant.id event.message_id = message.id case options[:event_type_name] when "created" diff --git a/app/models/participant.rb b/app/models/participant.rb index c9f6746..3e7d924 100644 --- a/app/models/participant.rb +++ b/app/models/participant.rb @@ -59,6 +59,9 @@ class Participant < ActiveRecord::Base not Membership.receiver(id, message.id).empty? end + def events? + self.events_.blank? ? false : true + end def self.generate_anonymous_participant cookie = Digest::SHA1.hexdigest('something secret'+Time.now.to_s+rand.to_s) diff --git a/app/models/ressource.rb b/app/models/ressource.rb index 1aba41a..0a741dd 100644 --- a/app/models/ressource.rb +++ b/app/models/ressource.rb @@ -36,6 +36,10 @@ class Ressource < ActiveRecord::Base return r end + def events? + self.events.blank? ? false : true + end + private def rebuild_routes diff --git a/app/views/admin/participants/_form.html.erb b/app/views/admin/participants/_form.html.erb index 81aaa08..13e920d 100644 --- a/app/views/admin/participants/_form.html.erb +++ b/app/views/admin/participants/_form.html.erb @@ -52,6 +52,9 @@ License along with ECS. If not, see <http://www.gnu.org/licenses/>. <p><label for="participant_community_selfrouting" class="box2 table-resource-label">Community Selfrouting:</label> <%= form.check_box :community_selfrouting %></p> +<p><label for="participant_events_" class="box2 table-resource-label">Events:</label> +<%= form.check_box :events_ %></p> + <p> <div class="formular-input-width"> <div class="table-border"> diff --git a/app/views/admin/participants/list.html.haml b/app/views/admin/participants/list.html.haml index 0366bbb..ea294e1 100644 --- a/app/views/admin/participants/list.html.haml +++ b/app/views/admin/participants/list.html.haml @@ -33,6 +33,7 @@ %th.box2 ↑ Name: %th.box2 Description (optional): %th.box2 Self-<br/>routing: + %th.box2 Events: %th.box2(align="center") Operations: %tr @@ -48,6 +49,7 @@ %td= participant.name %td= truncate(participant.description, :length => 80) %td.center= check_box_tag "participant[community_selfrouting]",1,participant.community_selfrouting, :disabled => true + %td.center= check_box_tag "participant[events_]",1,participant.events_, :disabled => true %td = link_to 'Show', admin_participant_url(:id => participant) = link_to 'Edit', edit_admin_participant_url(:id => participant) diff --git a/app/views/admin/participants/show.html.haml b/app/views/admin/participants/show.html.haml index c81b93b..d7b4845 100644 --- a/app/views/admin/participants/show.html.haml +++ b/app/views/admin/participants/show.html.haml @@ -47,6 +47,12 @@ // = check_box_tag "participant[community_selfrouting]",1,@participant.community_selfrouting, :disabled => true = @participant.community_selfrouting.to_s +.small-skip + %span.box5 + %label.box4.table-resource-label Events: + // = check_box_tag "participant[community_selfrouting]",1,@participant.community_selfrouting, :disabled => true + = @participant.events?.to_s + - unless @participant.description.blank? %p .formular-input-width.table-border diff --git a/config/ecs_config.yml b/config/ecs_config.yml index 2916b66..b3af8fe 100644 --- a/config/ecs_config.yml +++ b/config/ecs_config.yml @@ -1,3 +1,4 @@ participants: allow_anonymous: false + allow_events: true # for database migration diff --git a/config/initializers/ecs_00.rb b/config/initializers/ecs_00.rb index baca196..6aa5db3 100644 --- a/config/initializers/ecs_00.rb +++ b/config/initializers/ecs_00.rb @@ -36,3 +36,4 @@ rescue Exception end ECS_CONFIG["participants"]["allow_anonymous"] = false unless defined? ECS_CONFIG["participants"]["allow_anonymous"] +ECS_CONFIG["participants"]["allow_events"] = true unless defined? ECS_CONFIG["participants"]["allow_events"] diff --git a/db/migrate/20130813144307_add_events_to_participant.rb b/db/migrate/20130813144307_add_events_to_participant.rb new file mode 100644 index 0000000..a1dd85f --- /dev/null +++ b/db/migrate/20130813144307_add_events_to_participant.rb @@ -0,0 +1,13 @@ +class AddEventsToParticipant < ActiveRecord::Migration + def self.up + add_column :participants, :events_, :boolean, :default => true + Participant.all.each do |p| + p.events_= ECS_CONFIG["participants"]["allow_events"] + p.save! + end + end + + def self.down + remove_column :participants, :events_ + end +end diff --git a/db/schema.rb b/db/schema.rb index a8d2fe1..74f16be 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,7 +9,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20110303145153) do +ActiveRecord::Schema.define(:version => 20130813144307) do create_table "auths", :force => true do |t| t.string "one_touch_hash" @@ -99,6 +99,7 @@ ActiveRecord::Schema.define(:version => 20110303145153) do t.datetime "created_at" t.datetime "updated_at" t.boolean "community_selfrouting", :default => false + t.boolean "events_", :default => true end create_table "ressources", :force => true do |t| |