myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [2085] trunk: removed ancient viewings/downloads/


From: noreply
Subject: [myexperiment-hackers] [2085] trunk: removed ancient viewings/downloads/contribution pages
Date: Wed, 4 Feb 2009 09:45:17 -0500 (EST)

Revision
2085
Author
dgc
Date
2009-02-04 09:45:17 -0500 (Wed, 04 Feb 2009)

Log Message

removed ancient viewings/downloads/contribution pages

Modified Paths

Removed Paths

Diff

Deleted: trunk/app/controllers/contributions_controller.rb (2084 => 2085)


--- trunk/app/controllers/contributions_controller.rb	2009-02-04 14:36:50 UTC (rev 2084)
+++ trunk/app/controllers/contributions_controller.rb	2009-02-04 14:45:17 UTC (rev 2085)
@@ -1,148 +0,0 @@
-# myExperiment: app/controllers/contributions_controller.rb
-#
-# Copyright (c) 2007 University of Manchester and the University of Southampton.
-# See license.txt for details.
-
-class ContributionsController < ApplicationController
-  before_filter :login_required, :except => [:index, :show]
-  
-  before_filter :find_contributions, : [:index]
-  before_filter :find_contribution, : [:show]
-  before_filter :find_contribution_auth, : [:edit, :update, :destroy]
-  
-  # GET /contributions
-  def index
-    respond_to do |format|
-      format.html # index.rhtml
-    end
-  end
-
-  # GET /contributions/1
-  def show
-    respond_to do |format|
-      format.html # show.rhtml
-    end
-  end
-
-  # GET /contributions/new
-  def new
-    @contribution = Contribution.new
-  end
-
-  # GET /contributions/1;edit
-  def edit
-
-  end
-
-  # POST /contributions
-  def create
-    @contribution = Contribution.new(params[:contribution])
-
-    respond_to do |format|
-      if @contribution.save
-        flash[:notice] = 'Contribution was successfully created.'
-        format.html { redirect_to contribution_url(@contribution) }
-      else
-        format.html { render :action ="" "new" }
-      end
-    end
-  end
-
-  # PUT /contributions/1
-  def update
-    # hack for select contributor form
-    if params[:contributor_pair]
-      params[:contribution][:contributor_type], params[:contribution][:contributor_id] = params[:contributor_pair][:class_id].split("-")
-      params.delete("contributor_pair")
-    end
-    
-    # security bugfix: do not allow owner to change protected columns
-    [:contributable_id, :contributable_type].each do |column_name|
-      params[:contribution].delete(column_name)
-    end
-    
-    # bug fix to not save 'default' workflow unless policy_id is selected
-    @contribution.policy = nil if (params[:policy_id].nil? or params[:policy_id].empty?)
-    
-    respond_to do |format|
-      if @contribution.update_attributes(params[:contribution])
-        flash[:notice] = 'Contribution was successfully updated.'
-        format.html { redirect_to contribution_url(@contribution) }
-      else
-        format.html { render :action ="" "edit" }
-      end
-    end
-  end
-
-  # DELETE /contributions/1
-  def destroy
-    @contribution.destroy
-
-    respond_to do |format|
-      format.html { redirect_to contributions_url }
-    end
-  end
-  
-protected
-
-  def find_contributions()
-    valid_keys = ["contributor_id", "contributor_type", "contributable_type"]
-    
-    cond_sql = ""
-    cond_params = []
-    
-    params.each do |key, value|
-      if valid_keys.include? key
-        cond_sql << " AND " unless cond_sql.empty?
-        cond_sql << "#{key} = ?" 
-        cond_params << value
-      end
-    end
-    
-    options = { :order => "contributable_type ASC, created_at DESC",
-                :page => { :size => 20, 
-                           :current => params[:page] } }
-    options = options.merge( { :conditions => [cond_sql] + cond_params }) unless cond_sql.empty?
-    
-    @contributions = Contribution.find(:all, options)
-  end
-  
-  def find_contribution
-    begin
-      contribution = Contribution.find(params[:id])
-      
-      if Authorization.is_authorized?(action_name, nil, contribution, current_user)
-        @contribution = contribution
-      else
-        error("Contribution not found (id not authorized)", "is invalid (not authorized)")
-      end
-    rescue ActiveRecord::RecordNotFound
-      error("Contribution not found", "is invalid")
-    end
-  end
-  
-  def find_contribution_auth
-    begin
-      contribution = Contribution.find(params[:id])
-      
-      if contribution.owner?(current_user)
-        @contribution = contribution
-      else
-        error("Contribution not found (id not owner)", "is invalid (not owner)")
-      end
-    rescue ActiveRecord::RecordNotFound
-      error("Contribution not found", "is invalid")
-    end
-  end
-
-private
-
-  def error(notice, message, attr=:id)
-    flash[:error] = notice
-    (err = Contribution.new.errors).add(attr, message)
-    
-    respond_to do |format|
-      format.html { redirect_to contributions_url }
-    end
-  end
-end

