myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [3797] branches/packs: reactivated subscriptions


From: noreply
Subject: [myexperiment-hackers] [3797] branches/packs: reactivated subscriptions for groups and added subscriptions to workflows, files and packs
Date: Tue, 19 Nov 2013 14:23:51 +0000 (UTC)

Revision
3797
Author
dgc
Date
2013-11-19 14:23:50 +0000 (Tue, 19 Nov 2013)

Log Message

reactivated subscriptions for groups and added subscriptions to workflows, files and packs

Modified Paths

Added Paths

Diff

Modified: branches/packs/app/controllers/networks_controller.rb (3796 => 3797)


--- branches/packs/app/controllers/networks_controller.rb	2013-11-19 14:13:18 UTC (rev 3796)
+++ branches/packs/app/controllers/networks_controller.rb	2013-11-19 14:23:50 UTC (rev 3797)
@@ -15,7 +15,7 @@
   before_filter :find_networks, : [:all]
   before_filter :find_network, : [:membership_request, :show, :tag, :content,
                                          :edit, :update, :destroy, :invite, :membership_invite,
-                                         :membership_invite_external, :sync_feed, :subscription]
+                                         :membership_invite_external, :sync_feed]
   before_filter :find_network_auth_admin, : [:invite, :membership_invite, :membership_invite_external, :sync_feed]
   before_filter :find_network_auth_owner, : [:edit, :update, :destroy]
   
@@ -417,25 +417,6 @@
     redirect_to network_path(@network)
   end
   
-  # PUT/DELETE /groups/1/subscription
-  def subscription
-
-    object = @network
-
-    existing_subscription = current_user.subscriptions.find(:first,
-        :conditions => { :objekt_type => object.class.name, :objekt_id => object.id } )
-
-    case request.method
-    when :put
-      current_user.subscriptions.create(:objekt => object) unless existing_subscription
-
-    when :delete
-      current_user.subscriptions.delete(existing_subscription) if existing_subscription
-    end
-
-    redirect_to object
-  end
-
 protected
 
   def find_networks

Added: branches/packs/app/controllers/subscriptions_controller.rb (0 => 3797)


--- branches/packs/app/controllers/subscriptions_controller.rb	                        (rev 0)
+++ branches/packs/app/controllers/subscriptions_controller.rb	2013-11-19 14:23:50 UTC (rev 3797)
@@ -0,0 +1,38 @@
+# myExperiment: app/controllers/subscriptions_controller.rb
+#
+# Copyright (c) 2007-2013 The University of Manchester, the University of
+# Oxford, and the University of Southampton.  See license.txt for details.
+
+class SubscriptionsController < ApplicationController
+
+  before_filter :find_and_auth_resource_context
+  before_filter :find_subscription
+
+  def update
+    current_user.subscriptions.create(:objekt => @context) unless @subscription
+    redirect_to @context
+  end
+
+  def destroy
+    current_user.subscriptions.delete(@subscription) if @subscription
+    redirect_to @context
+  end
+
+  private
+
+  def find_and_auth_resource_context
+    @context = extract_resource_context(params)
+
+    if @context.nil?
+      render_404("Subscription context not found.")
+    elsif !Authorization.check('view', @context, current_user)
+      render_401("You are not authorized to view the subscription status of this resource.")
+    end
+  end
+  
+  def find_subscription
+    @subscription = current_user.subscriptions.find(:first,
+        :conditions => { :objekt_type => @context.class.name, :objekt_id => @context.id } )
+  end
+
+end

Modified: branches/packs/app/views/blobs/show.rhtml (3796 => 3797)


--- branches/packs/app/views/blobs/show.rhtml	2013-11-19 14:13:18 UTC (rev 3796)
+++ branches/packs/app/views/blobs/show.rhtml	2013-11-19 14:23:50 UTC (rev 3797)
@@ -123,6 +123,8 @@
 
 <div class="contribution_right_box">
 	<%= render :partial => "contributions/uploader_box", :locals => { :contributable => @blob } %>
+
+  <%= render :partial => "contributions/subscription_box", :locals => { :object => @blob } -%>
 	
 	<%= render :partial => "contributions/license_box", :locals => { :contributable => @blob } %>
 	

Modified: branches/packs/app/views/contributions/_subscription_box.html.erb (3796 => 3797)


--- branches/packs/app/views/contributions/_subscription_box.html.erb	2013-11-19 14:13:18 UTC (rev 3796)
+++ branches/packs/app/views/contributions/_subscription_box.html.erb	2013-11-19 14:23:50 UTC (rev 3797)
@@ -5,12 +5,12 @@
       Subscription
       <% if current_user.subscriptions.find(:first, :conditions => { :objekt_type => object.class.name, :objekt_id => object.id } ) %>
         <p>You have subscribed to this resource.</p>
