Author: assaf
Date: Thu Jun  5 16:26:50 2008
New Revision: 663779

URL: http://svn.apache.org/viewvc?rev=663779&view=rev
Log:
What was once /activities is now /activity, and task activity shows under 
/tasks.
PerformController replaced with TaskForController and task_for_person provides 
authenticated URL.

Added:
    ode/sandbox/singleshot/app/controllers/activity_controller.rb
      - copied, changed from r663778, 
ode/sandbox/singleshot/app/controllers/activities_controller.rb
    ode/sandbox/singleshot/app/controllers/task_for_controller.rb
    ode/sandbox/singleshot/app/views/activity/
    ode/sandbox/singleshot/app/views/activity/_activities.html.erb
      - copied, changed from r663778, 
ode/sandbox/singleshot/app/views/activities/_activities.html.erb
    ode/sandbox/singleshot/app/views/activity/index.atom.builder
      - copied, changed from r663778, 
ode/sandbox/singleshot/app/views/activities/index.atom.builder
    ode/sandbox/singleshot/app/views/activity/index.html.erb
      - copied, changed from r663778, 
ode/sandbox/singleshot/app/views/activities/index.html.erb
    ode/sandbox/singleshot/app/views/activity/index.ics.ical
      - copied, changed from r663778, 
ode/sandbox/singleshot/app/views/activities/index.ics.ical
Removed:
    ode/sandbox/singleshot/app/controllers/activities_controller.rb
    ode/sandbox/singleshot/app/controllers/performs_controller.rb
    ode/sandbox/singleshot/app/views/activities/_activities.html.erb
    ode/sandbox/singleshot/app/views/activities/index.atom.builder
    ode/sandbox/singleshot/app/views/activities/index.html.erb
    ode/sandbox/singleshot/app/views/activities/index.ics.ical
Modified:
    ode/sandbox/singleshot/app/controllers/tasks_controller.rb
    ode/sandbox/singleshot/app/helpers/activity_helper.rb
    ode/sandbox/singleshot/app/helpers/task_helper.rb
    ode/sandbox/singleshot/app/models/person.rb
    ode/sandbox/singleshot/app/views/layouts/application.html.erb
    ode/sandbox/singleshot/app/views/tasks/show.html.erb
    ode/sandbox/singleshot/config/routes.rb

Copied: ode/sandbox/singleshot/app/controllers/activity_controller.rb (from 
r663778, ode/sandbox/singleshot/app/controllers/activities_controller.rb)
URL: 
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/controllers/activity_controller.rb?p2=ode/sandbox/singleshot/app/controllers/activity_controller.rb&p1=ode/sandbox/singleshot/app/controllers/activities_controller.rb&r1=663778&r2=663779&rev=663779&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/controllers/activities_controller.rb (original)
+++ ode/sandbox/singleshot/app/controllers/activity_controller.rb Thu Jun  5 
16:26:50 2008
@@ -1,12 +1,12 @@
-class ActivitiesController < ApplicationController
+class ActivityController < ApplicationController
 
-  access_key_authentication :only=>[:index, :show]
+  access_key_authentication
 
   def index
     @title = 'Activities'
     @subtitle = 'Track activity in tasks you participate in or observe.'
-    @alternate = { Mime::ATOM=>formatted_activities_url(:format=>:atom, 
:access_key=>authenticated.access_key),
-                   Mime::ICS=>formatted_activities_url(:format=>:ics, 
:access_key=>authenticated.access_key) }
+    @alternate = { Mime::ATOM=>formatted_activity_url(:format=>:atom, 
:access_key=>authenticated.access_key),
+                   Mime::ICS=>formatted_activity_url(:format=>:ics, 
:access_key=>authenticated.access_key) }
     @activities = Activity.for_stakeholder(authenticated)
     day = Date.new(params[:year].to_i, params[:month].to_i, params[:day].to_i) 
rescue nil if params[:year]
     dates = day ? day..day + 1.day : Date.today - 3.day..Date.today + 1.day
@@ -18,13 +18,13 @@
     end
   end
 