Deleted: trunk/app/controllers/downloads_controller.rb (2084 => 2085)


--- trunk/app/controllers/downloads_controller.rb	2009-02-04 14:36:50 UTC (rev 2084)
+++ trunk/app/controllers/downloads_controller.rb	2009-02-04 14:45:17 UTC (rev 2085)
@@ -1,98 +0,0 @@
-class DownloadsController < ApplicationController
-  before_filter :login_required, :except => [:index, :show]
-  
-  before_filter :find_downloads, : [:index]
-  before_filter :find_download, : [:show]
-  
-  # GET /downloads
-  # GET /contribution/1/downloads
-  def index
-    respond_to do |format|
-      format.html # index.rhtml
-    end
-  end
-
-  # GET /downloads/1
-  # GET /contribution/1/downloads/1
-  def show
-    respond_to do |format|
-      format.html # show.rhtml
-    end
-  end
-  
-  def new
-    error("That action (downloads/new) has been disabled", "action has been disabled")
-  end
-  
-  def create
-    error("That action (downloads/create) has been disabled", "action has been disabled")
-  end
-  
-  def edit
-    error("That action (downloads/edit) has been disabled", "action has been disabled")
-  end
-  
-  def update
-    error("That action (downloads/update) has been disabled", "action has been disabled")
-  end
-  
-  def destroy
-    error("That action (downloads/new) has been disabled", "action has been disabled")
-  end
-  
-protected
-
-  def find_contribution
-    if contribution = Contribution.find(:first, :conditions => ["id = ?", params[:contribution_id]])
-      @contribution = contribution
-    else
-      error("Contribution ID not found", "not found", :contribution_id)
-    end
-  end
-
-  def find_downloads
-    if params[:contribution_id]
-      find_contribution
-      
-      @downloads = Download.find(:all, 
-                                 :conditions => ["contribution_id = ?", @contribution.id],
-                                 :page => { :size => 20, 
-                                            :current => params[:page] })
-    else
-      @downloads = Download.find(:all,
-                                 :page => { :size => 20, 
-                                            :current => params[:page] })
-    end
-  end
-  
-  def find_download
-    if params[:contribution_id]
-      find_contribution
-      
-      download = Download.find(:first, :conditions => ["id = ? AND contribution_id = ?", params[:id], @contribution.id])
-    else
-      download = Download.find(:first, :conditions => ["id = ?", params[:id]])
-    end
-    
-    if download
-      @download = download
-    else
-      error("Download ID not found", "not found")
-    end
-  end
-  
-private
-
-  def error(notice, message, attr=:id)
-    flash[:error] = notice
-    (err = Download.new.errors).add(attr, message)
-    
-    respond_to do |format|
-      if @contribution
-        format.html { redirect_to downloads_url(@contribution) }
-      else
-        format.html { redirect_to contributions_url }
-      end
-    end
-  end
-end

