diff options
author | Heiko Bernloehr <Heiko.Bernloehr@FreeIT.de> | 2013-08-13 23:18:50 +0200 |
---|---|---|
committer | Heiko Bernloehr <Heiko.Bernloehr@FreeIT.de> | 2014-05-07 02:58:28 +0200 |
commit | ce1773461b71a40afb406f4148b32aad11b52a57 (patch) | |
tree | 88f779715658a74c2ac8bb8972e7879c5b10e1b3 /app | |
parent | 561be6974dc030309a2165726c5b4ff3f0afba2d (diff) | |
download | ecs2-ce1773461b71a40afb406f4148b32aad11b52a57.tar.gz ecs2-ce1773461b71a40afb406f4148b32aad11b52a57.zip |
Turn on/off events by participants.
Up to now events could be turned on and off by resources. To turn on
events you still have to do it by resource but have additionally
the possibility to control it by participant. Only if both switches are
on, the participant will get events generated through the resource.
Diffstat (limited to 'app')
-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 |
6 files changed, 21 insertions, 2 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 |