-  def show
-    @task = Task.for_stakeholder(authenticated).find(params[:id], 
:include=>:activities)
+  def for_task
+    @task = Task.for_stakeholder(authenticated).find(params[:task_id], 
:include=>:activities)
     @activities = @task.activities
     @title = "Activities - [EMAIL PROTECTED]"
     @subtitle = "Track all activities in the task [EMAIL PROTECTED]"
-    @alternate = { Mime::ATOM=>formatted_activity_url(@task, :atom, 
:access_key=>authenticated.access_key),
-                   Mime::ICS=>formatted_activity_url(@task, :ics, 
:access_key=>authenticated.access_key) }
+    @alternate = { Mime::ATOM=>formatted_task_activity_url(@task, 
:format=>:atom, :access_key=>authenticated.access_key),
+                   Mime::ICS=>formatted_task_activity_url(@task, 
:format=>:ics, :access_key=>authenticated.access_key) }
     respond_to do |want|
       want.html { render :action=>'index' }
       want.atom { render :action=>'index' }

Added: ode/sandbox/singleshot/app/controllers/task_for_controller.rb
URL: 
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/controllers/task_for_controller.rb?rev=663779&view=auto
==============================================================================
--- ode/sandbox/singleshot/app/controllers/task_for_controller.rb (added)
+++ ode/sandbox/singleshot/app/controllers/task_for_controller.rb Thu Jun  5 
16:26:50 2008
@@ -0,0 +1,31 @@
+class TaskForController < ApplicationController
+
+  before_filter :authenticate
+  verify :params=>'task', :only=>:update
+
+  def show
+    respond_to do |wants|
+      wants.xml { render :xml=>@task }
+      wants.json { render :json=>@task }
+    end
+  end
+
+  def update
+    @task.modify_by(@person).update_attributes! params[:task]
+    respond_to do |wants|
+      wants.xml { render :xml=>@task }
+      wants.json { render :json=>@task }
+    end
+  end
+
+private
+
+  def authenticate
+    @task = Task.with_stakeholders.find(params[:task_id])
+    @person = Person.identify(params[:person_id])
+    authenticate_or_request_with_http_basic request.domain do |login, token|
+      login == '_token' && token == @task.token_for(@person)
+    end
+  end
+
+end

Modified: ode/sandbox/singleshot/app/controllers/tasks_controller.rb
URL: 
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/controllers/tasks_controller.rb?rev=663779&r1=663778&r2=663779&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/controllers/tasks_controller.rb (original)
+++ ode/sandbox/singleshot/app/controllers/tasks_controller.rb Thu Jun  5 
16:26:50 2008
@@ -50,8 +50,8 @@
 
   def show
     @title = @task.title
-    @alternate = { Mime::ICS=>formatted_task_url(@task, :ics, 
:access_key=>authenticated.access_key),
-                   Mime::ATOM=>formatted_activity_url(@task, :atom, 
:access_key=>authenticated.access_key) }
+    @alternate = { Mime::ICS=>formatted_task_url(@task, :format=>:ics, 
:access_key=>authenticated.access_key),
+                   Mime::ATOM=>formatted_task_activity_url(@task, 
:format=>:atom, :access_key=>authenticated.access_key) }
     respond_to do |wants|
       wants.html { render :layout=>'head' }
       # TODO: wants.xml

Modified: ode/sandbox/singleshot/app/helpers/activity_helper.rb
URL: 
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/helpers/activity_helper.rb?rev=663779&r1=663778&r2=663779&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/helpers/activity_helper.rb (original)
+++ ode/sandbox/singleshot/app/helpers/activity_helper.rb Thu Jun  5 16:26:50 
2008
@@ -7,7 +7,7 @@
 
   def activity_to_html(activity, options = {})
     title = link_to(h(activity.task.title), task_url(activity.task), 
options[:task])
-    activity.person ? "#{link_to_person activity.person, options[:person]} 
#{activity.action} #{title}" :
+    activity.person ? "#{link_to_person activity.person, 
:rel=>options[:person]} #{activity.action} #{title}" :
       "#{activity.action.capitalize} #{title}"
   end
 

