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
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

View File

@@ -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

View File

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