diff --git a/app/controllers/admin/licenses_controller.rb b/app/controllers/admin/licenses_controller.rb index 49212c5..1cef9ca 100644 --- a/app/controllers/admin/licenses_controller.rb +++ b/app/controllers/admin/licenses_controller.rb @@ -20,7 +20,7 @@ class LicensesController < AdminController end def edit - @license = License.find(params[:license_id]) + @license = environment.licenses.find(params[:license_id]) if request.post? begin @license.update_attributes!(params[:license]) @@ -33,12 +33,16 @@ class LicensesController < AdminController end def remove - @license = License.find(params[:license_id]) - begin - @license.destroy - session[:notice] = _('Licese removed') - rescue - session[:notice] = _('Licese could not be removed') + @license = environment.licenses.find(params[:license_id]) + if request.post? + begin + @license.destroy + session[:notice] = _('License removed') + rescue + session[:notice] = _('License could not be removed') + end + else + session[:notice] = _('License could not be removed') end redirect_to :action => 'index' end diff --git a/app/views/cms/_general_fields.html.erb b/app/views/cms/_general_fields.html.erb index d1f7715..3644994 100644 --- a/app/views/cms/_general_fields.html.erb +++ b/app/views/cms/_general_fields.html.erb @@ -1 +1 @@ -<%= labelled_form_field(_('License'), select(:article, :license_id, [[_('None'), nil]] + profile.environment.licenses.map {|license| [license.name, license.id]})) %> +<%= labelled_form_field(_('License'), select(:article, :license_id, options_for_select_with_title([[_('None'), nil]] + profile.environment.licenses.map {|license| [license.name, license.id]}, @article.license ? @article.license.id : nil))) %> diff --git a/app/views/licenses/index.html.erb b/app/views/licenses/index.html.erb index af50ba0..02106be 100644 --- a/app/views/licenses/index.html.erb +++ b/app/views/licenses/index.html.erb @@ -1,5 +1,5 @@