Modified: ode/sandbox/singleshot/app/helpers/task_helper.rb
URL: 
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/helpers/task_helper.rb?rev=663779&r1=663778&r2=663779&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/helpers/task_helper.rb (original)
+++ ode/sandbox/singleshot/app/helpers/task_helper.rb Thu Jun  5 16:26:50 2008
@@ -45,4 +45,10 @@
     actions.join
   end
 
+  def task_for_person_url(task, person)
+    uri = URI(super(task, person))
+    uri.user, uri.password = '_token', task.token_for(person)
+    uri.to_s
+  end
+
 end

Modified: ode/sandbox/singleshot/app/models/person.rb
URL: 
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/models/person.rb?rev=663779&r1=663778&r2=663779&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/models/person.rb (original)
+++ ode/sandbox/singleshot/app/models/person.rb Thu Jun  5 16:26:50 2008
@@ -40,9 +40,9 @@
     # it will return an array of people.  Matches against the identity 
returned in to_param.
     def identify(identity)
       case identity
-      when Array then identity.flatten.map { |id| identify(id) }.uniq 
+      when Array then Person.find(:all, 
:conditions=>{:identity=>identity.flatten.uniq})
       when Person then identity
-      else Person.find_by_identity(identity)
+      else Person.find_by_identity(identity) or raise 
ActiveRecord::RecordNotFound
       end
     end
 

Copied: ode/sandbox/singleshot/app/views/activity/_activities.html.erb (from 
r663778, ode/sandbox/singleshot/app/views/activities/_activities.html.erb)
URL: 
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/views/activity/_activities.html.erb?p2=ode/sandbox/singleshot/app/views/activity/_activities.html.erb&p1=ode/sandbox/singleshot/app/views/activities/_activities.html.erb&r1=663778&r2=663779&rev=663779&view=diff
==============================================================================
    (empty)

Copied: ode/sandbox/singleshot/app/views/activity/index.atom.builder (from 
r663778, ode/sandbox/singleshot/app/views/activities/index.atom.builder)
URL: 
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/views/activity/index.atom.builder?p2=ode/sandbox/singleshot/app/views/activity/index.atom.builder&p1=ode/sandbox/singleshot/app/views/activities/index.atom.builder&r1=663778&r2=663779&rev=663779&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/views/activities/index.atom.builder (original)
+++ ode/sandbox/singleshot/app/views/activity/index.atom.builder Thu Jun  5 
16:26:50 2008
@@ -1,4 +1,4 @@
-atom_feed :root_url=>activities_url do |feed|
+atom_feed :root_url=>activity_url do |feed|
   feed.title @title
   feed.subtitle @subtitle
   feed.updated @activities.first.created_at unless @activities.empty?

Copied: ode/sandbox/singleshot/app/views/activity/index.html.erb (from r663778, 
ode/sandbox/singleshot/app/views/activities/index.html.erb)
URL: 
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/views/activity/index.html.erb?p2=ode/sandbox/singleshot/app/views/activity/index.html.erb&p1=ode/sandbox/singleshot/app/views/activities/index.html.erb&r1=663778&r2=663779&rev=663779&view=diff
==============================================================================
    (empty)

Copied: ode/sandbox/singleshot/app/views/activity/index.ics.ical (from r663778, 
ode/sandbox/singleshot/app/views/activities/index.ics.ical)
URL: 
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/views/activity/index.ics.ical?p2=ode/sandbox/singleshot/app/views/activity/index.ics.ical&p1=ode/sandbox/singleshot/app/views/activities/index.ics.ical&r1=663778&r2=663779&rev=663779&view=diff
==============================================================================
    (empty)