Deleted: trunk/app/controllers/viewings_controller.rb (2084 => 2085)


--- trunk/app/controllers/viewings_controller.rb	2009-02-04 14:36:50 UTC (rev 2084)
+++ trunk/app/controllers/viewings_controller.rb	2009-02-04 14:45:17 UTC (rev 2085)
@@ -1,98 +0,0 @@
-class ViewingsController < ApplicationController
-  before_filter :login_required, :except => [:index, :show]
-  
-  before_filter :find_viewings, : [:index]
-  before_filter :find_viewing, : [:show]
-  
-  # GET /viewings
-  # GET /contribution/1/viewings
-  def index
-    respond_to do |format|
-      format.html # index.rhtml
-    end
-  end
-
-  # GET /viewings/1
-  # GET /contribution/1/viewings/1
-  def show
-    respond_to do |format|
-      format.html # show.rhtml
-    end
-  end
-  
-  def new
-    error("That action (viewings/new) has been disabled", "action has been disabled")
-  end
-  
-  def create
-    error("That action (viewings/create) has been disabled", "action has been disabled")
-  end
-  
-  def edit
-    error("That action (viewings/edit) has been disabled", "action has been disabled")
-  end
-  
-  def update
-    error("That action (viewings/update) has been disabled", "action has been disabled")
-  end
-  
-  def destroy
-    error("That action (viewings/new) has been disabled", "action has been disabled")
-  end
-  
-protected
-
-  def find_contribution
-    if contribution = Contribution.find(:first, :conditions => ["id = ?", params[:contribution_id]])
-      @contribution = contribution
-    else
-      error("Contribution ID not found", "not found", :contribution_id)
-    end
-  end
-
-  def find_viewings
-    if params[:contribution_id]
-      find_contribution
-      
-      @viewings = Viewing.find(:all, 
-                               :conditions => ["contribution_id = ?", @contribution.id],
-                               :page => { :size => 20, 
-                                          :current => params[:page] })
-    else
-      @viewings = Viewing.find(:all,
-                               :page => { :size => 20, 
-                                          :current => params[:page] })
-    end
-  end
-  
-  def find_viewing
-    if params[:contribution_id]
-      find_contribution
-      
-      viewing = Viewing.find(:first, :conditions => ["id = ? AND contribution_id = ?", params[:id], @contribution.id])
-    else
-      viewing = Viewing.find(:first, :conditions => ["id = ?", params[:id]])
-    end
-    
-    if viewing
-      @viewing = viewing
-    else
-      error("Viewing ID not found", "not found")
-    end
-  end
-  
-private
-
-  def error(notice, message, attr=:id)
-    flash[:error] = notice
-    (err = Viewing.new.errors).add(attr, message)
-    
-    respond_to do |format|
-      if @contribution
-        format.html { redirect_to viewings_url(@contribution) }
-      else
-        format.html { redirect_to contributions_url }
-      end
-    end
-  end
-end

Deleted: trunk/app/views/contributions/edit.rhtml (2084 => 2085)


--- trunk/app/views/contributions/edit.rhtml	2009-02-04 14:36:50 UTC (rev 2084)
+++ trunk/app/views/contributions/edit.rhtml	2009-02-04 14:45:17 UTC (rev 2085)
@@ -1,13 +0,0 @@
-<h1>Editing contribution</h1>
-
-<%= error_messages_for :contribution %>
-
-<% form_for(:contribution, :url ="" contribution_path(@contribution), :html => { :method => :put }) do |f| %>
-  <% if @contribution.owner?(current_user) %>
-    <%= render :partial => "contributions/contributor_form", :locals => { :user => current_user } %>
-  <% end %>
-
-  <p>
-    <%= submit_tag "Update" %>
-  </p>
-<% end %>

Deleted: trunk/app/views/contributions/index.rhtml (2084 => 2085)


