Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge commit '48a292c5f1c5dd15ac4a272a9ddd5dd4eac5c86d' into HEAD

  • Loading branch information...
commit d55b8f4c82ea6656b150d38344033e1915dffc7c 2 parents ec3d386 + 48a292c
Jenkins authored
8 app/controllers/artefacts_controller.rb
... ... @@ -1,5 +1,4 @@
1 1 class ArtefactsController < ApplicationController
2   - before_filter :redirect_to_show_if_need_met, :only => :new
3 2 before_filter :find_artefact, :only => [:show, :edit, :update]
4 3 before_filter :build_artefact, :only => [:new, :create]
5 4
@@ -17,6 +16,7 @@ def show
17 16 end
18 17
19 18 def new
  19 + redirect_to_show_if_need_met
20 20 end
21 21
22 22 def edit
@@ -24,9 +24,7 @@ def edit
24 24
25 25 def create
26 26 @artefact.save
27   - location = @artefact.admin_url
28   - location += '?return_to=' + params[:return_to] if params[:return_to]
29   - respond_with @artefact, location: location
  27 + respond_with @artefact, location: @artefact.admin_url(params.slice(:return_to))
30 28 end
31 29
32 30 def update
@@ -44,7 +42,7 @@ def update
44 42
45 43 private
46 44 def redirect_to_show_if_need_met
47   - if params[:artefact] and params[:artefact][:need_id]
  45 + if params[:artefact] && params[:artefact][:need_id]
48 46 artefact = Artefact.where(need_id: params[:artefact][:need_id]).first
49 47 redirect_to artefact if artefact
50 48 end
7 app/models/artefact.rb
@@ -90,9 +90,10 @@ def normalise
90 90 self.kind = KIND_TRANSLATIONS[kind.to_s.downcase.strip]
91 91 end
92 92
93   - def admin_url
94   - app = Plek.current.find owning_app
95   - app += '/admin/publications/' + id.to_s
  93 + def admin_url(options = {})
  94 + [ "#{Plek.current.find(owning_app)}/admin/publications/#{id}",
  95 + options.to_query
  96 + ].reject(&:blank?).join("?")
96 97 end
97 98
98 99 # TODO: Replace this nonsense with a proper API layer.

0 comments on commit d55b8f4

Please sign in to comment.
Something went wrong with that request. Please try again.