forked from bofh/fetsite
Merge branch 'master' of https://github.com/andreassteph/fetsite
Beispiel.lva bei neues Beispiel resolved Conflicts: app/controllers/beispiele_controller.rb
This commit is contained in:
@@ -2,6 +2,7 @@ class BeispieleController < ApplicationController
|
||||
# GET /beispiele
|
||||
# GET /beispiele.json
|
||||
def index
|
||||
@lva = params([:lva])
|
||||
@beispiele = Beispiel.all
|
||||
|
||||
respond_to do |format|
|
||||
@@ -13,6 +14,7 @@ class BeispieleController < ApplicationController
|
||||
# GET /beispiele/1
|
||||
# GET /beispiele/1.json
|
||||
def show
|
||||
@lva = lva unless lva.nil?
|
||||
@beispiel = Beispiel.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
@@ -26,7 +28,7 @@ class BeispieleController < ApplicationController
|
||||
def new
|
||||
@beispiel = Beispiel.new
|
||||
@beispiel.lva = Lva.find(params[:lva_id])
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.json { render json: @beispiel }
|
||||
|
||||
@@ -3,23 +3,36 @@ class LvasController < ApplicationController
|
||||
before_filter {@toolbar_elements =[]}
|
||||
def index
|
||||
@lvas = Lva.all
|
||||
|
||||
@toolbar_elements=[{:hicon=>'icon-plus-sign',:text =>I18n.t('lva.add'),:path => new_lva_path}]
|
||||
@tb=[{:hicon=>'icon-list', :text=>I18n.t("studien.allestudien"),:path=>studien_path},
|
||||
{:hicon=>'icon-list', :text=>I18n.t("modul.list"),:path=>moduls_path},
|
||||
{:hicon=>'icon-list', :text=>I18n.t("lva.list"),:path=>lvas_path}]
|
||||
end
|
||||
|
||||
# GET /lvas/1
|
||||
|
||||
def show
|
||||
@lva = Lva.find_by_id(params[:id])
|
||||
@toolbar_elements<<{:icon=>:pencil,:text =>I18n.t('common.edit'),:path => edit_lva_path(@lva)}
|
||||
|
||||
@toolbar_elements<<{:hicon=>'icon-plus-sign', :icon=>:plus, :text => "Neues Beispiel", :path=> new_beispiel_path(:lva_id =>@lva.id)}
|
||||
@toolbar_elements<<{:hicon=>'icon-pencil', :icon=>:pencil,:text =>I18n.t('common.edit'),:path => edit_lva_path(@lva)}
|
||||
@topbar_elements =[{:hicon=>'icon-list', :text=>I18n.t("lva.list"), :path=>lvas_path}]
|
||||
for m in @lva.modul
|
||||
@topbar_elements << {:newline=>true}
|
||||
@topbar_elements << {:text=> '<b>' + m.name + '</b>', :path=>modul_path(m)}
|
||||
for mg in m.modulgruppen
|
||||
@topbar_elements << {:text => mg.studium.name + ' (' + mg.name + ')', :path=>studium_path(mg.studium)}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# GET /lvas/new
|
||||
# GET /lvas/new.json
|
||||
def new
|
||||
@lva = Lva.new
|
||||
modul=Modul.find(params[:modul_id])
|
||||
@lva.modul<<modul
|
||||
|
||||
modul=Modul.find_by_id(params[:modul_id])
|
||||
@lva.modul<<modul unless modul.nil? #
|
||||
|
||||
end
|
||||
|
||||
# GET /lvas/1/edit
|
||||
@@ -31,14 +44,15 @@ class LvasController < ApplicationController
|
||||
# POST /lvas.json
|
||||
def create
|
||||
@lva = Lva.new(params[:lva])
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
if @lva.save
|
||||
@lva.add_semesters
|
||||
format.html { redirect_to @lva, notice: 'Lva was successfully created.' }
|
||||
|
||||
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -47,9 +61,10 @@ class LvasController < ApplicationController
|
||||
# PUT /lvas/1.json
|
||||
def update
|
||||
@lva = Lva.find(params[:id])
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
if @lva.update_attributes(params[:lva])
|
||||
@lva.add_semesters
|
||||
format.html { redirect_to @lva, notice: 'Lva was successfully updated.' }
|
||||
|
||||
else
|
||||
|
||||
@@ -27,9 +27,9 @@ class ModulgruppenController < ApplicationController
|
||||
def new
|
||||
@modulgruppe = Modulgruppe.new
|
||||
if !params[:studium_id].nil?
|
||||
@studium=Studium.find(params[:studium_id])
|
||||
@modulgruppe.studium_id=(params[:studium_id])
|
||||
else
|
||||
@studium=Studium.first
|
||||
@modulgruppe.studium_id=studium_id=Studium.first.id
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
@@ -50,14 +50,16 @@ class ModulgruppenController < ApplicationController
|
||||
|
||||
def create
|
||||
@modulgruppe = Modulgruppe.new(params[:modulgruppe])
|
||||
|
||||
if !params[:studium_id].nil?
|
||||
@studium=Studium.find_by_id(params[:studium_id])
|
||||
else
|
||||
@studium=Studium.find_by_id(params[:modulgruppe][:studium_id])
|
||||
end
|
||||
respond_to do |format|
|
||||
|
||||
if @modulgruppe.save
|
||||
format.html { redirect_to @modulgruppe, notice: 'Modulgruppe was successfully created.' }
|
||||
format.html { redirect_to @studium, notice: 'Modulgruppe was successfully created.' }
|
||||
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
|
||||
@@ -2,24 +2,47 @@ class ModulsController < ApplicationController
|
||||
# GET /moduls
|
||||
# GET /moduls.json
|
||||
def index
|
||||
@moduls = Modul.all
|
||||
if @moduls
|
||||
if !params[:studium_id].nil?
|
||||
@studium=Studium.find_by_id(params[:studium_id])
|
||||
end
|
||||
@moduls = Modul.all
|
||||
if @moduls
|
||||
if !params[:studium_id].nil?
|
||||
@studium=Studium.find_by_id(params[:studium_id])
|
||||
end
|
||||
@toolbar_elements = [{:hicon=>'icon-plus-sign', :text=>I18n.t("modul.add"), :path=>new_modul_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("lva.list"),:path=>lvas_path}
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @moduls }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# GET /moduls/1
|
||||
# GET /moduls/1.json
|
||||
def show
|
||||
@modul = Modul.find(params[:id])
|
||||
@toolbar_elements = [{:hicon=>'icon-plus-sign', :text=>I18n.t("lva.add"), :path=>new_lva_path(:modul_id =>@modul.id)}]
|
||||
@toolbar_elements << {:hicon=>'icon-pencil', :text=>I18n.t("modul.edit"), :path=>edit_modul_path(@modul)}
|
||||
@toolbar_elements << {:hicon=>'icon-remove-circle', :text=>I18n.t("common.delete"),:path=>@modul , :method=>:delete , :data=>{:confirm =>'Are you sure'}}
|
||||
|
||||
respond_to do |format|
|
||||
|
||||
@topbar_elements = [{:hicon=>'icon-list', :text=>I18n.t("modul.list"),:path=>moduls_path}]
|
||||
@tb=[]
|
||||
for i in @modul.modulgruppen
|
||||
|
||||
if !i.studium.nil?
|
||||
name =i.studium.name
|
||||
id = i.studium.id
|
||||
else
|
||||
s.name = 'Kein Studium vorhanden'
|
||||
s.id = nil
|
||||
end
|
||||
@tb <<{:text=> i.name + ' ('+i.studium.name + ')', :path=>modulgruppe_path(i)}
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render json: @modul }
|
||||
end
|
||||
@@ -31,7 +54,7 @@ class ModulsController < ApplicationController
|
||||
@modul = Modul.new
|
||||
modulgruppe=Modulgruppe.find_by_id(params[:modulgruppen_id])
|
||||
if !modulgruppe.nil?
|
||||
@modul.modulgruppen<<modulgruppe
|
||||
@modul.modulgruppen<<modulgruppe #
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
@@ -42,27 +65,30 @@ class ModulsController < ApplicationController
|
||||
# GET /moduls/1/edit
|
||||
def edit
|
||||
@modul = Modul.find(params[:id])
|
||||
if !params[:studium_id].nil?
|
||||
@studium=Studium.find(params[:studium_id])
|
||||
end
|
||||
if !params[:studium_id].nil?
|
||||
@studium=Studium.find(params[:studium_id])
|
||||
end
|
||||
end
|
||||
|
||||
# POST /moduls
|
||||
# POST /moduls.json
|
||||
def create
|
||||
@modul = Modul.new(params[:modul])
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
if @modul.save
|
||||
|
||||
respond_to do |format|
|
||||
if @modul.save
|
||||
for i in @modul.lvas
|
||||
i.add_semesters
|
||||
end
|
||||
format.html { redirect_to modulgruppe_path(@modul.modulgruppen.first), notice: 'Modul was successfully created.' }
|
||||
format.json { render json: @modul, status: :created, location: @modul }
|
||||
else
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.json { render json: @modul.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# PUT /moduls/1
|
||||
@@ -72,6 +98,9 @@ class ModulsController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
if @modul.update_attributes(params[:modul])
|
||||
for i in @modul.lvas
|
||||
i.add_semesters
|
||||
end
|
||||
format.html { redirect_to url_for(@modul), notice: 'Modul was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
@@ -87,6 +116,9 @@ class ModulsController < ApplicationController
|
||||
|
||||
@modul = Modul.find(params[:id])
|
||||
modulgruppe=@modul.modulgruppen.first
|
||||
for i in @modul.lvas
|
||||
i.add_semesters
|
||||
end
|
||||
@modul.destroy
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ class SemestersController < ApplicationController
|
||||
@semesters = Semester.all
|
||||
end
|
||||
|
||||
|
||||
|
||||
def show
|
||||
@semester = Semester.find(params[:id])
|
||||
|
||||
@@ -20,6 +20,7 @@ class SemestersController < ApplicationController
|
||||
|
||||
def create
|
||||
@semester = Semester.new(params[:semester])
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
if @semester.save
|
||||
@@ -45,7 +46,7 @@ class SemestersController < ApplicationController
|
||||
def destroy
|
||||
@semester = Semester.find(params[:id])
|
||||
@semester.destroy
|
||||
redirect_to semester_url
|
||||
redirect_to semester_url
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,52 +1,71 @@
|
||||
class StudienController < ApplicationController
|
||||
before_filter {@toolbar_elements =[]}
|
||||
before_filter {@toolbar_elements =[]}
|
||||
|
||||
|
||||
def index
|
||||
@studien = Studium.all
|
||||
@toolbar_elements<<{:icon =>:plus, :text=> I18n.t('studien.new') ,:path=>new_studium_path }
|
||||
@toolbar_elements<<{:text=> I18n.t('modulgruppe.show.link') ,:path=>modulgruppen_path }
|
||||
@toolbar_elements<<{:text=> I18n.t('modul.show.link') ,:path=>moduls_path }
|
||||
end
|
||||
def index
|
||||
@studien = Studium.all
|
||||
@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}
|
||||
@toolbar_elements<<{:icon =>:plus, :hicon=>'icon-plus-sign', :text=> I18n.t('studien.new') ,:path=>new_studium_path }
|
||||
# @toolbar_elements<<{:text=> I18n.t('modulgruppe.show.link') ,:path=>modulgruppen_path }
|
||||
end
|
||||
|
||||
def show
|
||||
@studium= Studium.find(params[:id])
|
||||
@studienphasen=[]
|
||||
[1, 2 ,3].each do |ph|
|
||||
modulgruppen_phase=@studium.modulgruppen.where(:phase=>ph)
|
||||
if modulgruppen_phase.count==1
|
||||
opts={:width=>12, :slice=>1}
|
||||
elsif modulgruppen_phase.count <= 4
|
||||
opts={:width=>6, :slice=>2}
|
||||
else
|
||||
opts={:width=>4, :slice=>3}
|
||||
end
|
||||
modulgruppen =[]
|
||||
modulgruppen_phase.each_slice(opts[:slice]) do |s|
|
||||
modulgruppen<<s
|
||||
end
|
||||
@studienphasen << {:modulgruppen=>modulgruppen, :phase => ph}.merge(opts)
|
||||
end
|
||||
@toolbar_elements=[{:icon =>:plus ,:text=> I18n.t('studien.new') , :path => new_studium_modulgruppe_path(@studium) }]
|
||||
@toolbar_elements<<{:icon=>:pencil,:text =>I18n.t('common.edit'),:path => edit_studium_path(@studium)}
|
||||
@toolbar_elements<<{:text=> I18n.t('common.delete'),:path => studium_path(@studium), :method=> :delete,:confirm=>"Sure?" }
|
||||
end
|
||||
def show
|
||||
@studium= Studium.find(params[:id])
|
||||
@text = 'Zu Semesteransicht wechseln'
|
||||
@path = studium_semesteransicht_path(@studium)
|
||||
|
||||
@studienphasen=[]
|
||||
[1, 2 ,3].each do |ph|
|
||||
modulgruppen_phase=@studium.modulgruppen.where(:phase=>ph)
|
||||
if modulgruppen_phase.count==1
|
||||
opts={:width=>12, :slice=>1}
|
||||
elsif modulgruppen_phase.count <= 4
|
||||
opts={:width=>6, :slice=>2}
|
||||
else
|
||||
opts={:width=>4, :slice=>3}
|
||||
end
|
||||
modulgruppen =[]
|
||||
modulgruppen_phase.each_slice(opts[:slice]) do |s|
|
||||
modulgruppen<<s #
|
||||
|
||||
end
|
||||
@studienphasen << {:modulgruppen=>modulgruppen, :phase => ph}.merge(opts)
|
||||
end
|
||||
|
||||
@toolbar_elements=[{:icon=>:plus, :hicon =>'icon-plus-sign' ,:text=> I18n.t('studien.new') , :path => new_studium_path(@studium) },
|
||||
{:icon=>:pencil, :hicon=>'icon-pencil',:text =>I18n.t('common.edit'),:path => edit_studium_path(@studium)},
|
||||
{:hicon=>'icon-remove-circle', :text=> I18n.t('common.delete'),:path => studium_path(@studium), :method=> :delete,:confirm=>"Sure?" }]
|
||||
|
||||
@toolbar_modulgruppen =[ {:hicon=>'icon-plus-sign', :text=> I18n.t('modulgruppe.new'), :path=>new_studium_modulgruppe_path(@studium)},
|
||||
{:hicon=>'icon-list', :text => I18n.t('modulgruppe.list'), :path=>modulgruppen_path}]
|
||||
|
||||
@topbar_elements = [ {:hicon=>'icon-list', :text=>I18n.t("studien.allestudien"), :path=>studien_path},
|
||||
{:text=>'Zur Semesteransicht wechseln', :path=>studium_semesteransicht_path(@studium)},
|
||||
{:newline=>true}]
|
||||
for i in Studium.all
|
||||
@topbar_elements << {:text=>i.name, :path=>studium_path(i)}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
def new
|
||||
@studium = Studium.new
|
||||
end
|
||||
|
||||
def edit
|
||||
@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)}
|
||||
@toolbar_elements=[{:text => I18n.t('studien.anzeigen') , :path => url_for(@studium) }]
|
||||
@toolbar_elements<<{:text =>I18n.t('studien.allestudien'),:path=>studien_path(@studium)}
|
||||
end
|
||||
|
||||
def create
|
||||
@studium = Studium.new(params[:studium])
|
||||
|
||||
respond_to do |format|
|
||||
if @studium.save
|
||||
@studium.batch_add_semester
|
||||
format.html { redirect_to url_for(@studium), notice: 'Studium was successfully created.' }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
@@ -57,19 +76,40 @@ class StudienController < ApplicationController
|
||||
|
||||
def update
|
||||
@studium = Studium.find(params[:id])
|
||||
|
||||
if @studium.update_attributes(params[:studium])
|
||||
redirect_to url_for(@studium), notice: 'Studium was successfully updated.'
|
||||
else
|
||||
render action: "edit"
|
||||
|
||||
end
|
||||
|
||||
if @studium.update_attributes(params[:studium])
|
||||
redirect_to url_for(@studium), notice: 'Studium was successfully updated.'
|
||||
else
|
||||
render action: "edit"
|
||||
|
||||
end
|
||||
end
|
||||
def semesteransicht
|
||||
@sem = 'true'
|
||||
@studium = Studium.find(params[:id])
|
||||
if @studium.nil?
|
||||
@studium = Studium.first
|
||||
end
|
||||
@text = 'Zu Modulgruppenansicht wechseln'
|
||||
@path = studium_path(@studium)
|
||||
@topbar_elements = [ {:hicon=>'icon-list', :text=>I18n.t("studien.allestudien"), :path=>studien_path},
|
||||
{:text=>'Zur Modulgruppenansicht wechseln', :path=>studium_path(@studium)},
|
||||
{:newline=>true}]
|
||||
for i in Studium.all
|
||||
@topbar_elements << {:text=>i.name, :path=>studium_semesteransicht_path(i)}
|
||||
end
|
||||
|
||||
|
||||
|
||||
@toolbar_elements = [ {:icon=>:plus, :hicon =>'icon-plus-sign' ,:text=> I18n.t('studien.new') , :path => new_studium_path(@studium) },
|
||||
{:icon=>:pencil, :hicon=>'icon-pencil',:text =>I18n.t('common.edit'),:path => edit_studium_path(@studium)},
|
||||
{:hicon=>'icon-remove-circle', :text=> I18n.t('common.delete'),:path => studium_path(@studium), :method=> :delete,:confirm=>"Sure?" }]
|
||||
end
|
||||
|
||||
def destroy
|
||||
@studium = Studium.find(params[:id])
|
||||
@studium.destroy
|
||||
redirect_to studien_url
|
||||
@studium = Studium.find(params[:id])
|
||||
@studium.destroy
|
||||
redirect_to studien_url
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user