From 4b71964e26eae04dad53813d60f22a8ca372dfb5 Mon Sep 17 00:00:00 2001 From: Andreas Stephanides Date: Wed, 6 May 2015 15:10:16 +0200 Subject: [PATCH] studien visible --- app/controllers/studien_controller.rb | 11 ++++++++--- app/models/ability.rb | 2 +- app/views/studien/_tabs.html.erb | 2 +- db/migrate/20150506112709_add_visible_to_studien.rb | 5 +++++ 4 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 db/migrate/20150506112709_add_visible_to_studien.rb diff --git a/app/controllers/studien_controller.rb b/app/controllers/studien_controller.rb index da15ac6..ac66f01 100755 --- a/app/controllers/studien_controller.rb +++ b/app/controllers/studien_controller.rb @@ -3,7 +3,7 @@ class StudienController < ApplicationController # before_filter :authorize, :only => :verwalten load_and_authorize_resource def index - @studien = Studium.all + @studien = Studium.accessible_by(current_ability, :show) @topbar_elements=[{:hicon=>'icon-list', :text=>I18n.t("studien.allestudien"),:path=>studien_path}] @topbar_elements<<{:hicon=>'icon-list', :text=>I18n.t("modul.list"),:path=>moduls_path} @topbar_elements<<{:hicon=>'icon-list', :text=>I18n.t("lva.list"),:path=>lvas_path} @@ -13,7 +13,7 @@ class StudienController < ApplicationController def show @studium= Studium.find(params[:id]) - + @studien = Studium.accessible_by(current_ability, :show) @studienphasen=[] [1, 2 ,3].each do |ph| modulgruppen_phase=@studium.modulgruppen.where(:phase=>ph) @@ -49,16 +49,19 @@ class StudienController < ApplicationController end def new + @studien = Studium.accessible_by(current_ability, :show) @studium = Studium.new end def edit + @studien = Studium.accessible_by(current_ability, :show) @studium = Studium.find(params[:id]) @toolbar_elements=[{:text => I18n.t('studien.anzeigen') , :path => url_for(@studium) }] @toolbar_elements<<{:text =>I18n.t('studien.allestudien'),:path=>studien_path(@studium)} end def edit_lvas + @studien = Studium.accessible_by(current_ability, :show) @studium = Studium.find(params[:id]) @lvas=@studium.lvas.uniq @semester=@studium.semester @@ -83,6 +86,7 @@ class StudienController < ApplicationController def update @studium = Studium.find(params[:id]) + @studien = Studium.accessible_by(current_ability, :show) logger.info "params: #{params[:studium].inspect}" if @studium.update_attributes(params[:studium]) if @studium.lvas.map(&:valid?).all? @@ -106,7 +110,8 @@ class StudienController < ApplicationController def verwalten @new_params={:std_verw=>params[:std_verw], :mg_verw=>params[:mg_verw], :m_verw=>params[:m_verw], :lva_verw=>params[:lva_verw], :b_verw=>params[:b_verw], :lec_verw=>params[:lec_verw]} if @new_params.values.compact.empty? - @studien=Studium.all + + @modulgruppen=Modulgruppe.all @module=Modul.all @lvas=Lva.all diff --git a/app/models/ability.rb b/app/models/ability.rb index 73b5237..364fe05 100755 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -8,7 +8,7 @@ class Ability #----------------------------------------------------- # Rechteverwaltung fuer Studien Modul - can [:show, :index], Studium + can [:show, :index], Studium, :visible=>true can [:show], Modulgruppe can [:show, :index], Modul can [:show, :index, :beispiel_sammlung], Lva diff --git a/app/views/studien/_tabs.html.erb b/app/views/studien/_tabs.html.erb index 788997d..303537b 100644 --- a/app/views/studien/_tabs.html.erb +++ b/app/views/studien/_tabs.html.erb @@ -5,7 +5,7 @@
  • <% end %> <%= link_to I18n.t("studien.allestudien"), studien_path %>
  • -<% for s in Studium.all %> +<% for s in @studien %> <% if !@studium.nil? && s == @studium %>
  • diff --git a/db/migrate/20150506112709_add_visible_to_studien.rb b/db/migrate/20150506112709_add_visible_to_studien.rb new file mode 100644 index 0000000..d6bd98b --- /dev/null +++ b/db/migrate/20150506112709_add_visible_to_studien.rb @@ -0,0 +1,5 @@ +class AddVisibleToStudien < ActiveRecord::Migration + def change + add_column :studien, :visible, :boolean + end +end