Fix for workshop translation permissions

This commit is contained in:
Godwin
2015-09-21 19:24:52 -07:00
parent da17c38120
commit 2fdfc57c49
53 changed files with 215 additions and 219 deletions
+2 -2
View File
@@ -832,7 +832,7 @@ class ConferencesController < ApplicationController
@workshop = Workshop.find_by_id_and_conference_id(params[:workshop_id], @this_conference.id)
do_404 unless @workshop
@can_edit = @workshop.can_edit?(current_user)
do_403 unless @can_edit || @workshop.can_translate?(current_user)
do_403 unless @can_edit || @workshop.can_translate?(current_user, I18n.locale)
@title = @workshop.title
@info = @workshop.info
@needs = JSON.parse(@workshop.needs || '[]').map &:to_sym
@@ -888,7 +888,7 @@ class ConferencesController < ApplicationController
end
can_edit = workshop.can_edit?(current_user)
do_403 unless can_edit || workshop.can_translate?(current_user)
do_403 unless can_edit || workshop.can_translate?(current_user, I18n.locale)
workshop.title = params[:title]
workshop.info = params[:info]
+2 -2
View File
@@ -83,8 +83,8 @@ class Workshop < ActiveRecord::Base
interested ? interested.size : 0
end
def can_translate?(user)
user.can_translate? || can_edit?(user)
def can_translate?(user, lang)
(user.can_translate? && lang.to_sym != locale.to_sym) || can_edit?(user)
end
private
+2 -2
View File
@@ -12,10 +12,10 @@
= form_tag toggle_workshop_interest_path(@this_conference.slug, @workshop.id) do
= button_tag (@workshop.interested?(current_user) ? :remove_interest : :show_interest), :value => :toggle_interest, :class => (@workshop.interested?(current_user) ? 'delete' : 'add')
=markdown _!(@workshop.info) || ''
- if @workshop.can_translate?(current_user)
- if current_user.can_translate?
.actions
- I18n.backend.enabled_locales.each do |locale|
= (link_to (_'actions.workshops.Translate', "Translate into #{language_name(locale)}", :vars => {:language => language_name(locale)}), edit_workshop_url(@this_conference.slug, @workshop.id, url_params(locale)), :class => 'button translate') if locale.to_sym != I18n.locale.to_sym
= (link_to (_'actions.workshops.Translate', "Translate into #{language_name(locale)}", :vars => {:language => language_name(locale)}), edit_workshop_url(@this_conference.slug, @workshop.id, url_params(locale)), :class => 'button translate') if @workshop.can_translate?(current_user, locale)
= columns(medium: 6) do
%h3=_'articles.workshops.headings.facilitators'
.facilitators