Modified: ode/sandbox/singleshot/app/views/layouts/application.html.erb
URL: 
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/views/layouts/application.html.erb?rev=663779&r1=663778&r2=663779&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/views/layouts/application.html.erb (original)
+++ ode/sandbox/singleshot/app/views/layouts/application.html.erb Thu Jun  5 
16:26:50 2008
@@ -16,7 +16,7 @@
         [ ['➠ Tasks', tasks_url, 'Pending and available tasks'],
           ['Following', following_tasks_url, 'Tasks you create, observing or 
administrating'],
           ['Completed', completed_tasks_url, 'Tasks you completed'],
-          ['Activity', activities_url, 'Recent task activity'] ].map { |tab|
+          ['Activity', activity_url, 'Recent task activity'] ].map { |tab|
             content_tag 'li', link_to(tab[0], tab[1], :title=>tab[2], 
:class=>current_page?(tab[1]) ? 'current': nil)
           }.join %></ul>
       <ul class='alternate'><%= content_tag 'li', 
link_to(image_tag('feed.png') + ' Feed', @alternate[Mime::ATOM], 
:rel=>'alternate', :title=>'Subscribe with your feed reader') if @alternate && 
@alternate[Mime::ATOM] %><%= content_tag 'li', 
link_to(image_tag('calendar.png') + ' Calendar', @alternate[Mime::ICS], 
:rel=>'alternate', :title=>'Add to your calendar') if @alternate && 
@alternate[Mime::ICS] %></ul>

Modified: ode/sandbox/singleshot/app/views/tasks/show.html.erb
URL: 
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/views/tasks/show.html.erb?rev=663779&r1=663778&r2=663779&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/views/tasks/show.html.erb (original)
+++ ode/sandbox/singleshot/app/views/tasks/show.html.erb Thu Jun  5 16:26:50 
2008
@@ -1,10 +1,6 @@
 <%
   performing = @task.can_complete?(authenticated)
-  iframe_url = @task.rendering.render_url(performing) {
-    uri = URI(task_perform_url(@task))
-    uri.user, uri.password = '_token', @task.token_for(authenticated)
-    { 'task_url'=>uri.to_s }
-  }
+  iframe_url = @task.rendering.render_url(performing, 
'task_url'=>task_for_person_url(@task, authenticated))
 %>
 <% div_for @task do %>
   <div class='header'>
@@ -26,7 +22,7 @@
         <dt>Recent activity</dt>
         <dd>
           <ul class='alternate'><%= content_tag 'li', 
link_to(image_tag('feed.png') + ' Feed', @alternate[Mime::ATOM], 
:rel=>'alternate', :title=>'Subscribe to see changes to this task') %><%= 
content_tag 'li', link_to(image_tag('calendar.png') + ' Calendar', 
@alternate[Mime::ICS], :rel=>'alternate', :title=>'Add this task to your 
calendar') %></ul>
-          <%= render :file=>'activities/_activities', :locals=>{ 
:today=>Date.today, :activities=>@task.activities } %>
+          <%= render :file=>'activity/_activities', :locals=>{ 
:today=>Date.today, :activities=>@task.activities } %>
         </dd>
       </dl>
       <div class='actions'><%= task_actions(@task) %></div>

Modified: ode/sandbox/singleshot/config/routes.rb
URL: 
http://svn.apache.org/viewvc/ode/sandbox/singleshot/config/routes.rb?rev=663779&r1=663778&r2=663779&view=diff
==============================================================================
--- ode/sandbox/singleshot/config/routes.rb (original)
+++ ode/sandbox/singleshot/config/routes.rb Thu Jun  5 16:26:50 2008
@@ -2,10 +2,19 @@
 
   map.resource 'session'
   map.resources 'tasks', :collection=>{ 'completed'=>:get, 'following'=>:get, 
'complete_redirect'=>:get } do |tasks|
-    tasks.resource :perform
+    tasks.with_options :controller=>'task_for' do |opts|
+      opts.connect 'for/:person_id', :action=>'update', :conditions=>{ 
:method=>:put }
+      opts.for_person 'for/:person_id', :action=>'show'
+    end
+    tasks.with_options :controller=>'activity', :action=>'for_task' do |opts|
+      opts.activity 'activity'
+      opts.activity 'activity.:format', :name_prefix=>'formatted_task_'
+    end
+  end
+  map.with_options :controller=>'activity', :action=>'index' do |opts|
+    opts.activity '/activity'
+    opts.formatted_activity '/activity.:format'
   end
-  map.resources 'activities'
-  map.day_activity 'activity/:year/:month/:day', :controller=>'activities', 
:action=>'show', :year =>/\d{4}/, :month=>/\d{1,2}/, :day=>/\d{1,2}/
   map.root :controller=>'application'
   map.resource 'sandwich'
 


Reply via email to