--- trunk/app/views/contributions/index.rhtml	2009-02-04 14:36:50 UTC (rev 2084)
+++ trunk/app/views/contributions/index.rhtml	2009-02-04 14:45:17 UTC (rev 2085)
@@ -1,21 +0,0 @@
-<% type = params[:contributable_type] -%>
-
-<%= render :partial => "contributions/most", :locals => { :type => type } %>
-
-<h2>Listing <%= type ? h(type.pluralize) : "Contributions" %></h2>
-
-<p>
-  <%= link_to "Show all", contributions_path %> or filter by 
-  <% types = ["Blob", "Blog", "Workflow"]; types.delete(params[:contributable_type]) if params[:contributable_type] -%>
-  <% types.each do |t| %>
-    <%= "|" unless types.index(t) == 0 %> <%= link_to t, contributions_path + "?contributable_type=" + t %> 
-  <% end %>
-</p>
-
-<%= render :partial => "layouts/paginate", :locals => { :collection => @contributions } %>
-
-<%= render :partial => "contributions/table", :locals => { :collection => @contributions } %>
-
-<%= render :partial => "layouts/paginate", :locals => { :collection => @contributions } %>
-
-<br/>

Deleted: trunk/app/views/contributions/new.rhtml (2084 => 2085)


--- trunk/app/views/contributions/new.rhtml	2009-02-04 14:36:50 UTC (rev 2084)
+++ trunk/app/views/contributions/new.rhtml	2009-02-04 14:45:17 UTC (rev 2085)
@@ -1,21 +0,0 @@
-<h1>New Contribution</h1>
-
-<%= error_messages_for :contribution %>
-
-<% form_for(:contribution, :url ="" contributions_path) do |f| %>
-  <%= render :partial => "contributions/contributor_form", :locals => { :user => current_user } %>
-
-  <p>
-    <b>Contributable</b><br />
-    <%= f.text_field :contributable_id %>
-  </p>
-
-  <p>
-    <b>Contributable type</b><br />
-    <%= f.text_field :contributable_type %>
-  </p>
-
-  <p>
-    <%= submit_tag "Create" %>
-  </p>
-<% end %>

Deleted: trunk/app/views/contributions/show.rhtml (2084 => 2085)


--- trunk/app/views/contributions/show.rhtml	2009-02-04 14:36:50 UTC (rev 2084)
+++ trunk/app/views/contributions/show.rhtml	2009-02-04 14:45:17 UTC (rev 2085)
@@ -1,63 +0,0 @@
-<div id="tabsContainer" class="tabsContainer"></div>
-
-<div class="tabContainer">
-  <div class="tabTitle">Details</div>
-  <div class="tabContent">
-
-    <p>
-      <b>Contributor:</b><br/>
-      <%= contributor(@contribution.contributor_id, @contribution.contributor_type, true, 100) %>
-    </p>
-
-    <p>
-      <b>Contributable:</b>
-      <%= render :partial => "contributions/list", :locals => { :collection => address@hidden } %>
-    </p>
-    
-    <p>
-      <b>Created at:</b>
-      <%=datetime @contribution.created_at %>
-    </p>
-
-    <p>
-      <b>Updated at:</b>
-      <%=datetime @contribution.updated_at %>
-    </p>
-  </div>
-</div>
-
-<% if logged_in? and @contribution.owner? current_user %>
-  <ul class="sectionIcons">
-    <li><%= icon('edit', edit_contribution_path(@contribution), nil, nil, 'Edit contribution') %></li>
-    <li><%= icon('destroy', contribution_path(@contribution), nil, { :confirm => 'Are you sure?', :method => :delete }, 'Remove contribution') %></li>
-  </ul>
-<% end %>
-
-
-<% if logged_in? && Authorization.is_authorized?("destroy", nil, @contribution, current_user) %>
-  <div class="tabContainer">
-    <div class="tabTitle">Policy</div>
-    <div class="tabContent">
-      <p>
-        <b>Policy:</b>
-        <%= policy_link(@contribution.policy_id) %>
-      </p>
-    </div>
-  </div>
-<% end %>
-
-<div class="tabContainer">
-  <div class="tabTitle">Statistics</div>
-  <div class="tabContent">    
-    <%= render :partial => "contributions/statistics", :object => @contribution %>
-  </div>
-</div>
-
-<% if logged_in? && Authorization.is_authorized?("destroy", nil, @contribution, current_user) %>
-  <div class="tabContainer">
-    <div class="tabTitle">History</div>
-    <div class="tabContent">
-      <%= render :partial => "contributions/history", :object => @contribution %>
-    </div>
-  </div>
-<% end %>

