Diff
Modified: branches/events/Rakefile (3112 => 3113)
--- branches/events/Rakefile 2012-08-25 05:57:12 UTC (rev 3112)
+++ branches/events/Rakefile 2012-08-25 13:41:30 UTC (rev 3113)
@@ -192,21 +192,22 @@
puts doc.to_s
end
-desc 'Create initial events'
-task "myexp:events:create" do
+desc 'Create initial activities'
+task "myexp:activities:create" do
require File.dirname(__FILE__) + '/config/environment'
- events = []
+ activities = []
- events += User.all.map do |u|
- Event.new(
- :subject => u,
+ activities += User.find(:all, :conditions => "activated_at IS NOT NULL").map do |object|
+ Activity.new(
+ :subject => object,
+ :subject_label => object.name,
:action ="" 'register',
- :created_at => u.created_at)
+ :created_at => object.created_at)
end
- events += (Workflow.all + Blob.all + Pack.all + Blog.all).map do |object|
- Event.new(
+ activities += (Workflow.all + Blob.all + Pack.all + Blog.all).map do |object|
+ Activity.new(
:subject => object.contributor,
:action ="" 'create',
:objekt => object,
@@ -214,32 +215,28 @@
:created_at => object.created_at)
end
- events += (WorkflowVersion.all).map do |object|
- if object.version > 1
- Event.new(
- :subject => object.contributor,
- :action ="" 'create',
- :objekt => object,
- :extra => object.version,
- :auth => object.versioned_resource,
- :created_at => object.created_at)
- end
+ activities += (WorkflowVersion.find(:all, :conditions => "version > 1")).map do |object|
+ Activity.new(
+ :subject => object.contributor,
+ :action ="" 'create',
+ :objekt => object,
+ :extra => object.version,
+ :auth => object.versioned_resource,
+ :created_at => object.created_at)
end
- events += (BlobVersion.all).map do |object|
- if object.version > 1
- Event.new(
- :subject => object.blob.contributor,
- :action ="" 'create',
- :objekt => object,
- :extra => object.version,
- :auth => object.versioned_resource,
- :created_at => object.created_at)
- end
+ activities += (BlobVersion.find(:all, :conditions => "version > 1")).map do |object|
+ Activity.new(
+ :subject => object.blob.contributor,
+ :action ="" 'create',
+ :objekt => object,
+ :extra => object.version,
+ :auth => object.versioned_resource,
+ :created_at => object.created_at)
end
- events += Comment.all.map do |comment|
- Event.new(
+ activities += Comment.all.map do |comment|
+ Activity.new(
:subject => comment.user,
:action ="" 'create',
:objekt => comment,
@@ -247,8 +244,8 @@
:created_at => comment.created_at)
end
- events += Bookmark.all.map do |bookmark|
- Event.new(
+ activities += Bookmark.all.map do |bookmark|
+ Activity.new(
:subject => bookmark.user,
:action ="" 'create',
:objekt => bookmark,
@@ -256,13 +253,12 @@
:created_at => bookmark.created_at)
end
-
- events.sort do |a, b|
+ activities.sort do |a, b|
a.created_at <=> b.created_at
end
- events.each do |event|
- event.save
+ activities.each do |activity|
+ activity.save
end
end
Modified: branches/events/app/controllers/announcements_controller.rb (3112 => 3113)
--- branches/events/app/controllers/announcements_controller.rb 2012-08-25 05:57:12 UTC (rev 3112)
+++ branches/events/app/controllers/announcements_controller.rb 2012-08-25 13:41:30 UTC (rev 3113)
@@ -50,7 +50,7 @@
params[:announcement][:user_id] = current_user.id
@announcement = Announcement.new(params[:announcement])
if @announcement.save
- Event.create(:subject => current_user, :action ="" 'create', :objekt => @announcement)
+ Activity.create(:subject => current_user, :action ="" 'create', :objekt => @announcement)
flash[:notice] = 'Announcement was successfully created.'
redirect_to :action ="" 'index'
else
@@ -65,7 +65,7 @@
def update
@announcement = Announcement.find(params[:id])
if @announcement.update_attributes(params[:announcement])
- Event.create(:subject => current_user, :action ="" 'edit', :objekt => @announcement)
+ Activity.create(:subject => current_user, :action ="" 'edit', :objekt => @announcement)
flash[:notice] = 'Announcement was successfully updated.'
redirect_to :action ="" 'show', :id => @announcement
else
Modified: branches/events/app/controllers/blobs_controller.rb (3112 => 3113)
--- branches/events/app/controllers/blobs_controller.rb 2012-08-25 05:57:12 UTC (rev 3112)
+++ branches/events/app/controllers/blobs_controller.rb 2012-08-25 13:41:30 UTC (rev 3113)
@@ -152,7 +152,7 @@
respond_to do |format|
if @blob.save
- Event.create(:subject => current_user, :action ="" 'create', :objekt => @blob, :auth => @blob)
+ Activity.create(:subject => current_user, :action ="" 'create', :objekt => @blob, :auth => @blob)
if params[:blob][:tag_list]
@blob.tags_user_id = current_user
@blob.tag_list = convert_tags_to_gem_format params[:blob][:tag_list]
@@ -221,9 +221,9 @@
if @blob.update_attributes(params[:blob])
if @blob.new_version_number
- Event.create(:subject => current_user, :action ="" 'create', :objekt => @blob.find_version(@blob.new_version_number), :extra => @blob.new_version_number, :auth => @blob)
+ Activity.create(:subject => current_user, :action ="" 'create', :objekt => @blob.find_version(@blob.new_version_number), :extra => @blob.new_version_number, :auth => @blob)
else
- Event.create(:subject => current_user, :action ="" 'edit', :objekt => @blob, :auth => @blob)
+ Activity.create(:subject => current_user, :action ="" 'edit', :objekt => @blob, :auth => @blob)
end
@blob.refresh_tags(convert_tags_to_gem_format(params[:blob][:tag_list]), current_user) if params[:blob][:tag_list]
@@ -320,7 +320,7 @@
success = bookmark.save
if success
- Event.create(:subject => current_user, :action ="" 'create', :objekt => bookmark, :auth => @blob)
+ Activity.create(:subject => current_user, :action ="" 'create', :objekt => bookmark, :auth => @blob)
end
respond_to do |format|
Modified: branches/events/app/controllers/comments_controller.rb (3112 => 3113)
--- branches/events/app/controllers/comments_controller.rb 2012-08-25 05:57:12 UTC (rev 3112)
+++ branches/events/app/controllers/comments_controller.rb 2012-08-25 13:41:30 UTC (rev 3113)
@@ -38,7 +38,7 @@
success = comment.save
if success
- Event.create(:subject => current_user, :action ="" 'create', :objekt => comment, :auth => @context)
+ Activity.create(:subject => current_user, :action ="" 'create', :objekt => comment, :auth => @context)
@context.solr_save if @context.respond_to?(:solr_save)
end
end
Modified: branches/events/app/controllers/packs_controller.rb (3112 => 3113)
--- branches/events/app/controllers/packs_controller.rb 2012-08-25 05:57:12 UTC (rev 3112)
+++ branches/events/app/controllers/packs_controller.rb 2012-08-25 13:41:30 UTC (rev 3113)
@@ -198,7 +198,7 @@
success = bookmark.save
if success
- Event.create(:subject => current_user, :action ="" 'create', :objekt => bookmark, :auth => @pack)
+ Activity.create(:subject => current_user, :action ="" 'create', :objekt => bookmark, :auth => @pack)
end
respond_to do |format|
Modified: branches/events/app/controllers/users_controller.rb (3112 => 3113)
--- branches/events/app/controllers/users_controller.rb 2012-08-25 05:57:12 UTC (rev 3112)
+++ branches/events/app/controllers/users_controller.rb 2012-08-25 13:41:30 UTC (rev 3113)
@@ -318,7 +318,7 @@
user.errors.full_messages.each { |e| logger.error(e) }
#END DEBUG
if confirmed
- Event.create(:subject => user, :action ="" 'register')
+ Activity.create(:subject => user, :action ="" 'register')
self.current_user = user
self.current_user.process_pending_invitations! # look up any pending invites for this user + transfer them to relevant tables from 'pending_invitations' table
confirmed = false if !logged_in?
Modified: branches/events/app/controllers/workflows_controller.rb (3112 => 3113)
--- branches/events/app/controllers/workflows_controller.rb 2012-08-25 05:57:12 UTC (rev 3112)
+++ branches/events/app/controllers/workflows_controller.rb 2012-08-25 13:41:30 UTC (rev 3113)
@@ -48,7 +48,7 @@
success = bookmark.save
if success
- Event.create(:subject => current_user, :action ="" 'create', :objekt => bookmark, :auth => @workflow)
+ Activity.create(:subject => current_user, :action ="" 'create', :objekt => bookmark, :auth => @workflow)
end
respond_to do |format|
@@ -351,7 +351,7 @@
respond_to do |format|
if @workflow.save
- Event.create(:subject => current_user, :action ="" 'create', :objekt => @workflow, :auth => @workflow)
+ Activity.create(:subject => current_user, :action ="" 'create', :objekt => @workflow, :auth => @workflow)
if params[:workflow][:tag_list]
@workflow.refresh_tags(convert_tags_to_gem_format(params[:workflow][:tag_list]), current_user)
@@ -483,7 +483,7 @@
rescue
end
- Event.create(:subject => current_user, :action ="" 'create', :objekt => @workflow.versions.last, :extra => @workflow.versions.last.version, :auth => @workflow)
+ Activity.create(:subject => current_user, :action ="" 'create', :objekt => @workflow.versions.last, :extra => @workflow.versions.last.version, :auth => @workflow)
respond_to do |format|
flash[:notice] = 'New workflow version successfully created.'
@@ -541,7 +541,7 @@
if @workflow.update_attributes(params[:workflow])
- Event.create(:subject => current_user, :action ="" 'edit', :objekt => @workflow, :auth => @workflow)
+ Activity.create(:subject => current_user, :action ="" 'edit', :objekt => @workflow, :auth => @workflow)
if params[:workflow][:tag_list]
@workflow.refresh_tags(convert_tags_to_gem_format(params[:workflow][:tag_list]), current_user)
@@ -596,7 +596,7 @@
respond_to do |format|
if success
- Event.create(:subject => current_user, :action ="" 'edit', :objekt => version, :extra => version.version, :auth => @workflow)
+ Activity.create(:subject => current_user, :action ="" 'edit', :objekt => version, :extra => version.version, :auth => @workflow)
flash[:notice] = "Workflow version #{version.version}: \"#{original_title}\" has been updated."
format.html { redirect_to(workflow_url(@workflow) + "?version=#{params[:version]}") }
else
Modified: branches/events/app/helpers/application_helper.rb (3112 => 3113)
--- branches/events/app/helpers/application_helper.rb 2012-08-25 05:57:12 UTC (rev 3112)
+++ branches/events/app/helpers/application_helper.rb 2012-08-25 13:41:30 UTC (rev 3113)
@@ -565,12 +565,12 @@
end
end
- def subject_link(event)
- link_aux(event.subject, event.subject_label)
+ def subject_link(activity)
+ link_aux(activity.subject, activity.subject_label)
end
- def objekt_link(event)
- link_aux(event.objekt, event.objekt_label)
+ def objekt_link(activity)
+ link_aux(activity.objekt, activity.objekt_label)
end
conditions_expr = []
@@ -599,43 +599,43 @@
conditions = [conditions_expr] + conditions_operands
end
- visible_events = Authorization.scoped(Event,
- :auth_type => 'events.auth_type',
- :auth_id => 'events.auth_id',
- :group => 'events.id',
+ visible_activities = Authorization.scoped(Activity,
+ :auth_type => 'activities.auth_type',
+ :auth_id => 'activities.auth_id',
+ :group => 'activities.id',
:authorised_user => current_user)
- events = visible_events.find(:all,
+ activities = visible_activities.find(:all,
:conditions => conditions,
:order => 'created_at DESC',
:limit => 15)
markup = '<ol class="activity-feed">'
- markup << events.map do |event|
+ markup << activities.map do |activity|
- action = "" event.objekt
- "#{event.objekt_type} #{event.action}"
+ action = "" activity.objekt
+ "#{activity.objekt_type} #{activity.action}"
else
- "#{event.action}"
+ "#{activity.action}"
end
sentence = case action
- when "Announcement create": "#{subject_link(event)} announced #{objekt_link(event)}"
- when "Announcement edit": "#{subject_link(event)} edited #{objekt_link(event)}"
- when "Blob create": "#{subject_link(event)} uploaded #{objekt_link(event)}"
- when "Blob edit": "#{subject_link(event)} edited #{objekt_link(event)}"
- when "BlobVersion create": "#{subject_link(event)} uploaded a new version of #{objekt_link(event)}"
- when "BlobVersion edit": "#{subject_link(event)} edited version #{event.extra} of #{objekt_link(event)}"
- when "Bookmark create": "#{subject_link(event)} favourited #{objekt_link(event)}"
- when "Comment create": "#{subject_link(event)} commented on #{objekt_link(event)}"
- when "Pack create": "#{subject_link(event)} created #{objekt_link(event)}"
- when "Workflow create": "#{subject_link(event)} uploaded #{objekt_link(event)}"
- when "Workflow edit": "#{subject_link(event)} edited #{objekt_link(event)}"
- when "WorkflowVersion create": "#{subject_link(event)} uploaded a new version of #{objekt_link(event)}"
- when "WorkflowVersion edit": "#{subject_link(event)} edited version #{event.extra} of #{objekt_link(event)}"
- when "register": "#{subject_link(event)} joined #{Conf.sitename}"
- else "Unknown event"
+ when "Announcement create": "#{subject_link(activity)} announced #{objekt_link(activity)}"
+ when "Announcement edit": "#{subject_link(activity)} edited #{objekt_link(activity)}"
+ when "Blob create": "#{subject_link(activity)} uploaded #{objekt_link(activity)}"
+ when "Blob edit": "#{subject_link(activity)} edited #{objekt_link(activity)}"
+ when "BlobVersion create": "#{subject_link(activity)} uploaded a new version of #{objekt_link(activity)}"
+ when "BlobVersion edit": "#{subject_link(activity)} edited version #{activity.extra} of #{objekt_link(activity)}"
+ when "Bookmark create": "#{subject_link(activity)} favourited #{objekt_link(activity)}"
+ when "Comment create": "#{subject_link(activity)} commented on #{objekt_link(activity)}"
+ when "Pack create": "#{subject_link(activity)} created #{objekt_link(activity)}"
+ when "Workflow create": "#{subject_link(activity)} uploaded #{objekt_link(activity)}"
+ when "Workflow edit": "#{subject_link(activity)} edited #{objekt_link(activity)}"
+ when "WorkflowVersion create": "#{subject_link(activity)} uploaded a new version of #{objekt_link(activity)}"
+ when "WorkflowVersion edit": "#{subject_link(activity)} edited version #{activity.extra} of #{objekt_link(activity)}"
+ when "register": "#{subject_link(activity)} joined #{Conf.sitename}"
+ else "Unknown activity"
end
"<li>#{sentence}.</li>"
Copied: branches/events/app/models/activity.rb (from rev 3112, branches/events/app/models/event.rb) (0 => 3113)
--- branches/events/app/models/activity.rb (rev 0)
+++ branches/events/app/models/activity.rb 2012-08-25 13:41:30 UTC (rev 3113)
@@ -0,0 +1,37 @@
+# myExperiment: app/models/activity.rb
+#
+# Copyright (c) 2012 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+class Activity < ActiveRecord::Base
+
+ belongs_to :subject, :polymorphic => true
+ belongs_to :objekt, :polymorphic => true
+ belongs_to :auth, :polymorphic => true
+
+ validates_presence_of :subject
+ validates_presence_of :action
+ validates_presence_of :subject_label
+
+ before_validation do |e|
+
+ if e.subject && e.subject_label.nil?
+ e.subject_label = e.subject.label if e.subject.respond_to?(:label)
+ e.subject_label = e.subject.title if e.subject.respond_to?(:title)
+ e.subject_label = e.subject.name if e.subject.respond_to?(:name)
+ end
+
+ if e.objekt && e.objekt_label.nil?
+ e.objekt_label = e.objekt.label if e.objekt.respond_to?(:label)
+ e.objekt_label = e.objekt.title if e.objekt.respond_to?(:title)
+ e.objekt_label = e.objekt.name if e.objekt.respond_to?(:name)
+ end
+
+ if e.objekt && (e.objekt_label.nil? || e.objekt_label == "") && e.auth
+ e.objekt_label = e.auth.label if e.auth.respond_to?(:label)
+ e.objekt_label = e.auth.title if e.auth.respond_to?(:title)
+ e.objekt_label = e.auth.name if e.auth.respond_to?(:name)
+ end
+ end
+end
+
Deleted: branches/events/app/models/event.rb (3112 => 3113)
--- branches/events/app/models/event.rb 2012-08-25 05:57:12 UTC (rev 3112)
+++ branches/events/app/models/event.rb 2012-08-25 13:41:30 UTC (rev 3113)
@@ -1,37 +0,0 @@
-# myExperiment: app/models/event.rb
-#
-# Copyright (c) 2012 University of Manchester and the University of Southampton.
-# See license.txt for details.
-
-class Event < ActiveRecord::Base
-
- belongs_to :subject, :polymorphic => true
- belongs_to :objekt, :polymorphic => true
- belongs_to :auth, :polymorphic => true
-
- validates_presence_of :subject
- validates_presence_of :action
- validates_presence_of :subject_label
-
- before_validation do |e|
-
- if e.subject && e.subject_label.nil?
- e.subject_label = e.subject.label if e.subject.respond_to?(:label)
- e.subject_label = e.subject.title if e.subject.respond_to?(:title)
- e.subject_label = e.subject.name if e.subject.respond_to?(:name)
- end
-
- if e.objekt && e.objekt_label.nil?
- e.objekt_label = e.objekt.label if e.objekt.respond_to?(:label)
- e.objekt_label = e.objekt.title if e.objekt.respond_to?(:title)
- e.objekt_label = e.objekt.name if e.objekt.respond_to?(:name)
- end
-
- if e.objekt && (e.objekt_label.nil? || e.objekt_label == "") && e.auth
- e.objekt_label = e.auth.label if e.auth.respond_to?(:label)
- e.objekt_label = e.auth.title if e.auth.respond_to?(:title)
- e.objekt_label = e.auth.name if e.auth.respond_to?(:name)
- end
- end
-end
-
Modified: branches/events/app/models/user.rb (3112 => 3113)
--- branches/events/app/models/user.rb 2012-08-25 05:57:12 UTC (rev 3112)
+++ branches/events/app/models/user.rb 2012-08-25 13:41:30 UTC (rev 3113)
@@ -17,7 +17,7 @@
has_many :jobs
- has_many :events, :as => :subject, :dependent => :destroy
+ has_many :activities, :as => :subject, :dependent => :destroy
has_many :taverna_enactors, :as => :contributor,
:conditions => ["contributor_type = ?", "User"]
Copied: branches/events/db/migrate/097_add_activities.rb (from rev 3112, branches/events/db/migrate/097_add_events.rb) (0 => 3113)
--- branches/events/db/migrate/097_add_activities.rb (rev 0)
+++ branches/events/db/migrate/097_add_activities.rb 2012-08-25 13:41:30 UTC (rev 3113)
@@ -0,0 +1,32 @@
+# myExperiment: db/migrate/097_add_activities.rb
+#
+# Copyright (c) 2012 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+class AddActivities < ActiveRecord::Migration
+ def self.up
+ create_table :activities do |t|
+
+ t.string :subject_type
+ t.integer :subject_id
+ t.string :subject_label
+
+ t.string :action
+
+ t.string :objekt_type
+ t.integer :objekt_id
+ t.string :objekt_label
+
+ t.string :auth_type
+ t.integer :auth_id
+
+ t.string :extra
+
+ t.datetime :created_at
+ end
+ end
+
+ def self.down
+ drop_table :activities
+ end
+end
Deleted: branches/events/db/migrate/097_add_events.rb (3112 => 3113)
--- branches/events/db/migrate/097_add_events.rb 2012-08-25 05:57:12 UTC (rev 3112)
+++ branches/events/db/migrate/097_add_events.rb 2012-08-25 13:41:30 UTC (rev 3113)
@@ -1,32 +0,0 @@
-# myExperiment: db/migrate/097_add_events.rb
-#
-# Copyright (c) 2012 University of Manchester and the University of Southampton.
-# See license.txt for details.
-
-class AddEvents < ActiveRecord::Migration
- def self.up
- create_table :events do |t|
-
- t.string :subject_type
- t.integer :subject_id
- t.string :subject_label
-
- t.string :action
-
- t.string :objekt_type
- t.integer :objekt_id
- t.string :objekt_label
-
- t.string :auth_type
- t.integer :auth_id
-
- t.string :extra
-
- t.datetime :created_at
- end
- end
-
- def self.down
- drop_table :events
- end
-end
Modified: branches/events/db/schema.rb (3112 => 3113)
--- branches/events/db/schema.rb 2012-08-25 05:57:12 UTC (rev 3112)
+++ branches/events/db/schema.rb 2012-08-25 13:41:30 UTC (rev 3113)
@@ -11,6 +11,20 @@
ActiveRecord::Schema.define(:version => 97) do
+ create_table "activities", :force => true do |t|
+ t.string "subject_type"
+ t.integer "subject_id"
+ t.string "subject_label"
+ t.string "action"
+ t.string "objekt_type"
+ t.integer "objekt_id"
+ t.string "objekt_label"
+ t.string "auth_type"
+ t.integer "auth_id"
+ t.string "extra"
+ t.datetime "created_at"
+ end
+
create_table "activity_limits", :force => true do |t|
t.string "contributor_type", :null => false
t.integer "contributor_id", :null => false
@@ -227,20 +241,6 @@
add_index "downloads", ["contribution_id"], :name => "index_downloads_on_contribution_id"
- create_table "events", :force => true do |t|
- t.string "subject_type"
- t.integer "subject_id"
- t.string "subject_label"
- t.string "action"
- t.string "objekt_type"
- t.integer "objekt_id"
- t.string "objekt_label"
- t.string "auth_type"
- t.integer "auth_id"
- t.string "extra"
- t.datetime "created_at"
- end
-
create_table "experiments", :force => true do |t|
t.string "title"
t.text "description"
Modified: branches/events/lib/rest.rb (3112 => 3113)
--- branches/events/lib/rest.rb 2012-08-25 05:57:12 UTC (rev 3112)
+++ branches/events/lib/rest.rb 2012-08-25 13:41:30 UTC (rev 3113)
@@ -1123,10 +1123,10 @@
if success
case "#{action} #{new_version || edit_version}"
- when "create false": Event.create(:subject => opts[:user], :action ="" 'create', :objekt => ob)
- when "create true": Event.create(:subject => opts[:user], :action ="" 'create version', :objekt => ob)
- when "edit false": Event.create(:subject => opts[:user], :action ="" 'edit', :objekt => ob)
- when "edit true": Event.create(:subject => opts[:user], :action ="" 'edit version', :objekt => ob, :extra => ob.version)
+ when "create false": Activity.create(:subject => opts[:user], :action ="" 'create', :objekt => ob)
+ when "create true": Activity.create(:subject => opts[:user], :action ="" 'create version', :objekt => ob)
+ when "edit false": Activity.create(:subject => opts[:user], :action ="" 'edit', :objekt => ob)
+ when "edit true": Activity.create(:subject => opts[:user], :action ="" 'edit version', :objekt => ob, :extra => ob.version)
end
end
@@ -1263,10 +1263,10 @@
if success
case "#{action} #{new_version || edit_version}"
- when "create false": Event.create(:subject => opts[:user], :action ="" 'create', :objekt => ob)
- when "create true": Event.create(:subject => opts[:user], :action ="" 'create version', :objekt => ob)
- when "edit false": Event.create(:subject => opts[:user], :action ="" 'edit', :objekt => ob)
- when "edit true": Event.create(:subject => opts[:user], :action ="" 'edit version', :objekt => ob, :extra => ob.version)
+ when "create false": Activity.create(:subject => opts[:user], :action ="" 'create', :objekt => ob)
+ when "create true": Activity.create(:subject => opts[:user], :action ="" 'create version', :objekt => ob)
+ when "edit false": Activity.create(:subject => opts[:user], :action ="" 'edit', :objekt => ob)
+ when "edit true": Activity.create(:subject => opts[:user], :action ="" 'edit version', :objekt => ob, :extra => ob.version)
end
end
@@ -1934,8 +1934,8 @@
if success
case action
- when "create": Event.create(:subject => opts[:user], :action ="" 'create', :objekt => ob)
- when "edit": Event.create(:subject => opts[:user], :action ="" 'edit', :objekt => ob)
+ when "create": Activity.create(:subject => opts[:user], :action ="" 'create', :objekt => ob)
+ when "edit": Activity.create(:subject => opts[:user], :action ="" 'edit', :objekt => ob)
end
end
@@ -1998,7 +1998,7 @@
success = ob.save
if success
- Event.create(:subject => current_user, :action ="" 'create', :objekt => ob)
+ Activity.create(:subject => current_user, :action ="" 'create', :objekt => ob)
end
return rest_response(400, :object => ob) unless success
Modified: branches/events/test/functional/api_controller_test.rb (3112 => 3113)
--- branches/events/test/functional/api_controller_test.rb 2012-08-25 05:57:12 UTC (rev 3112)
+++ branches/events/test/functional/api_controller_test.rb 2012-08-25 13:41:30 UTC (rev 3113)
@@ -19,7 +19,7 @@
def test_workflows
existing_workflows = Workflow.find(:all)
- existing_events = Event.all
+ existing_activities = Activity.all
login_as(:john)
@@ -45,16 +45,16 @@
assert_response(:success)
extra_workflows = Workflow.find(:all) - existing_workflows
- extra_events = Event.find(:all). - existing_events
+ extra_activities = Activity.find(:all). - existing_activities
assert_equal(1, extra_workflows.length)
- assert_equal(1, extra_events.length)
+ assert_equal(1, extra_activities.length)
- new_event = (extra_events - existing_events).first
+ new_activity = (extra_activities - existing_activities).first
- assert_equal("John Smith", new_event.subject_label);
- assert_equal("create", new_event.action);
- assert_equal(title, new_event.objekt_label);
+ assert_equal("John Smith", new_activity.subject_label);
+ assert_equal("create", new_activity.action);
+ assert_equal(title, new_activity.objekt_label);
@workflow_id = extra_workflows.first.id
@@ -86,7 +86,7 @@
setup
login_as(:john)
- existing_events = Event.all
+ existing_activities = Activity.all
rest_request(:put, 'workflow', "<?xml version='1.0'?>
<workflow>
@@ -95,14 +95,14 @@
assert_response(:success)
- extra_events = Event.find(:all). - existing_events
- assert_equal(1, extra_events.length)
+ extra_activities = Activity.find(:all). - existing_activities
+ assert_equal(1, extra_activities.length)
- new_event = (extra_events - existing_events).first
+ new_activity = (extra_activities - existing_activities).first
- assert_equal("John Smith", new_event.subject_label);
- assert_equal("edit", new_event.action);
- assert_equal(title2, new_event.objekt_label);
+ assert_equal("John Smith", new_activity.subject_label);
+ assert_equal("edit", new_activity.action);
+ assert_equal(title2, new_activity.objekt_label);
# get the updated workflow
@@ -120,7 +120,7 @@
# post a new version of the workflow
- existing_events = Event.all
+ existing_activities = Activity.all
rest_request(:post, 'workflow', "<?xml version='1.0'?>
<workflow>
@@ -130,14 +130,14 @@
assert_response(:success)
- extra_events = Event.find(:all). - existing_events
- assert_equal(1, extra_events.length)
+ extra_activities = Activity.find(:all). - existing_activities
+ assert_equal(1, extra_activities.length)
- new_event = (extra_events - existing_events).first
+ new_activity = (extra_activities - existing_activities).first
- assert_equal("John Smith", new_event.subject_label);
- assert_equal("create", new_event.action);
- assert_equal("Fetch today's xkcd comic", new_event.objekt_label);
+ assert_equal("John Smith", new_activity.subject_label);
+ assert_equal("create", new_activity.action);
+ assert_equal("Fetch today's xkcd comic", new_activity.objekt_label);
workflow = Workflow.find(@workflow_id)
@@ -165,7 +165,7 @@
# edit a particular version of a workflow
- existing_events = Event.all
+ existing_activities = Activity.all
rest_request(:put, 'workflow', "<?xml version='1.0'?>
<workflow>
@@ -174,15 +174,15 @@
assert_response(:success)
- extra_events = Event.find(:all). - existing_events
- assert_equal(1, extra_events.length)
+ extra_activities = Activity.find(:all). - existing_activities
+ assert_equal(1, extra_activities.length)
- new_event = (extra_events - existing_events).first
+ new_activity = (extra_activities - existing_activities).first
- assert_equal("John Smith", new_event.subject_label);
- assert_equal("edit", new_event.action);
- assert_equal("1", new_event.extra);
- assert_equal("Oranges", new_event.objekt_label);
+ assert_equal("John Smith", new_activity.subject_label);
+ assert_equal("edit", new_activity.action);
+ assert_equal("1", new_activity.extra);
+ assert_equal("Oranges", new_activity.objekt_label);
# Verify that only version 1 was changed
@@ -229,7 +229,7 @@
# post a file
- existing_events = Event.all
+ existing_activities = Activity.all
rest_request(:post, 'file', "<?xml version='1.0'?>
<file>
@@ -242,13 +242,13 @@
assert_response(:success)
- new_events = Event.all - existing_events
+ new_activities = Activity.all - existing_activities
- assert_equal(1, new_events.length)
+ assert_equal(1, new_activities.length)
- assert_equal("John Smith", new_events.first.subject.name)
- assert_equal("create", new_events.first.action)
- assert_equal(title, new_events.first.objekt.title)
+ assert_equal("John Smith", new_activities.first.subject.name)
+ assert_equal("create", new_activities.first.action)
+ assert_equal(title, new_activities.first.objekt.title)
extra_files = Blob.find(:all) - existing_files
@@ -287,7 +287,7 @@
setup
login_as(:john)
- existing_events = Event.all
+ existing_activities = Activity.all
rest_request(:put, 'file', "<?xml version='1.0'?>
<file>
@@ -296,12 +296,12 @@
assert_response(:success)
- new_events = Event.all - existing_events
+ new_activities = Activity.all - existing_activities
- assert_equal(1, new_events.length)
- assert_equal("John Smith", new_events.first.subject.name)
- assert_equal("edit", new_events.first.action)
- assert_equal(title2, new_events.first.objekt.title)
+ assert_equal(1, new_activities.length)
+ assert_equal("John Smith", new_activities.first.subject.name)
+ assert_equal("edit", new_activities.first.action)
+ assert_equal(title2, new_activities.first.objekt.title)
# get the updated file
@@ -315,7 +315,7 @@
# add a new version of the file
- existing_events = Event.all
+ existing_activities = Activity.all
rest_request(:post, 'file', "<?xml version='1.0'?>
<file>
@@ -328,12 +328,12 @@
assert_response(:success)
- new_events = Event.all - existing_events
+ new_activities = Activity.all - existing_activities
- assert_equal(1, new_events.length)
- assert_equal("John Smith", new_events.first.subject.name)
- assert_equal("create", new_events.first.action)
- assert_equal(title2, new_events.first.objekt.title)
+ assert_equal(1, new_activities.length)
+ assert_equal("John Smith", new_activities.first.subject.name)
+ assert_equal("create", new_activities.first.action)
+ assert_equal(title2, new_activities.first.objekt.title)
file.reload
@@ -341,7 +341,7 @@
# update the first version of the file
- existing_events = Event.all
+ existing_activities = Activity.all
rest_request(:put, 'file', "<?xml version='1.0'?>
<file>
@@ -350,12 +350,12 @@
assert_response(:success)
- new_events = Event.all - existing_events
+ new_activities = Activity.all - existing_activities
- assert_equal(1, new_events.length)
- assert_equal("John Smith", new_events.first.subject.name)
- assert_equal("edit", new_events.first.action)
- assert_equal(title3, new_events.first.objekt.title)
+ assert_equal(1, new_activities.length)
+ assert_equal("John Smith", new_activities.first.subject.name)
+ assert_equal("edit", new_activities.first.action)
+ assert_equal(title3, new_activities.first.objekt.title)
file.reload
assert_equal(title3, file.find_version(1).title);
@@ -645,7 +645,7 @@
existing_comments = Comment.find(:all)
- existing_events = Event.all
+ existing_activities = Activity.all
rest_request(:post, 'comment', "<?xml version='1.0'?>
<comment>
@@ -655,12 +655,12 @@
assert_response(:success)
- new_events = Event.all - existing_events
+ new_activities = Activity.all - existing_activities
- assert_equal(1, new_events.length)
- assert_equal("John Smith", new_events.first.subject.name)
- assert_equal("create", new_events.first.action)
- assert_equal("Unique tags", new_events.first.objekt.commentable.title)
+ assert_equal(1, new_activities.length)
+ assert_equal("John Smith", new_activities.first.subject.name)
+ assert_equal("create", new_activities.first.action)
+ assert_equal("Unique tags", new_activities.first.objekt.commentable.title)
extra_comments = Comment.find(:all) - existing_comments
@@ -798,7 +798,7 @@
existing_favourites = Bookmark.find(:all)
- existing_events = Event.all
+ existing_activities = Activity.all
rest_request(:post, 'favourite', "<?xml version='1.0'?>
<favourite>
@@ -807,12 +807,12 @@
assert_response(:success)
- new_events = Event.all - existing_events
+ new_activities = Activity.all - existing_activities
- assert_equal(1, new_events.length)
- assert_equal("John Smith", new_events.first.subject.name)
- assert_equal("create", new_events.first.action)
- assert_equal("Unique tags", new_events.first.objekt.bookmarkable.title)
+ assert_equal(1, new_activities.length)
+ assert_equal("John Smith", new_activities.first.subject.name)
+ assert_equal("create", new_activities.first.action)
+ assert_equal("Unique tags", new_activities.first.objekt.bookmarkable.title)
extra_favourites = Bookmark.find(:all) - existing_favourites