summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2010-09-10 16:00:49 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2010-09-10 16:00:49 +0000
commit3a2efb47572d198c91a09b1bf92e717b843980ed (patch)
tree4999fd81509971bf2ee45ba80983b336ce51d551 /app
parent5e1c29523003f697b4ba88998c1c587881785820 (diff)
downloadredmine-3a2efb47572d198c91a09b1bf92e717b843980ed.tar.gz
redmine-3a2efb47572d198c91a09b1bf92e717b843980ed.zip
Refactor: convert ProjectEnumerations to a resource on a project.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4075 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/controllers/application_controller.rb7
-rw-r--r--app/controllers/project_enumerations_controller.rb6
-rw-r--r--app/views/projects/settings/_activities.rhtml4
3 files changed, 12 insertions, 5 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 725bde788..32bb528a3 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -169,6 +169,13 @@ class ApplicationController < ActionController::Base
render_404
end
+ # Find project of id params[:project_id]
+ def find_project_by_project_id
+ @project = Project.find(params[:project_id])
+ rescue ActiveRecord::RecordNotFound
+ render_404
+ end
+
# Find a project based on params[:project_id]
# TODO: some subclasses override this, see about merging their logic
def find_optional_project
diff --git a/app/controllers/project_enumerations_controller.rb b/app/controllers/project_enumerations_controller.rb
index d63e23641..0b15887fa 100644
--- a/app/controllers/project_enumerations_controller.rb
+++ b/app/controllers/project_enumerations_controller.rb
@@ -1,9 +1,9 @@
class ProjectEnumerationsController < ApplicationController
- before_filter :find_project
+ before_filter :find_project_by_project_id
before_filter :authorize
- def save
- if request.post? && params[:enumerations]
+ def update
+ if request.put? && params[:enumerations]
Project.transaction do
params[:enumerations].each do |id, activity|
@project.update_or_create_time_entry_activity(id, activity)
diff --git a/app/views/projects/settings/_activities.rhtml b/app/views/projects/settings/_activities.rhtml
index 5909ac64c..726e6240c 100644
--- a/app/views/projects/settings/_activities.rhtml
+++ b/app/views/projects/settings/_activities.rhtml
@@ -1,4 +1,4 @@
-<% form_tag({:controller => 'project_enumerations', :action => 'save', :id => @project}, :class => "tabular") do %>
+<% form_tag(project_project_enumerations_path(@project), :method => :put, :class => "tabular") do %>
<table class="list">
<thead><tr>
@@ -32,7 +32,7 @@
</table>
<div class="contextual">
-<%= link_to(l(:button_reset), {:controller => 'project_enumerations', :action => 'destroy', :id => @project},
+<%= link_to(l(:button_reset), project_project_enumerations_path(@project),
:method => :delete,
:confirm => l(:text_are_you_sure),
:class => 'icon icon-del') %>