Modified: trunk/config/routes.rb (2084 => 2085)


--- trunk/config/routes.rb	2009-02-04 14:36:50 UTC (rev 2084)
+++ trunk/config/routes.rb	2009-02-04 14:45:17 UTC (rev 2085)
@@ -113,15 +113,6 @@
   # all downloads and viewings
   map.resources :downloads, :viewings
 
-  # contributions (all types)
-  map.resources :contributions do |contribution|
-    # download history
-    contribution.resources :downloads
-
-    # viewing history
-    contribution.resources :viewings
-  end
-
   # messages
   map.resources :messages, :collection => { :sent => :get, :delete_all_selected => :delete }
 

Deleted: trunk/test/functional/contributions_controller_test.rb (2084 => 2085)


--- trunk/test/functional/contributions_controller_test.rb	2009-02-04 14:36:50 UTC (rev 2084)
+++ trunk/test/functional/contributions_controller_test.rb	2009-02-04 14:45:17 UTC (rev 2085)
@@ -1,79 +0,0 @@
-# myExperiment: test/functional/contributions_controller_test.rb
-#
-# Copyright (c) 2007 University of Manchester and the University of Southampton.
-# See license.txt for details.
-
-require File.dirname(__FILE__) + '/../test_helper'
-require 'contributions_controller'
-
-# Re-raise errors caught by the controller.
-class ContributionsController; def rescue_action(e) raise e end; end
-
-class ContributionsControllerTest < Test::Unit::TestCase
-  fixtures :contributions, :users, :workflows, :workflow_versions, :blobs, :packs, :policies, :permissions
-
-  def setup
-    @controller = ContributionsController.new
-    @request    = ActionController::TestRequest.new
-    @response   = ActionController::TestResponse.new
-  end
-
-  # not used on site
-  def test_should_get_index
-    #get :index
-    #assert_response :success
-    #assert assigns(:contributions)
-
-    assert true
-  end
-
-  # not used directly
-  def test_should_get_new
-    #login_as(:john)
-    #get :new
-    #assert_response :success
-
-    assert true
-  end
-  
-  def test_should_create_contribution
-    old_count = Contribution.count
-
-    login_as(:john)
-    post :create, :contribution => { }
-
-    assert_equal old_count+1, Contribution.count
-    assert_redirected_to contribution_path(assigns(:contribution))
-  end
-
-  # not used on site
-  def test_should_show_contribution
-    #login_as(:john)
-    #get :show, :id => 1
-    #assert_response :success
-    
-    assert true
-  end
-
-  def test_should_get_edit
-    login_as(:john)
-    get :edit, :id => 1
-    assert_response :success
-  end
-  
-  def test_should_update_contribution
-    login_as(:john)
-    put :update, :id => 1, :contribution => { }
-    assert_redirected_to contribution_path(assigns(:contribution))
-  end
-  
-  def test_should_destroy_contribution
-    old_count = Contribution.count
-
-    login_as(:john)
-    delete :destroy, :id => 1
-
-    assert_equal old_count-1, Contribution.count
-    assert_redirected_to contributions_path
-  end
-end

Deleted: trunk/test/functional/downloads_controller_test.rb (2084 => 2085)


