studien visible

This commit is contained in:
Andreas Stephanides
2015-05-06 15:10:16 +02:00
parent 0656e849bd
commit 4b71964e26
4 changed files with 15 additions and 5 deletions

View File

@@ -3,7 +3,7 @@ class StudienController < ApplicationController
# before_filter :authorize, :only => :verwalten # before_filter :authorize, :only => :verwalten
load_and_authorize_resource load_and_authorize_resource
def index 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("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("modul.list"),:path=>moduls_path}
@topbar_elements<<{:hicon=>'icon-list', :text=>I18n.t("lva.list"),:path=>lvas_path} @topbar_elements<<{:hicon=>'icon-list', :text=>I18n.t("lva.list"),:path=>lvas_path}
@@ -13,7 +13,7 @@ class StudienController < ApplicationController
def show def show
@studium= Studium.find(params[:id]) @studium= Studium.find(params[:id])
@studien = Studium.accessible_by(current_ability, :show)
@studienphasen=[] @studienphasen=[]
[1, 2 ,3].each do |ph| [1, 2 ,3].each do |ph|
modulgruppen_phase=@studium.modulgruppen.where(:phase=>ph) modulgruppen_phase=@studium.modulgruppen.where(:phase=>ph)
@@ -49,16 +49,19 @@ class StudienController < ApplicationController
end end
def new def new
@studien = Studium.accessible_by(current_ability, :show)
@studium = Studium.new @studium = Studium.new
end end
def edit def edit
@studien = Studium.accessible_by(current_ability, :show)
@studium = Studium.find(params[:id]) @studium = Studium.find(params[:id])
@toolbar_elements=[{:text => I18n.t('studien.anzeigen') , :path => url_for(@studium) }] @toolbar_elements=[{:text => I18n.t('studien.anzeigen') , :path => url_for(@studium) }]
@toolbar_elements<<{:text =>I18n.t('studien.allestudien'),:path=>studien_path(@studium)} @toolbar_elements<<{:text =>I18n.t('studien.allestudien'),:path=>studien_path(@studium)}
end end
def edit_lvas def edit_lvas
@studien = Studium.accessible_by(current_ability, :show)
@studium = Studium.find(params[:id]) @studium = Studium.find(params[:id])
@lvas=@studium.lvas.uniq @lvas=@studium.lvas.uniq
@semester=@studium.semester @semester=@studium.semester
@@ -83,6 +86,7 @@ class StudienController < ApplicationController
def update def update
@studium = Studium.find(params[:id]) @studium = Studium.find(params[:id])
@studien = Studium.accessible_by(current_ability, :show)
logger.info "params: #{params[:studium].inspect}" logger.info "params: #{params[:studium].inspect}"
if @studium.update_attributes(params[:studium]) if @studium.update_attributes(params[:studium])
if @studium.lvas.map(&:valid?).all? if @studium.lvas.map(&:valid?).all?
@@ -106,7 +110,8 @@ class StudienController < ApplicationController
def verwalten 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]} @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? if @new_params.values.compact.empty?
@studien=Studium.all
@modulgruppen=Modulgruppe.all @modulgruppen=Modulgruppe.all
@module=Modul.all @module=Modul.all
@lvas=Lva.all @lvas=Lva.all

View File

@@ -8,7 +8,7 @@ class Ability
#----------------------------------------------------- #-----------------------------------------------------
# Rechteverwaltung fuer Studien Modul # Rechteverwaltung fuer Studien Modul
can [:show, :index], Studium can [:show, :index], Studium, :visible=>true
can [:show], Modulgruppe can [:show], Modulgruppe
can [:show, :index], Modul can [:show, :index], Modul
can [:show, :index, :beispiel_sammlung], Lva can [:show, :index, :beispiel_sammlung], Lva

View File

@@ -5,7 +5,7 @@
<li> <li>
<% end %> <% end %>
<%= link_to I18n.t("studien.allestudien"), studien_path %> </li> <%= link_to I18n.t("studien.allestudien"), studien_path %> </li>
<% for s in Studium.all %> <% for s in @studien %>
<% if !@studium.nil? && s == @studium %> <% if !@studium.nil? && s == @studium %>
<li class="active" title="<%= s.name %>"> <li class="active" title="<%= s.name %>">

View File

@@ -0,0 +1,5 @@
class AddVisibleToStudien < ActiveRecord::Migration
def change
add_column :studien, :visible, :boolean
end
end