aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeiko Bernloehr <Heiko.Bernloehr@FreeIT.de>2015-04-21 09:51:07 +0200
committerHeiko Bernloehr <Heiko.Bernloehr@FreeIT.de>2016-01-27 01:50:45 +0100
commitc4c0d3425190df6ad1e0617dcccc4d5f5f4bf17e (patch)
tree9c2aa14bac68a77aee62bbaf6fc302eef453842b
parent2448258421fe1d86fc806489313786b4e6e27c75 (diff)
downloadecs2-c4c0d3425190df6ad1e0617dcccc4d5f5f4bf17e.tar.gz
ecs2-c4c0d3425190df6ad1e0617dcccc4d5f5f4bf17e.zip
Type tags for /sys/memberships.
Participants in /sys/mebmberships representation are now tagged with their appropriate participant type: main: mainparticipant sub: subparticipant anonym: anonymous participant e.g. [ { "community": { "name": "public", "description": "For anonymous participants.", "cid": 1 }, "participants": [ { "pid": 2, --> "type": "main", "name": "Computation client", "itsyou": true, "description": "Computation client of NumLab service.", "org": { "abbr": "S", "name": "Universität Stuttgart" }, "mid": 1, "email": "rudlof@rus.uni-stuttgart.de", "dns": "nfldevvipecs.rus.uni-stuttgart.de" }, ... This feature needs a database migration.
-rw-r--r--app/controllers/admin/participants_controller.rb1
-rw-r--r--app/models/membership.rb2
-rw-r--r--app/models/participant.rb42
-rw-r--r--app/models/subparticipant.rb1
-rw-r--r--db/schema.rb3
5 files changed, 35 insertions, 14 deletions
diff --git a/app/controllers/admin/participants_controller.rb b/app/controllers/admin/participants_controller.rb
index 1e32b6b..1f2c49f 100644
--- a/app/controllers/admin/participants_controller.rb
+++ b/app/controllers/admin/participants_controller.rb
@@ -66,6 +66,7 @@ class Admin::ParticipantsController < ApplicationController
def create
@participant = Participant.new(params[:participant])
+ @participant.ptype = Participant::TYPE[:main]
if @participant.save
flash[:notice] = 'Participant was successfully created.'
redirect_to admin_participants_path
diff --git a/app/models/membership.rb b/app/models/membership.rb
index 87742b9..fda3093 100644
--- a/app/models/membership.rb
+++ b/app/models/membership.rb
@@ -91,8 +91,10 @@ class Membership < ActiveRecord::Base
attribs["org"] = {"name" => p.organization.name, "abbr" => p.organization.abrev}
attribs["itsyou"] = p.id == participant.id
attribs["pid"] = p.id
+ attribs["type"] = p.ptype
attribs.delete("id")
attribs.delete("organization_id")
+ attribs.delete("ptype")
attribs
end
logger.debug "**** Membership::memberships: participants: #{participants.inspect}"
diff --git a/app/models/participant.rb b/app/models/participant.rb
index 944d75e..2252aa7 100644
--- a/app/models/participant.rb
+++ b/app/models/participant.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de).
+# Copyright (C) 2007, 2008, 2009, 2010, 2014 Heiko Bernloehr (FreeIT.de).
#
# This file is part of ECS.
#
@@ -18,6 +18,7 @@
class Participant < ActiveRecord::Base
TTL = 1.hour # how long an anonymous participant lives
+ TYPE={ :main => "main", :sub => "sub", :anonym => "anonym" }
after_destroy :delete_messages
@@ -52,26 +53,44 @@ class Participant < ActiveRecord::Base
:conditions => { :communities => { :id => community.id }}}}
named_scope :for_subparticipants
named_scope :itsyou, lambda { |itsyoupid| { :conditions => { :participants => { :id => itsyoupid } } } }
- named_scope :only_subparticipants, :joins => [:subparticipant]
+ named_scope :only_subparticipants, :conditions => { :participants => { :ptype => TYPE[:sub] } }
+ named_scope :only_mainparticipants, :conditions => { :participants => { :ptype => TYPE[:main] } }
+ named_scope :only_anonymous, :conditions => { :participants => { :ptype => TYPE[:anonym] } }
def self.reduced_attributes
- find :all, :select => "participants.id, participants.name, participants.description, participants.email, participants.dns, participants.organization_id"
+ find :all, :select => "participants.id, participants.name, participants.description, participants.email, participants.dns, participants.organization_id, participants.ptype"
end
def self.mainparticipants_with_reduced_attributes
- without_anonymous.order_id_asc.reduced_attributes - only_subparticipants.reduced_attributes
+ only_mainparticipants.order_id_asc.reduced_attributes
end
def self.subparticipants_with_reduced_attributes
only_subparticipants.order_id_asc.reduced_attributes
end
- def self.without_anonymous_with_reduced_attributes
- without_anonymous.order_id_asc.reduced_attributes
+ def self.anonymous_participants_with_reduced_attributes
+ only_anonymous.order_id_asc.reduced_attributes
end
- def self.anonymous_participants_with_reduced_attributes
- anonymous.order_id_asc.reduced_attributes
+ def mainparticipant?
+ if not anonymousparticipant? and subparticipant.nil?
+ true
+ else
+ false
+ end
+ end
+
+ def subparticipant?
+ if not anonymousparticipant? and not subparticipant.nil?
+ true
+ else
+ false
+ end
+ end
+
+ def anonymousparticipant?
+ anonymous?
end
# test if the participant is the initial sender of the message in question.
@@ -95,10 +114,6 @@ class Participant < ActiveRecord::Base
anonymous
end
- def subparticipant?
- subparticipant
- end
-
def self.generate_anonymous_participant
cookie = Digest::SHA1.hexdigest('something secret'+Time.now.to_s+rand.to_s)
params = {
@@ -110,7 +125,8 @@ class Participant < ActiveRecord::Base
"organization_id"=>Organization.find_by_name("not available").id,
"email"=>"N/A",
"ttl"=> DateTime.now.utc + TTL,
- "anonymous"=>true
+ "anonymous"=>true,
+ "ptype"=>TYPE[:anonym]
}
ap = new(params)
ap.save!
diff --git a/app/models/subparticipant.rb b/app/models/subparticipant.rb
index 6d44ffa..2efc504 100644
--- a/app/models/subparticipant.rb
+++ b/app/models/subparticipant.rb
@@ -43,6 +43,7 @@ class Subparticipant < ActiveRecord::Base
"email" => parent.email,
"ttl" => nil,
"anonymous" => false,
+ "ptype" => Participant::TYPE[:sub],
"community_selfrouting" => data[:community_selfrouting],
"events_" => data[:events],
"subparticipant_attributes" => { :realm => data[:realm] }
diff --git a/db/schema.rb b/db/schema.rb
index 254e303..4bf5c6b 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 => 20140525164346) do
+ActiveRecord::Schema.define(:version => 20150420210728) do
create_table "auths", :force => true do |t|
t.string "one_touch_hash"
@@ -100,6 +100,7 @@ ActiveRecord::Schema.define(:version => 20140525164346) do
t.datetime "updated_at"
t.boolean "community_selfrouting", :default => false
t.boolean "events_", :default => true
+ t.string "ptype"
end
create_table "ressources", :force => true do |t|