-        <% form_tag polymorphic_path([:subscription, @network]), :method => :delete do %>
+        <% form_tag polymorphic_path([object, :subscription]), :method => :delete do %>
           <%= submit_tag "Unsubscribe" -%>
         <% end %>
       <% else %>
         <p>Subscribe to this resource to get notifications on your home page.</p>
-        <% form_tag polymorphic_path([:subscription, @network]), :method => :put do %>
+        <% form_tag polymorphic_path([object, :subscription]), :method => :put do %>
           <%= submit_tag "Subscribe" -%>
         <% end %>
       <% end %>

Modified: branches/packs/app/views/networks/show.rhtml (3796 => 3797)


--- branches/packs/app/views/networks/show.rhtml	2013-11-19 14:13:18 UTC (rev 3796)
+++ branches/packs/app/views/networks/show.rhtml	2013-11-19 14:23:50 UTC (rev 3797)
@@ -119,9 +119,7 @@
 
     <div class="contribution_right_box">
       <%= render :partial => "owner_box", :locals => { :network => @network } %>
-      <% if false %>
       <%= render :partial => "contributions/subscription_box", :locals => { :object => @network } -%>
-      <% end %>
       <%= render :partial => "statistics_box", :locals => { :network => @network, :items => @shared_items } %>
 
       <div class="contribution_section_box"> <!-- style="width: 130px; padding: 0.4em 0.8em; font-size: 93%;" -->

Modified: branches/packs/app/views/packs/show.rhtml (3796 => 3797)


--- branches/packs/app/views/packs/show.rhtml	2013-11-19 14:13:18 UTC (rev 3796)
+++ branches/packs/app/views/packs/show.rhtml	2013-11-19 14:23:50 UTC (rev 3797)
@@ -173,6 +173,8 @@
 
 <div class="contribution_right_box">
 	<%= render :partial => "contributions/uploader_box", :locals => { :contributable => @pack } %>
+
+  <%= render :partial => "contributions/subscription_box", :locals => { :object => @pack } -%>
 	
 	<div class="contribution_section_box">
 		<p style="font-size: 108%;">

Modified: branches/packs/app/views/workflows/show.rhtml (3796 => 3797)


--- branches/packs/app/views/workflows/show.rhtml	2013-11-19 14:13:18 UTC (rev 3796)
+++ branches/packs/app/views/workflows/show.rhtml	2013-11-19 14:23:50 UTC (rev 3797)
@@ -233,6 +233,8 @@
 	
 	<%= render :partial => "contributions/uploader_box", :locals => { :contributable => @workflow } %>
 	
+  <%= render :partial => "contributions/subscription_box", :locals => { :object => @workflow } -%>
+
 	<%= render :partial => "contributions/license_box", :locals => { :contributable => @workflow } %>
 	
 	<%= render :partial => "contributions/credits_attributions_box", :locals => { :contributable => @workflow, :edit_path => edit_workflow_path(@workflow) } %>

Modified: branches/packs/config/routes.rb (3796 => 3797)


--- branches/packs/config/routes.rb	2013-11-19 14:13:18 UTC (rev 3796)
+++ branches/packs/config/routes.rb	2013-11-19 14:23:50 UTC (rev 3797)
@@ -70,6 +70,7 @@
     pack.resources :relationships, :collection => { :edit_relationships => :get }
     pack.resources :annotations
     pack.resources :items, :requirements => { :id => /[^;]+/ }
+    pack.resource  :subscription
     pack.resources :checklists
     pack.resources :activities, :member => { :feature => [:put, :delete] } do |activity|
       activity.resources :comments
@@ -97,6 +98,7 @@
     workflow.resources :reviews
     workflow.resources :previews
     workflow.resources :comments, :collection => { :timeline => :get }
+    workflow.resource  :subscription
   end
 
   # workflow redirect for linked data model
@@ -155,6 +157,7 @@
     # ie: we cannot have polymorphic nested resources.
     #blob.resources :reviews
     blob.resources :comments, :collection => { :timeline => :get }
+    blob.resource  :subscription
   end
 
   # services
@@ -230,7 +233,6 @@
                  :membership_request => :get, 
                  :rate => :post, 
                  :sync_feed => :post,
-                 :subscription => [:put, :delete],
                  :tag => :post } do |network|
     network.resources :group_announcements, :as => :announcements, :name_prefix => nil
     network.resources :comments, :collection => { :timeline => :get }
@@ -243,6 +245,7 @@
     network.resources :workflows, : :index
     network.resources :blobs, : :index, :as => :files
     network.resources :packs, : :index
+    network.resource  :subscription
   end
   
   # The priority is based upon order of creation: first created -> highest priority.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]