From 7436c5c01e1ba113e795612a05cc35ab7a5f25c1 Mon Sep 17 00:00:00 2001 From: Andreas Stephanides Date: Sun, 19 Oct 2014 19:49:33 +0200 Subject: [PATCH] =?UTF-8?q?rechte=20f=C3=BCr=20actions=20versions=20neuigk?= =?UTF-8?q?eiten?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/neuigkeiten_controller.rb | 9 +++++---- app/controllers/themen_controller.rb | 4 +++- app/models/ability.rb | 2 ++ app/views/layouts/_pretty_toolbar.html.erb | 2 ++ app/views/neuigkeiten/_nlink_list.html.erb | 2 +- app/views/themen/_small.html.erb | 2 +- 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/controllers/neuigkeiten_controller.rb b/app/controllers/neuigkeiten_controller.rb index 60e5ce3..d1f5c01 100755 --- a/app/controllers/neuigkeiten_controller.rb +++ b/app/controllers/neuigkeiten_controller.rb @@ -15,8 +15,8 @@ class NeuigkeitenController < ApplicationController else @rubriken = Rubrik.where(:public=>true) end - - if !params[:version].nil? + + if !params[:version].nil? && can?(:showversions, Neuigkeit) @neuigkeit.assign_attributes(@neuigkeit.translation.versions.reverse[params[:version].to_i].reify.attributes.select{|k,v| @neuigkeit.translated_attribute_names.include? k.to_sym }) end @calentries1=@neuigkeit.calentries @@ -192,12 +192,13 @@ actions << {:hicon=>'icon-facebook', :text=> I18n.t('neuigkeit.publishfetmail'), @toolbar_elements << {:text=>I18n.t('common.edit'),:path=>edit_rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:icon=>:pencil} if can? :edit, @neuigkeit.rubrik +if can?(:showversions, Neuigkeit) @versions= @neuigkeit.translation.versions.select([:created_at]).reverse @toolbar_elements <<{:path=>rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit),:method=>:versions,:versions=>@versions} - +end actions << {:hicon=>'icon-remove-circle', :text=> I18n.t('common.delete'),:path => rubrik_neuigkeit_path(@neuigkeit.rubrik,@neuigkeit), :method=> :delete,:confirm=>'Sure?' } if can? :delete, @neuigkeit - @toolbar_elements << {:text => "action", :method => :dropdown, :elements=> actions} + @toolbar_elements << {:text => "action", :method => :dropdown, :elements=> actions} unless actions.empty? end diff --git a/app/controllers/themen_controller.rb b/app/controllers/themen_controller.rb index 1b5a875..5f5024a 100644 --- a/app/controllers/themen_controller.rb +++ b/app/controllers/themen_controller.rb @@ -38,7 +38,7 @@ class ThemenController < ApplicationController # # # # @thema.text = @thema.text.sanitize - render :show + render :edit end def verwalten @thema = Thema.find(params[:id]) @@ -46,6 +46,8 @@ class ThemenController < ApplicationController @fragen=@thema.fragen @toolbar_elements = [{:icon=>:pencil, :hicon=>'icon-pencil', :text=>I18n.t('thema.edit'), :path=>edit_thema_path(@thema)}] + @toolbar_elements <<{ :hicon=>'icon-leaf', :text=>"Sanitize", :path=>sanitize_thema_path(@thema)} + @toolbar_elements << {:hicon=>'icon-remove-circle', :text=>I18n.t('thema.remove'), :path=>thema_path(@thema), :method=>:delete, :confirm=>I18n.t('thema.sure')} end diff --git a/app/models/ability.rb b/app/models/ability.rb index 296af27..74c3bd5 100755 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -24,6 +24,7 @@ class Ability can :manage, Studium can :manage, Beispiel can :manage, Lecturer + end unless user.has_role?("fetadmin") cannot :delete, Studium @@ -88,6 +89,7 @@ class Ability if loggedin end if( user.has_role?("fetuser") || user.has_role?("fetadmin")) + can :showintern, Neuigkeit can :showintern, Rubrik can :seeintern, User diff --git a/app/views/layouts/_pretty_toolbar.html.erb b/app/views/layouts/_pretty_toolbar.html.erb index 8405a4c..8b8ef77 100644 --- a/app/views/layouts/_pretty_toolbar.html.erb +++ b/app/views/layouts/_pretty_toolbar.html.erb @@ -31,6 +31,7 @@ Verwendung: Aufruf mit <% end %> <% else %> +<% if t[:versions].count>0 %>
<%= I18n.t("common.versions") %> @@ -53,6 +54,7 @@ Verwendung: Aufruf mit <% end %>
+<% end %> <% end %> <% end %> diff --git a/app/views/neuigkeiten/_nlink_list.html.erb b/app/views/neuigkeiten/_nlink_list.html.erb index f011fba..5328180 100644 --- a/app/views/neuigkeiten/_nlink_list.html.erb +++ b/app/views/neuigkeiten/_nlink_list.html.erb @@ -5,7 +5,7 @@ <% p = nlink_list.link_type.downcase.pluralize+"/nlink" %> <%= raw(strip_links(render :partial=>p, :object=>nlink_list.link )) %> -<%= link_to "DELETE", delete_link_rubrik_neuigkeit_path(nlink_list.neuigkeit.rubrik,nlink_list.neuigkeit.id, :nlink_id=>nlink_list.id) %> +<%= link_to "DELETE", delete_link_rubrik_neuigkeit_path(nlink_list.neuigkeit.rubrik,nlink_list.neuigkeit.id, :nlink_id=>nlink_list.id) if can? :delete, Nlink %> <% end %> diff --git a/app/views/themen/_small.html.erb b/app/views/themen/_small.html.erb index 397d435..c30e6cb 100644 --- a/app/views/themen/_small.html.erb +++ b/app/views/themen/_small.html.erb @@ -1,6 +1,6 @@ <% if can? :show, small %> -

<%= small.title %> <%= link_to fa_icon("pencil"), verwalten_thema_path(small) if can? :edit, small %>

+

<%= small.title %> <%= link_to fa_icon("pencil"), verwalten_thema_path(small) if can? :edit, small %> <%= link_to fa_icon("paint-brush"), sanitize_thema_path(small) if can? :edit, small %>

<% if small.is_outdated? %>
<%= I18n.t("thema.outdated") %> <%= link_to"Als aktuell markieren",is_updated_thema_path(small), :class=>:btn if can? :is_updated, small%>