--- trunk/test/functional/downloads_controller_test.rb	2009-02-04 14:36:50 UTC (rev 2084)
+++ trunk/test/functional/downloads_controller_test.rb	2009-02-04 14:45:17 UTC (rev 2085)
@@ -1,60 +0,0 @@
-require File.dirname(__FILE__) + '/../test_helper'
-require 'downloads_controller'
-
-# Re-raise errors caught by the controller.
-class DownloadsController; def rescue_action(e) raise e end; end
-
-class DownloadsControllerTest < Test::Unit::TestCase
-  fixtures :downloads, :users, :contributions, :workflows, :workflow_versions, :blobs, :packs, :policies, :permissions, :profiles, :pictures, :picture_selections
-
-  def setup
-    @controller = DownloadsController.new
-    @request    = ActionController::TestRequest.new
-    @response   = ActionController::TestResponse.new
-  end
-
-  def test_should_get_index
-    get :index, :contribution_id => contributions(:contribution_workflow_1).id
-    assert_response :success
-    assert assigns(:downloads)
-  end
-
-  # cannot explicitly create new download
-  def test_should_get_new
-    get :new
-    assert_response :redirect
-  end
-  
-  # cannot explicitly create new download
-  def test_should_create_download
-    post :create, :download => { }
-    assert_response :redirect
-  end
-
-  # not used on site so not worth testing
-  def test_should_show_download
-    #login_as(:john)
-    #get :show, :id => 1, :contribution_id => contributions(:contribution_workflow_1).id
-    #assert_response :success
-
-    assert true
-  end
-
-  # cannot edit a download
-  def test_should_get_edit
-    get :edit, :id => 1
-    assert_response :redirect
-  end
-  
-  # cannot update a download
-  def test_should_update_download
-    put :update, :id => 1, :download => { }
-    assert_response :redirect
-  end
-  
-  # cannot destroy a download
-  def test_should_destroy_download
-    delete :destroy, :id => 1
-    assert_response :redirect
-  end
-end

Deleted: trunk/test/functional/viewings_controller_test.rb (2084 => 2085)


--- trunk/test/functional/viewings_controller_test.rb	2009-02-04 14:36:50 UTC (rev 2084)
+++ trunk/test/functional/viewings_controller_test.rb	2009-02-04 14:45:17 UTC (rev 2085)
@@ -1,56 +0,0 @@
-require File.dirname(__FILE__) + '/../test_helper'
-require 'viewings_controller'
-
-# Re-raise errors caught by the controller.
-class ViewingsController; def rescue_action(e) raise e end; end
-
-class ViewingsControllerTest < Test::Unit::TestCase
-  fixtures :viewings, :users, :contributions, :workflows, :blobs, :packs
-
-  def setup
-    @controller = ViewingsController.new
-    @request    = ActionController::TestRequest.new
-    @response   = ActionController::TestResponse.new
-  end
-
-  def test_should_get_index
-    get :index, :contribution_id => contributions(:contribution_workflow_1).id
-    assert_response :success
-    assert assigns(:viewings)
-  end
-
-  # cannot directly create new viewing
-  def test_should_get_new
-    get :new
-    assert_response :redirect
-  end
-  
-  # cannot directly create new viewing
-  def test_should_create_viewing
-    post :create, :viewing => { }
-    assert_response :redirect
-  end
-
-  def test_should_show_viewing
-    get :show, :id => 1, :contribution_id => contributions(:contribution_workflow_1).id
-    assert_response :success
-  end
-
-  # cannot edit a viewing
-  def test_should_get_edit
-    get :edit, :id => 1
-    assert_response :redirect
-  end
-  
-  # cannot update a viewing
-  def test_should_update_viewing
-    put :update, :id => 1, :viewing => { }
-    assert_response :redirect
-  end
-  
-  # cannot destroy a viewing
-  def test_should_destroy_viewing
-    delete :destroy, :id => 1    
-    assert_response :redirect
-  end
-end

reply via email to

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