aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeiko Bernloehr <Heiko.Bernloehr@FreeIT.de>2012-10-16 18:50:24 +0200
committerHeiko Bernloehr <Heiko.Bernloehr@FreeIT.de>2012-10-16 18:54:13 +0200
commit97abb997732314696756aea12e3a2a74f6a7cca9 (patch)
treede7ee54667f2377c61960f2e9d873e6d7c4ce063
parent859a06d797a047d74bc5ff27bf61e7315437a2f6 (diff)
downloadecs2-97abb997732314696756aea12e3a2a74f6a7cca9.tar.gz
ecs2-97abb997732314696756aea12e3a2a74f6a7cca9.zip
Listing of participants in community view.
When showing a community in the administration there is now a listing of all joined participants.
-rw-r--r--app/models/participant.rb4
-rw-r--r--app/views/admin/communities/show.html.erb45
-rw-r--r--app/views/admin/communities/show.html.haml60
3 files changed, 63 insertions, 46 deletions
diff --git a/app/models/participant.rb b/app/models/participant.rb
index 3191b4e..f2ffb17 100644
--- a/app/models/participant.rb
+++ b/app/models/participant.rb
@@ -42,7 +42,9 @@ class Participant < ActiveRecord::Base
named_scope :for_message, lambda { |message| {
:joins => [:memberships => {:membership_messages => :message}],
:conditions => {:messages => {:id => message.id}}}}
-
+ named_scope :for_community, lambda { |community| {
+ :joins => [:memberships => :community],
+ :conditions => { :communities => { :id => community.id }}}}
# test if the participant is the initial sender of the message in question.
def sender?(message)
diff --git a/app/views/admin/communities/show.html.erb b/app/views/admin/communities/show.html.erb
deleted file mode 100644
index 9027067..0000000
--- a/app/views/admin/communities/show.html.erb
+++ /dev/null
@@ -1,45 +0,0 @@
-<!--
-Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
-
-This file is part of ECS.
-
-ECS is free software: you can redistribute it and/or modify it
-under the terms of the GNU Affero General Public License as
-published by the Free Software Foundation, either version 3 of
-the License, or (at your option) any later version.
-
-ECS is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Affero General Public License for more details.
-
-You should have received a copy of the GNU Affero General Public
-License along with ECS. If not, see <http://www.gnu.org/licenses/>.
--->
-
-
-<h1 class="box1">Show Community</h1>
-
-<%= link_to 'Edit', edit_admin_community_url(:id => @community) %> |
-<%= link_to 'Back', admin_communities_url %>
-
-<p>
- <label class="box2 table-resource-label">Name:</label>
- <%= h @community.name %>
-</p>
-
-<p>
-<div class="formular-input-width">
-<div class="table-border">
-<div class="table-header">
- <label class="table-resource-label">Description (optional):</label>
-</div>
- <%= h(@community.description).gsub(/\r\n/, '<BR>') %>
-</div>
-</div>
-</p>
-
-<p>
-<%= link_to 'Edit', edit_admin_community_url(:id => @community) %> |
-<%= link_to 'Back', admin_communities_url %>
-</p>
diff --git a/app/views/admin/communities/show.html.haml b/app/views/admin/communities/show.html.haml
new file mode 100644
index 0000000..7a8f4b2
--- /dev/null
+++ b/app/views/admin/communities/show.html.haml
@@ -0,0 +1,60 @@
+-#
+ Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 Heiko Bernloehr (FreeIT.de).
+
+ This file is part of ECS.
+
+ ECS is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ ECS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public
+ License along with ECS. If not, see <http://www.gnu.org/licenses/>.
+
+
+%h1.box1 Show Community
+
+%p
+ = link_to 'Edit', edit_admin_community_url(:id => @community)
+ |
+ = link_to 'Back', admin_communities_url
+
+.normal-skip
+ %span.box5
+ %label.box2.table-resource-label(for="community_name") Name:
+ = h @community.name
+
+- unless @community.description.blank?
+ %p
+ .formular-input-width.table-border
+ .table-header
+ %label.table-resource-label Description (optional):
+ = @community.description.gsub(/\r\n/, '<BR>')
+
+- unless (participants= Participant.for_community(@community)).blank?
+ %p
+ .show-output-width.table-border
+ .table-header
+ %label.table-resource-label Participants joining this community:
+
+ %table.list(width="100%")
+ %tr(align="left")
+ %th ID:
+ %th Name:
+ %th Description:
+ - participants.each do |participant|
+ %tr{:class => [cycle('list-line-odd', 'list-line-even')]}
+ %td= link_to h(participant.id), admin_participant_path(participant)
+ %td= participant.name
+ %td= h(participant.description).gsub(/\r\n/, '<BR>')
+
+%p
+ = link_to 'Edit', edit_admin_community_url(:id => @community)
+ |
+ = link_to 'Back', admin_communities_url
+