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:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -15,8 +15,8 @@
|
||||
/log/*.log
|
||||
/tmp
|
||||
/config/initializers/devise.rb
|
||||
|
||||
/console
|
||||
/app/doc/*
|
||||
console
|
||||
/server
|
||||
/public/uploads/
|
||||
*~
|
||||
|
||||
|
||||
6
Gemfile
6
Gemfile
@@ -70,4 +70,8 @@ gem 'haml'
|
||||
#gem 'gollum'
|
||||
gem 'awesome_nested_set'
|
||||
gem 'annotate', ">=2.5.0"
|
||||
gem 'carrierwave'
|
||||
gem 'carrierwave'
|
||||
group :development, :test do
|
||||
gem 'factory_girl_rails'
|
||||
gem 'rspec-rails'
|
||||
end
|
||||
|
||||
19
Gemfile.lock
19
Gemfile.lock
@@ -56,9 +56,15 @@ GEM
|
||||
orm_adapter (~> 0.1)
|
||||
railties (~> 3.1)
|
||||
warden (~> 1.2.1)
|
||||
diff-lcs (1.2.4)
|
||||
erubis (2.7.0)
|
||||
execjs (1.4.0)
|
||||
multi_json (~> 1.0)
|
||||
factory_girl (4.2.0)
|
||||
activesupport (>= 3.0.0)
|
||||
factory_girl_rails (4.2.1)
|
||||
factory_girl (~> 4.2.0)
|
||||
railties (>= 3.0.0)
|
||||
formtastic (2.2.1)
|
||||
actionpack (>= 3.0)
|
||||
formtastic-bootstrap (2.0.0)
|
||||
@@ -123,6 +129,17 @@ GEM
|
||||
json (~> 1.4)
|
||||
ref (1.0.2)
|
||||
rolify (3.2.0)
|
||||
rspec-core (2.14.4)
|
||||
rspec-expectations (2.14.0)
|
||||
diff-lcs (>= 1.1.3, < 2.0)
|
||||
rspec-mocks (2.14.1)
|
||||
rspec-rails (2.14.0)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
railties (>= 3.0)
|
||||
rspec-core (~> 2.14.0)
|
||||
rspec-expectations (~> 2.14.0)
|
||||
rspec-mocks (~> 2.14.0)
|
||||
sass (3.2.5)
|
||||
sass-rails (3.2.6)
|
||||
railties (~> 3.2.0)
|
||||
@@ -165,6 +182,7 @@ DEPENDENCIES
|
||||
coffee-rails (~> 3.2.1)
|
||||
devise (~> 2.2.3)
|
||||
execjs (~> 1.4.0)
|
||||
factory_girl_rails
|
||||
formtastic (~> 2.2.1)
|
||||
formtastic-bootstrap
|
||||
git
|
||||
@@ -175,6 +193,7 @@ DEPENDENCIES
|
||||
paperclip (~> 3.4.0)
|
||||
rails (= 3.2.9)
|
||||
rolify
|
||||
rspec-rails
|
||||
sass-rails (~> 3.2.3)
|
||||
sqlite3
|
||||
therubyracer
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -19,4 +19,9 @@ class Beispiel < ActiveRecord::Base
|
||||
attr_accessible :desc, :name, :lva_id, :beispieldatei, :beispieldatei_cache
|
||||
belongs_to :lva
|
||||
mount_uploader :beispieldatei, BeispieldateiUploader
|
||||
validates :beispieldatei, :presence => true
|
||||
validates :name, :presence => true
|
||||
validates :lva_id, :presence => true
|
||||
validates :lva, :presence => true
|
||||
|
||||
end
|
||||
|
||||
@@ -17,39 +17,52 @@
|
||||
|
||||
class Lva < ActiveRecord::Base
|
||||
has_paper_trail # Versionsverfolgung
|
||||
attr_accessible :desc, :ects, :lvanr, :name, :stunden, :modul_ids
|
||||
|
||||
attr_accessible :desc, :ects, :lvanr, :name, :stunden, :modul_ids, :semester_ids
|
||||
has_and_belongs_to_many :modul # Gehört zu einem Modul
|
||||
has_and_belongs_to_many :semester # Gehört zu einem Semester( derzeit nicht implementiert)
|
||||
has_and_belongs_to_many :semester
|
||||
#Gehört zu einem Semester( derzeit nicht implementiert)
|
||||
has_many :beispiele , :class_name => "Beispiel"
|
||||
|
||||
translates :desc, :fallbacks_for_empty_translations => true
|
||||
|
||||
validates :lvanr,:format=>{ :with => /^[0-9][0-9][0-9]\.[0-9][0-9][0-9]$/} # , :uniqueness=>true # LVA-Nummer muss das Format 000.000 besitzen (uniqueness?) oder 000 für nicht existent
|
||||
|
||||
validates :lvanr,:format=>{ :with => /^[0-9][0-9][0-9]\.[0-9][0-9][0-9]$/}, :presence=>true, :uniqueness=>true # , :uniqueness=>true # LVA-Nummer muss das Format 000.000 besitzen (uniqueness?) oder 000 für nicht
|
||||
validates_presence_of :ects # ECTS vorhanden?
|
||||
validates_presence_of :name # Name Eingetragen?
|
||||
validates :name, :presence=>true
|
||||
validates :name, :uniqueness=>true# Name Eingetragen?
|
||||
validates_presence_of :stunden # Stunden Eingetragen?
|
||||
validates_presence_of :modul # Zugehöriges Modul eingetragen? (zumindest eines)
|
||||
private
|
||||
def add_semesters
|
||||
# Diese Methode fügt die Instanz automatisch zu allen Studien als "Ohne Semesterempfehlung" (Semester 0) zu, bei denen die Instanz im Studium noch nicht vorkommt.
|
||||
for m in self.modul
|
||||
for mg in m.modulgruppen # Über alle Module und alle Modulgruppen iterieren
|
||||
hits = mg.studium.semester.all.map{|x| x.lvas}.collect{|x| x.find_by_id(self.id)}.compact # Alle einträge in allen semestern mit gleicher LVa-ID suchen und alle nils entfernen
|
||||
|
||||
##
|
||||
# Lade Daten aus TISS und füge diese in die Datenbank ein.
|
||||
def load_tissdata
|
||||
url= "https://tiss.tuwien.ac.at/api/course/"+ self.lvanr.to_s+"-2012W"
|
||||
begin
|
||||
@hash=Hash.from_xml(open(url).read)["tuvienna"]
|
||||
@person=[]
|
||||
if @hash["course"]["lecturers"]["oid"].is_a? String
|
||||
@person = @hash["course"]["lecturers"]["oid"]
|
||||
else
|
||||
@hash["course"]["lecturers"]["oid"].each do |pid|
|
||||
@person << Hash.from_xml(open("https://tiss.tuwien.ac.at/adressbuch/adressbuch/person_via_oid/" + pid.to_s + ".xml").read)["tuvienna"]["person"]
|
||||
if hits.empty? # wurde gar kein eintrag gefunden ?
|
||||
self.semester << mg.studium.semester.where(:nummer => 0) # auf nummer null eintragen
|
||||
end
|
||||
end
|
||||
end
|
||||
rescue OpenURI::HTTPError => e
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
private
|
||||
|
||||
##
|
||||
# Lade Daten aus TISS und füge diese in die Datenbank ein.
|
||||
def load_tissdata
|
||||
url= "https://tiss.tuwien.ac.at/api/course/"+ self.lvanr.to_s+"-2012W"
|
||||
begin
|
||||
@hash=Hash.from_xml(open(url).read)["tuvienna"]
|
||||
@person=[]
|
||||
if @hash["course"]["lecturers"]["oid"].is_a? String
|
||||
@person = @hash["course"]["lecturers"]["oid"]
|
||||
else
|
||||
@hash["course"]["lecturers"]["oid"].each do |pid|
|
||||
@person << Hash.from_xml(open("https://tiss.tuwien.ac.at/adressbuch/adressbuch/person_via_oid/" + pid.to_s + ".xml").read)["tuvienna"]["person"]
|
||||
end
|
||||
end
|
||||
rescue OpenURI::HTTPError => e
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ class Modul < ActiveRecord::Base
|
||||
has_and_belongs_to_many :lvas
|
||||
has_and_belongs_to_many :modulgruppen
|
||||
|
||||
|
||||
validates :modulgruppen, :presence=>true # Ein Modul muss zu einer Modulgruppe gehören
|
||||
validates :name, :presence=>true # Ein Modul muss einen Namen haben
|
||||
translates :desc,:depend,:name, :versioning =>true, :fallbacks_for_empty_translations => true
|
||||
|
||||
@@ -21,8 +21,8 @@ class Modulgruppe < ActiveRecord::Base
|
||||
|
||||
validates :studium_id, :presence => true # Bei der Abfrage ist student_id entscheidend
|
||||
validates :studium, :presence => true # Wird gesetzt, um das richtige Feld zu melden bei Fehlern
|
||||
validates :name, :uniqueness =>{:scope => :studium}, :presence=>true # Funktioniert leider nicht
|
||||
validates :name, :uniqueness =>{:scope => :studium_id}, :presence=>true # Pro Studium darf ein Name nur einmal vorkommen
|
||||
validates :phase, :inclusion => {:in => [1, 2, 3, 4]}
|
||||
validates :typ, :inclusion => {:in => ["Pflicht","Vertiefungspflicht","Wahl"] }
|
||||
translates :name,:desc, :versioning =>true,:fallbacks_for_empty_translations => true
|
||||
translates :desc, :versioning =>true,:fallbacks_for_empty_translations => true
|
||||
end
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: semesters
|
||||
@@ -12,6 +13,9 @@
|
||||
#
|
||||
|
||||
class Semester < ActiveRecord::Base
|
||||
attr_accessible :name, :nummer, :ssws, :lva_ids
|
||||
has_and_belongs_to_many :lvas
|
||||
attr_accessible :name, :nummer, :ss, :ws
|
||||
belongs_to :studium, :foreign_key => "studium_id"
|
||||
validates :name, :presence => true
|
||||
validates :nummer, :presence => true
|
||||
end
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: studien
|
||||
@@ -10,14 +11,36 @@
|
||||
# typ :string(255)
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
|
||||
class Studium < ActiveRecord::Base
|
||||
attr_accessible :desc, :name, :typ, :zahl
|
||||
has_many :modulgruppen, inverse_of: :studium, :class_name => "Modulgruppe"
|
||||
has_many :modulgruppen, inverse_of: :studium, :class_name => "Modulgruppe", :dependent => :destroy
|
||||
has_many :semester, :dependent => :destroy
|
||||
|
||||
validates :typ, :inclusion => {:in => ["Bachelor","Master"] }
|
||||
validates :name, :uniqueness => true, :presence=>true
|
||||
validates :zahl, :uniqueness => true, :presence=>true
|
||||
validates :zahl, :presence=>true, :format=>{:with=>/^0(33|66)[0-9]{3}$/}, :uniqueness => true
|
||||
translates :desc,:shortdesc, :versioning =>true,:fallbacks_for_empty_translations => true
|
||||
|
||||
def batch_add_semester
|
||||
# Semester automatisch zu Studien hinzufügen
|
||||
if self.typ == "Bachelor"
|
||||
length = 6
|
||||
else
|
||||
length = 4
|
||||
end
|
||||
for i in 1..length
|
||||
semester =Semester.new()
|
||||
semester.name = i.to_s + '. ' + self.name
|
||||
semester.nummer = i
|
||||
semester.ssws = ((i % 2 == 0) ? "SS" : "WS")
|
||||
semester.save
|
||||
self.semester << semester
|
||||
end
|
||||
semester = Semester.new()
|
||||
semester.name = 'Ohne Zuordnung (' + self.name + ')'
|
||||
semester.nummer = 0
|
||||
semester.ssws = "WS"
|
||||
semester.save
|
||||
self.semester << semester
|
||||
end
|
||||
end
|
||||
|
||||
19
app/views/beispiele/_beispiel_list.html.erb
Normal file
19
app/views/beispiele/_beispiel_list.html.erb
Normal file
@@ -0,0 +1,19 @@
|
||||
<div class="beispiel">
|
||||
<p>
|
||||
<b>
|
||||
<%=link_to beispiel.name, beispiel.beispieldatei.url%>
|
||||
</b>
|
||||
<p>
|
||||
Beschreibung:
|
||||
<p>
|
||||
<%= beispiel.desc %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
LVA: <%=link_to beispiel.lva.name, lva_path(beispiel.lva.id)%>
|
||||
</p>
|
||||
|
||||
<%= link_to 'Show', beispiel %>
|
||||
<%= link_to 'Edit', edit_beispiel_path(beispiel) %>
|
||||
<%= link_to 'Destroy', beispiel, method: :delete, data: { confirm: 'Are you sure?' } %>
|
||||
</div class="beispiel">
|
||||
@@ -4,7 +4,7 @@
|
||||
<%= f.input :desc %>
|
||||
<%= f.file_field :beispieldatei %>
|
||||
<%= f.hidden_field :beispieldatei_cache %>
|
||||
<%= f.input :lva, :as=>:radio, :collection => Lva.all%>
|
||||
<%= f.input :lva, :as=>:select, :collection => Lva.all%>
|
||||
<% end %>
|
||||
|
||||
<%= f.actions do %>
|
||||
|
||||
@@ -1,25 +1,10 @@
|
||||
<h1>Listing beispiele</h1>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Desc</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<h1><%= I18n.t("beispiele.list")</h1>
|
||||
<ul>
|
||||
<% @beispiele.each do |beispiel| %>
|
||||
<tr>
|
||||
<td><%= beispiel.name %></td>
|
||||
<td><%= beispiel.desc %></td>
|
||||
<td><%= link_to 'Show', beispiel %></td>
|
||||
<td><%= link_to 'Edit', edit_beispiel_path(beispiel) %></td>
|
||||
<td><%= link_to 'Destroy', beispiel, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<li>
|
||||
<%= render :partial=> "beispiele/beispiel_list", :object => beispiel, :as=>:beispiel%>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<%= link_to 'New Beispiel', new_beispiel_path %>
|
||||
|
||||
11
app/views/layouts/_link_all.html.erb
Executable file
11
app/views/layouts/_link_all.html.erb
Executable file
@@ -0,0 +1,11 @@
|
||||
|
||||
<ul class="breadcrumb">
|
||||
<li> <%= link_to_unless_current '<i class="icon-list"></i>'.html_safe+ I18n.t("studien.allestudien"), studien_path,:raw=>true %>
|
||||
<span class="divider">/</span></li>
|
||||
|
||||
<li> <%= link_to_unless_current '<i class="icon-list"></i>'.html_safe+ I18n.t("modul.list"), moduls_path,:raw=>true %>
|
||||
<span class="divider">/</span></li>
|
||||
<li> <%= link_to_unless_current '<i class="icon-list"></i>'.html_safe+ I18n.t("lva.list"), lvas_path,:raw=>true %>
|
||||
<span class="divider">/</span></li>
|
||||
</ul>
|
||||
|
||||
7
app/views/layouts/_pretty_toolbar.html.erb
Normal file
7
app/views/layouts/_pretty_toolbar.html.erb
Normal file
@@ -0,0 +1,7 @@
|
||||
<% toolbar_elements = !pretty_toolbar.nil? ? pretty_toolbar : @toolbar_elements %>
|
||||
<span class="label"><%= I18n.t("common.actions")%></span>
|
||||
<div class="btn-group">
|
||||
<% toolbar_elements.each do |t| %>
|
||||
<%= link_to '<i class="'.html_safe+ t[:hicon].to_s.html_safe + '"></i>'.html_safe+t[:text], t[:path], :method=>t[:method], :confirm=>t[:confirm].to_s, :data=>t[:data], :class=>"btn" %>
|
||||
<% end %>
|
||||
</div>
|
||||
11
app/views/layouts/_topbar.html.erb
Executable file
11
app/views/layouts/_topbar.html.erb
Executable file
@@ -0,0 +1,11 @@
|
||||
<% topbar = !topbar.nil? ? topbar : @topbar_elements %>
|
||||
<ul class="breadcrumb">
|
||||
<% topbar.each do |tb| %>
|
||||
<% if tb[:newline]%>
|
||||
<br>
|
||||
<% else %>
|
||||
<li>
|
||||
<%= link_to_unless_current '<i class="'.html_safe + tb[:hicon].to_s.html_safe + '"></i>'.html_safe+ tb[:text].html_safe, tb[:path] %><span class="divider">/</span></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
@@ -1,5 +1,6 @@
|
||||
<%= semantic_form_for @lva do |f| %>
|
||||
<%= f.inputs do %>
|
||||
<%= f.input :semester, :collection=>Semester.all.sort_by{|n| [:name]}%>
|
||||
<%= f.input :modul %>
|
||||
<%= f.input :name %>
|
||||
<%= f.input :ects %>
|
||||
|
||||
28
app/views/lvas/_lva.html.erb
Executable file
28
app/views/lvas/_lva.html.erb
Executable file
@@ -0,0 +1,28 @@
|
||||
<% @lva.modul.each do |modul| %>
|
||||
<% modul.modulgruppen.each do |g| %>
|
||||
<ul class="breadcrumb">
|
||||
<li><%= link_to g.studium.name , studium_path(g.studium)%>
|
||||
<span class="divider"></span></li>
|
||||
<li><%= link_to g.name , modulgruppe_path(g)%><span class="divider">/</span></li>
|
||||
<li><%= link_to modul.name , modul_path(modul)%></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
<p id="notice"><%= notice %></p>
|
||||
<p>
|
||||
<%= @lva.lvanr %>
|
||||
<b><%= @lva.name %> <%= @lva.ects %> ECTS/ <%= @lva.stunden %> Std</b>
|
||||
|
||||
</p>
|
||||
<p>
|
||||
<%= @lva.desc %>
|
||||
</p>
|
||||
<ul>
|
||||
<% @lva.beispiele.each do |b|%>
|
||||
|
||||
<li><%= render b%></li>
|
||||
|
||||
<% end %>
|
||||
</ul>
|
||||
<%= toolbar_html(@toolbar_elements) %>
|
||||
10
app/views/lvas/_lva_semester.html.erb
Executable file
10
app/views/lvas/_lva_semester.html.erb
Executable file
@@ -0,0 +1,10 @@
|
||||
|
||||
<p class="lva_semester">
|
||||
<b><%= link_to lva.name, lva_path(lva)%></b><br>
|
||||
Module: /<% lva.modul.each do |m| %> <%= link_to m.name + ' / ', modul_path(m) unless m.modulgruppen.map{|x| x.studium}.index(@studium).nil? && !@studium.nil? %><% end %>
|
||||
<br>
|
||||
<%="LVa-Nr " + lva.lvanr.to_s %>
|
||||
<%= lva.ects %> ECTS / <%= lva.stunden %> Std <% " / " + lva.beispiele.count.to_s + " Beispiele"%> <br>
|
||||
<%= link_to "Edit", edit_lva_path(lva) %> | <%= link_to "Beispiel hinzufügen", new_beispiel_path(:lva_id=>lva.id) %>
|
||||
</p class="lva_semester">
|
||||
<% #toolbar_html(@toolbar_elements) %>
|
||||
@@ -1,31 +1,8 @@
|
||||
<h1>Listing lvas</h1>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Desc</th>
|
||||
<th>Ects</th>
|
||||
<th>Lvanr</th>
|
||||
<th>Stunden</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<% @lvas.each do |lva| %>
|
||||
<tr>
|
||||
<td><%= lva.name %></td>
|
||||
<td><%= lva.desc %></td>
|
||||
<td><%= lva.ects %></td>
|
||||
<td><%= lva.lvanr %></td>
|
||||
<td><%= lva.stunden %></td>
|
||||
<td><%= link_to 'Show', lva %></td>
|
||||
<td><%= link_to 'Edit', edit_lva_path(lva) %></td>
|
||||
<td><%= link_to 'Destroy', lva, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
||||
<%= link_to 'New Lva', new_lva_path %>
|
||||
<%= render :partial=>'layouts/topbar', :object=>@tb %>
|
||||
<h1><%= I18n.t("lva.list")%></h1>
|
||||
<ul>
|
||||
<% @lvas.each do |l| %>
|
||||
<li><%= render :partial => 'lvas/lva_semester', :locals=> {:lva => l} %>
|
||||
<%end%>
|
||||
</ul>
|
||||
<%= render 'layouts/pretty_toolbar' %>
|
||||
|
||||
@@ -1,30 +1,36 @@
|
||||
<% @lva.modul.each do |modul| %>
|
||||
<% modul.modulgruppen.each do |g| %>
|
||||
<ul class="breadcrumb">
|
||||
<li><%= link_to g.studium.name , studium_path(g.studium)%>
|
||||
<span class="divider">/</span></li>
|
||||
<li><%= link_to g.name , modulgruppe_path(g)%><span class="divider">/</span></li>
|
||||
<li><%= link_to modul.name , modul_path(modul)%></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
<%= render 'layouts/topbar'%>
|
||||
<p id="notice"><%= notice %></p>
|
||||
<p>
|
||||
<%= @lva.lvanr %>
|
||||
<b><%= @lva.name %> <%= @lva.ects %> ECTS/ <%= @lva.stunden %> Std</b>
|
||||
|
||||
|
||||
<h2><%= @lva.lvanr %><%= @lva.name %> <%= @lva.ects %> ECTS/ <%= @lva.stunden %> Std</h2>
|
||||
|
||||
</p>
|
||||
<p>
|
||||
|
||||
<p><h4>Beschreibung</h4>
|
||||
<%= @lva.desc %>
|
||||
|
||||
<%= link_to "Beispiel neu" , new_beispiel_path(:lva_id=>@lva.id) %>
|
||||
</p>
|
||||
<h4>Beispiele</h4>
|
||||
<ul>
|
||||
<% @lva.beispiele.each do |b|%>
|
||||
<% @lva.beispiele.each do |b|%>
|
||||
|
||||
<li><%= render b%></li>
|
||||
<li><%= render b%></li>
|
||||
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
<%= toolbar_html(@toolbar_elements) %>
|
||||
<h4>Module</h4>
|
||||
<ul>
|
||||
<% @lva.modul.each do |modul| %>
|
||||
<li><b><%= link_to modul.name , modul_path(modul)%></b>
|
||||
<ul>
|
||||
<% modul.modulgruppen.each do |g| %>
|
||||
|
||||
<li><%= link_to g.studium.name , studium_semesteransicht_path(g.studium)%> (<%=link_to g.name, modulgruppe_path(g)%>)</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<% end %>
|
||||
</ul>
|
||||
<%= render 'layouts/pretty_toolbar' %>
|
||||
|
||||
@@ -1,29 +1,9 @@
|
||||
<h1><%= I18n.t("modulgruppe.show.title")%></h1>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Type</th>
|
||||
<th>Phase</th>
|
||||
<th>Studium</th>
|
||||
<th>Name</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<% @modulgruppen.sort_by{|n| n[:name]}.each do |modulgruppe| %>
|
||||
<tr>
|
||||
<td><%= modulgruppe.typ %></td>
|
||||
<td><%= modulgruppe.phase %></td>
|
||||
<td><%= modulgruppe.studium.name unless modulgruppe.studium.nil? %></td>
|
||||
<td><%= modulgruppe.name %></td>
|
||||
<td><%= link_to 'Show', modulgruppe %></td>
|
||||
<td><%= link_to 'Edit', edit_modulgruppe_path(modulgruppe) %></td>
|
||||
<td><%= link_to 'Destroy', modulgruppe, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<%= render modulgruppe%>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
<% if !@studium.nil? %>
|
||||
<%= link_to 'New Modulgruppe', new_studium_modulgruppe_path(@studium) %>
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
|
||||
<%= semantic_form_for @modul do |f| %>
|
||||
<%= f.inputs do %>
|
||||
<%= f.input :modulgruppen,:as => :select, :collection => Hash[Modulgruppe.all.map{|m| [m.studium.name + " " + m.name,m.id]}] %>
|
||||
<% # f.input :modulgruppen,:as => :select, :collection => Hash[Modulgruppe.all.map{|m| [m.studium.name + " " + m.name,m.id]}] %>
|
||||
<%= f.input :modulgruppen %>
|
||||
<%= f.input :name ,:hint=>true%>
|
||||
<%= f.input :desc, :as=>:tinymce_text %>
|
||||
<%= f.input :depend %>
|
||||
|
||||
32
app/views/moduls/_lang.html.erb
Executable file
32
app/views/moduls/_lang.html.erb
Executable file
@@ -0,0 +1,32 @@
|
||||
<div style="border: solid 1px; padding:2px"><p>
|
||||
<b><%=
|
||||
if modul.name.nil?
|
||||
name=""
|
||||
else
|
||||
name=modul.name
|
||||
end
|
||||
link_to "Modul "+name , modul_path(modul) %> </b>
|
||||
</p>
|
||||
<p>
|
||||
<%= raw(modul.desc) %>
|
||||
</p>
|
||||
LVAs:
|
||||
|
||||
<ul>
|
||||
|
||||
<% modul.lvas.each do |lv| %>
|
||||
<li>
|
||||
<%= link_to lv.name.to_s, lva_path(lv.id) %>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
</ul>
|
||||
|
||||
Modulgruppen:
|
||||
<ul>
|
||||
<% modul.modulgruppen.each do |mg| %>
|
||||
<li> <%=mg.name%> (<%= mg.studium.name unless mg.studium.nil?%>)</li>
|
||||
<%end%>
|
||||
</ul>
|
||||
<% # @toolbar_elements << {:icon=>:pencil,:text=>I18n.t("common.edit"),:path=> edit_modul_path(modul)} %>
|
||||
</div>
|
||||
@@ -1,39 +1,8 @@
|
||||
<h1><%= I18n.t("modul.show.title") %></h1>
|
||||
<%= render 'layouts/topbar' %>
|
||||
<h1><%= I18n.t("modul.list") %></h1>
|
||||
|
||||
<table class="table" >
|
||||
<tr>
|
||||
<th>Modulgruppe (Studium)</th>
|
||||
<th>Name</th>
|
||||
<th>Desc</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<%= render :partial=>'moduls/lang', :collection=>@moduls, :as=>:modul%>
|
||||
|
||||
<% @moduls.sort_by{|n| n[:name]}.each do |modul| %>
|
||||
<tr>
|
||||
<td>
|
||||
<%modul.modulgruppen.sort_by{|n| n[:name]}.each do |m|%>
|
||||
|
||||
|
||||
<%=m.name unless m.nil? %> (<%=m.studium.name unless m.studium.nil? %>)
|
||||
<!-- Modulgruppenname falls existiert (Studium falls existiert) -->
|
||||
<br>
|
||||
<% end %>
|
||||
|
||||
</td>
|
||||
|
||||
<td><%= modul.name %></td>
|
||||
<td><%= modul.desc %></td>
|
||||
<td><%= link_to 'Show', modul_path(modul) %></td>
|
||||
<td><%= link_to 'Edit', edit_modul_path(modul) %></td>
|
||||
<td><%= link_to 'Destroy', [modul], method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
<% #if !@studium.nil? %>
|
||||
<%= link_to 'New Modul', new_modul_path() %>
|
||||
<% #end%>
|
||||
<br>
|
||||
<%= render 'layouts/pretty_toolbar'%>
|
||||
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
|
||||
<% @modul.modulgruppen.each do |g| %>
|
||||
<ul class="breadcrumb">
|
||||
<li>
|
||||
<%= link_to g.studium.name , studium_path(g.studium)%> <span class="divider">/</span></li>
|
||||
<li><%= link_to g.name , modulgruppe_path(g)%></li>
|
||||
<%end%>
|
||||
</ul>
|
||||
|
||||
<%= render 'layouts/topbar'%>
|
||||
<%= render 'layouts/topbar', :topbar=>@tb%>
|
||||
<p id="notice"><%= notice %></p>
|
||||
<%= render @modul %>
|
||||
|
||||
|
||||
<%= link_to 'Add LVA', new_lva_path(:modul_id =>@modul.id) %>
|
||||
<%= link_to '<i class="icon-pencil"></i>'.html_safe+ I18n.t("common.edit") , edit_modul_path(@modul) %>
|
||||
<%= link_to "Loeschen", [@modul],:method=>:delete ,:data => {:confirm =>"Are you sure" } %>
|
||||
<%= render 'layouts/pretty_toolbar' %>
|
||||
<% # link_to 'Add LVA', %>
|
||||
<% # link_to '<i class="icon-pencil"></i>'.html_safe+ I18n.t("common.edit") , edit_modul_path(@modul) %>
|
||||
<% # link_to "Loeschen", [@modul],:method=>:delete ,:data => {:confirm =>"Are you sure" } %>
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
<%= f.inputs do %>
|
||||
<%= f.input :name %>
|
||||
<%= f.input :nummer %>
|
||||
<%= f.input :ws %>
|
||||
<%= f.input :ss %>
|
||||
<%= f.input :ssws %>
|
||||
<%= f.input :lvas %>
|
||||
<% end %>
|
||||
|
||||
<%= f.actions do %>
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
<tr>
|
||||
<td><%= semester.name %></td>
|
||||
<td><%= semester.nummer %></td>
|
||||
<td><%= semester.ws %></td>
|
||||
<td><%= semester.ss %></td>
|
||||
<td><%= semester.ssws %></td>
|
||||
<td><% %></td>
|
||||
<td><%= link_to 'Show', semester %></td>
|
||||
<td><%= link_to 'Edit', edit_semester_path(semester) %></td>
|
||||
<td><%= link_to 'Destroy', semester, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
|
||||
@@ -1,25 +1,20 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<p>
|
||||
<b>Name:</b>
|
||||
<%= @semester.name %>
|
||||
<b>Name:</b> <%= @semester.name %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Nummer:</b>
|
||||
<%= @semester.nummer %>
|
||||
<b>Nummer:</b> <%= @semester.nummer %>
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
<b>Ws:</b>
|
||||
<%= @semester.ws %>
|
||||
<b>WS/SS?:</b> <%= @semester.ssws %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Ss:</b>
|
||||
<%= @semester.ss %>
|
||||
<%= render :partial =>'lvas/lva_semester', :collection=>@semester.lvas, :as=>:lva%>
|
||||
</p>
|
||||
|
||||
|
||||
<%= link_to 'Edit', edit_semester_path(@semester) %> |
|
||||
<%= link_to 'Back', semesters_path %>
|
||||
|
||||
20
app/views/studien/_navigation.html.erb
Executable file
20
app/views/studien/_navigation.html.erb
Executable file
@@ -0,0 +1,20 @@
|
||||
|
||||
<ul class="breadcrumb">
|
||||
<li> <%= link_to '<i class="icon-list"></i>'.html_safe+ I18n.t("studien.allestudien"), studien_path,:raw=>true %>
|
||||
<span class="divider">/</span></li>
|
||||
<li> <%= link_to @text, @path%>
|
||||
<span class="divider">/</span></li>
|
||||
<br>
|
||||
<% Studium.all.each do |s| %>
|
||||
<li>
|
||||
<% if @sem=='true' %>
|
||||
<%= link_to_unless_current s.name, studium_semesteransicht_path(s) %>
|
||||
<% else %>
|
||||
<%= link_to_unless_current s.name, studium_path(s) %>
|
||||
<% end %>
|
||||
<span class="divider">/</span></li>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
</ul>
|
||||
|
||||
9
app/views/studien/_studium.html.erb
Normal file
9
app/views/studien/_studium.html.erb
Normal file
@@ -0,0 +1,9 @@
|
||||
<div class="studium">
|
||||
<h2><%= link_to studium.name + " " + studium.zahl.to_s, studium_semesteransicht_path(studium)%></h2>
|
||||
<ul>
|
||||
<li><b><%= studium.typ%> </b></li>
|
||||
<li><b>Beschreibung:</b><br>
|
||||
<%= !(studium.desc.to_s == "") ? studium.desc.html_safe : I18n.t("keine.beschreibung")%></li>
|
||||
<li><%=link_to "Link zur Modulgruppenansicht",studium_path(studium) %> </li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -1,6 +1,6 @@
|
||||
<h1>Editing studium</h1>
|
||||
<h1><%= I18n.t("studien.edit")%></h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Show', @studium %> |
|
||||
<%= link_to 'Back', studien_path %>
|
||||
<%= link_to 'Back', studien_path %>
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
<%= render 'layouts/topbar' %>
|
||||
<h1><%= I18n.t("studien.list") %></h1>
|
||||
|
||||
|
||||
<% @studien.sort_by{|z| z[:zahl]}.each do |studium| %>
|
||||
|
||||
|
||||
<h2><%= link_to studium.zahl + " "+ studium.typ+" " + studium.name, studium_path(studium) %></h2>
|
||||
|
||||
<ul>
|
||||
<li><%= render studium%></li>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
|
||||
<br />
|
||||
<% link_to I18n.t("studien.new"), new_studium_path %>
|
||||
<% link_to I18n.t("modulgruppe.show"), modulgruppen_path %>
|
||||
<%= toolbar_html(@toolbar_elements) %>
|
||||
<br>
|
||||
<%= render :partial=>'layouts/pretty_toolbar'%>
|
||||
<% #toolbar_html(@toolbar_elements) %>
|
||||
|
||||
17
app/views/studien/semesteransicht.html.erb
Normal file
17
app/views/studien/semesteransicht.html.erb
Normal file
@@ -0,0 +1,17 @@
|
||||
<%= render :partial=>'layouts/topbar'%>
|
||||
|
||||
<h1><%= @studium.typ %> <%= @studium.name %> (<%= @studium.zahl %>)</h1>
|
||||
<%= raw(@studium.desc) %>
|
||||
<% @studium.semester.each do |sem| %>
|
||||
<div class="row-fluid">
|
||||
<h2><%= sem.name %></h2>
|
||||
<div class="span<%= sem[:width]%> min-width:13em;">
|
||||
<ul>
|
||||
<% sem.lvas.sort_by{|n| n[:name]}.each do |l| %>
|
||||
<li><%= render :partial=>'lvas/lva_semester', :locals =>{:lva => l}%>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= render :partial=>'layouts/pretty_toolbar', :locals=>{:elements=>@toolbar_elements} %>
|
||||
50
app/views/studien/show.html.erb
Executable file → Normal file
50
app/views/studien/show.html.erb
Executable file → Normal file
@@ -1,33 +1,23 @@
|
||||
<%= render 'layouts/topbar'%>
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<%= link_to '<i class="icon-list"></i>'.html_safe+ I18n.t("studien.allestudien"), studien_path,:raw=>true %>
|
||||
|
||||
<h1><%= @studium.typ %> <%= @studium.name %> (<%= @studium.zahl %>)</h1>
|
||||
</div>
|
||||
<%= raw(@studium.desc) %>
|
||||
<% @studienphasen.each do |sp| %>
|
||||
<% sp[:modulgruppen].each do |row| %>
|
||||
<div class="row-fluid">
|
||||
<% row.each do |modulgruppe| %>
|
||||
<div class="span<%= sp[:width]%> min-width:13em;">
|
||||
<%= render modulgruppe %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="row-fluid">
|
||||
<p id="notice"><%= notice %></p>
|
||||
<h1><%= @studium.typ %> <%= @studium.name %> (<%= @studium.zahl %>)</h1>
|
||||
</div>
|
||||
<div>
|
||||
<%= raw(@studium.desc) %>
|
||||
<% @studienphasen.each do |sp| %>
|
||||
<% sp[:modulgruppen].each do |row| %>
|
||||
<div class="row-fluid">
|
||||
<% row.each do |modulgruppe| %>
|
||||
<div class="span<%= sp[:width]%> min-width:13em;">
|
||||
<%= render modulgruppe %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
||||
<div class="row-fluid">
|
||||
<span class="span12">
|
||||
<%= link_to '<i class="icon-plus-sign"></i>'.html_safe+I18n.t("studien.newmodulgroup"), new_studium_modulgruppe_path(@studium),:class=>"btn" %> |
|
||||
<%= link_to '<i class="icon-pencil"></i>'.html_safe+I18n.t("common.edit"), edit_studium_path(@studium) ,:class=>"btn"%>
|
||||
<%= link_to 'Destroy', @studium, method: :delete, data: { confirm: 'Are you sure?' } %>
|
||||
</span>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= render :partial=>'layouts/pretty_toolbar', :object=>@toolbar_modulgruppen %>
|
||||
</div>
|
||||
<%= render 'layouts/pretty_toolbar' %>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<%= toolbar_html(@toolbar_elements) %>
|
||||
|
||||
@@ -10,20 +10,26 @@ de:
|
||||
list: "Studien der Fakultät Elektrotechnik"
|
||||
anzeigen: "Studium anzeigen"
|
||||
new: "Neues Studium"
|
||||
newmodulgroup: "Neue Modulgruppe"
|
||||
allestudien: "Alle Studien"
|
||||
loeschen: "Dieses Studium löschen"
|
||||
edit: "Studium bearbeiten"
|
||||
modul:
|
||||
edit:
|
||||
title: "Bearbeite Modul"
|
||||
show:
|
||||
title: "Auflistung aller Module"
|
||||
link: "Alle Module auflisten"
|
||||
|
||||
edit: "Modul bearbeiten"
|
||||
list: "Alle Module"
|
||||
add: "Neues Modul"
|
||||
keine:
|
||||
beschreibung: "Keine Beschreibung vorhanden"
|
||||
lva:
|
||||
add: "Lva hinzufügen"
|
||||
list: "Alle Lvas"
|
||||
semester:
|
||||
ohne: "Ohne Semesterzuordnung"
|
||||
modulgruppe:
|
||||
typ: "Typ"
|
||||
addmodul: "Neues Modul hinzufügen"
|
||||
studium: "Studium"
|
||||
new: "Neue Modulgruppe"
|
||||
list: "Alle Modulgruppen auflisten"
|
||||
show:
|
||||
title: "Auflistung aller Modulgruppen"
|
||||
link: "Modulgruppen auflisten"
|
||||
@@ -85,4 +91,17 @@ de:
|
||||
blank: "Geben Sie die Stunden der LVA an"
|
||||
lvanr:
|
||||
invalid: "Geben Sie eine LVA-Nummer in richtigem Format an. Wenn die LVA noch keine Nummer hat, so geben sie 000 an."
|
||||
studium:
|
||||
attributes:
|
||||
zahl:
|
||||
blank: "Geben Sie die Studienkennzahl an"
|
||||
invalid: "Die eingegebene Form stimmt nicht (beginnend mit 033 oder 066, dann 3 Stellen)"
|
||||
taken: "Die Kennzahl wird bereits verwendet"
|
||||
name:
|
||||
blank: "Geben Sie den Namen des Studiums ein"
|
||||
taken: "Der Name ist bereits vergeben"
|
||||
typ:
|
||||
inclusion: 'Wählen Sie "Bachelor" oder "Master" aus'
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,42 +1,41 @@
|
||||
Fetsite::Application.routes.draw do
|
||||
|
||||
devise_for :users
|
||||
resources :home, :only=>[:index]
|
||||
#get 'home',:controller=>home,:action=>:index,:as=>"home_index"
|
||||
scope '(:locale)/admin' do
|
||||
resources :users
|
||||
get 'config',:controller=>:config,:action=>:index , :as => 'config'
|
||||
get 'config/get_git_update',:controller=>:config,:action=>:get_git_update, :as=>'config_getgitupdate'
|
||||
get 'config/get_git_update',:controller=>:config,:action=>:get_git_update
|
||||
end
|
||||
|
||||
devise_for :users
|
||||
|
||||
|
||||
|
||||
devise_for :users
|
||||
resources :home, :only=>[:index]
|
||||
#get 'home',:controller=>home,:action=>:index,:as=>"home_index"
|
||||
scope '(:locale)/admin' do
|
||||
resources :users
|
||||
get 'config',:controller=>:config,:action=>:index , :as => 'config'
|
||||
get 'config/get_git_update',:controller=>:config,:action=>:get_git_update, :as=>'config_getgitupdate'
|
||||
get 'config/get_git_update',:controller=>:config,:action=>:get_git_update
|
||||
|
||||
|
||||
end
|
||||
|
||||
devise_for :users
|
||||
|
||||
resources :pages, :except => [:index] do
|
||||
member do
|
||||
post 'preview'
|
||||
end
|
||||
end
|
||||
get 'pages', :to =>'pages#show'
|
||||
scope '(:locale)' do
|
||||
resources :pages, :except => [:index] do
|
||||
member do
|
||||
post 'preview'
|
||||
end
|
||||
end
|
||||
get 'pages', :to =>'pages#show'
|
||||
scope '(:locale)' do
|
||||
|
||||
resources :studien, :only=>[:show,:new,:edit,:update,:destroy]
|
||||
resources :modulgruppen,:only =>[:create,:index]
|
||||
|
||||
resources :studien,:except=>[:show,:new,:edit,:update,:destroy], :shallow=>true do
|
||||
resources :modulgruppen, :path => "(:locale)/modulgruppen"
|
||||
|
||||
end
|
||||
get 'studien/:id/semesteransicht', :controller=>:studien, :action=>:semesteransicht, :as=>'studium_semesteransicht'
|
||||
resources :semesters
|
||||
resources :moduls
|
||||
resources :lvas
|
||||
resources :neuigkeiten
|
||||
get 'rubriken/verwalten', :controller=>:rubriken, :action=>:alle_verwalten, :as=>'alle_verwalten_rubrik'
|
||||
|
||||
|
||||
resources :rubriken do
|
||||
resources :neuigkeiten, :only=>[:new, :show]
|
||||
resources :neuigkeiten, :only=>[:new, :show]
|
||||
end
|
||||
put 'rubriken/(:id)/addmoderator',:controller=>:rubriken,:action=>:addmoderator
|
||||
get 'rubriken/:id/verwalten',:controller=>:rubriken,:action=>:verwalten, :as=>'verwalten_rubrik'
|
||||
@@ -44,7 +43,7 @@ scope '(:locale)' do
|
||||
get 'home/dev', :controller=>:home, :action=>:dev, :as=>'home_dev'
|
||||
resources :beispiele
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# The priority is based upon order of creation:
|
||||
# first created -> highest priority.
|
||||
@@ -96,7 +95,7 @@ scope '(:locale)' do
|
||||
# You can have the root of your site routed with "root"
|
||||
# just remember to delete public/index.html.
|
||||
|
||||
root :to => 'home#index'
|
||||
root :to => 'home#index'
|
||||
|
||||
# See how all your routes lay out with "rake routes"
|
||||
|
||||
|
||||
14
db/migrate/20130729085446_create_lva_semester_join_table.rb
Normal file
14
db/migrate/20130729085446_create_lva_semester_join_table.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
class CreateLvaSemesterJoinTable < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :lvas_semesters, :id=>false do |t|
|
||||
t.integer :lva_id
|
||||
t.integer :semester_id
|
||||
end
|
||||
add_index :lvas_semesters, [:lva_id, :semester_id]
|
||||
add_index :lvas_semesters, :semester_id
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :lvas_semesters
|
||||
end
|
||||
end
|
||||
17
db/schema.rb
17
db/schema.rb
@@ -11,17 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20130214233723) do
|
||||
|
||||
create_table "beispiel_translations", :force => true do |t|
|
||||
t.string "locale"
|
||||
t.text "desc"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "beispiele_id"
|
||||
end
|
||||
|
||||
add_index "beispiel_translations", ["locale"], :name => "index_beispiel_translations_on_locale"
|
||||
ActiveRecord::Schema.define(:version => 20130729085446) do
|
||||
|
||||
create_table "beispiele", :force => true do |t|
|
||||
t.string "name"
|
||||
@@ -60,6 +50,11 @@ ActiveRecord::Schema.define(:version => 20130214233723) do
|
||||
t.integer "modul_id"
|
||||
end
|
||||
|
||||
create_table "lvas_semesters", :force => true do |t|
|
||||
t.integer "lva_id"
|
||||
t.integer "semester_id"
|
||||
end
|
||||
|
||||
create_table "modul_translations", :force => true do |t|
|
||||
t.integer "modul_id"
|
||||
t.string "locale"
|
||||
|
||||
6
spec/factories/beispiele.rb
Normal file
6
spec/factories/beispiele.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||
|
||||
FactoryGirl.define do
|
||||
factory :beispiel do
|
||||
end
|
||||
end
|
||||
6
spec/factories/lvas.rb
Normal file
6
spec/factories/lvas.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||
|
||||
FactoryGirl.define do
|
||||
factory :lva do
|
||||
end
|
||||
end
|
||||
15
spec/factories/modulgruppen.rb
Normal file
15
spec/factories/modulgruppen.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||
|
||||
FactoryGirl.define do
|
||||
factory :modulgruppe do
|
||||
typ "Pflicht"
|
||||
phase 1
|
||||
name "Pflichtmodule 1"
|
||||
desc "ASDFASDF"
|
||||
factory :other_modulgruppe do
|
||||
name "PFlichtmodule 2"
|
||||
desc "sdafaswdfsfr"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
6
spec/factories/moduls.rb
Normal file
6
spec/factories/moduls.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||
|
||||
FactoryGirl.define do
|
||||
factory :modul do
|
||||
end
|
||||
end
|
||||
19
spec/factories/studien.rb
Normal file
19
spec/factories/studien.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||
|
||||
|
||||
FactoryGirl.define do
|
||||
factory :studium do
|
||||
zahl "066506"
|
||||
name "Automatisierung"
|
||||
desc "TEST DESC"
|
||||
typ "Master"
|
||||
|
||||
factory :other_studium do
|
||||
name "Telecommunication"
|
||||
desc "frueher Telekommungikation"
|
||||
zahl "066507"
|
||||
typ "Master"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
1
spec/factories/studium_factory.rb
Normal file
1
spec/factories/studium_factory.rb
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
5
spec/models/beispiel_spec.rb
Normal file
5
spec/models/beispiel_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Beispiel do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
5
spec/models/lva_spec.rb
Normal file
5
spec/models/lva_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Lva do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
5
spec/models/modul_spec.rb
Normal file
5
spec/models/modul_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Modul do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
46
spec/models/modulgruppe_spec.rb
Normal file
46
spec/models/modulgruppe_spec.rb
Normal file
@@ -0,0 +1,46 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Modulgruppe do
|
||||
it "should not be valid without studium" do
|
||||
mg=FactoryGirl.build(:modulgruppe)
|
||||
mg.should_not be_valid
|
||||
mg.should have(1).errors_on(:studium_id)
|
||||
end
|
||||
it "should be valid with studium" do
|
||||
s=FactoryGirl.create(:studium)
|
||||
mg=FactoryGirl.build(:modulgruppe)
|
||||
mg.studium=s
|
||||
mg.should be_valid
|
||||
end
|
||||
it "should not be valid without name" do
|
||||
s=FactoryGirl.create(:studium)
|
||||
mg=FactoryGirl.build(:modulgruppe)
|
||||
mg.studium=s
|
||||
mg.name=nil
|
||||
mg.should_not be_valid
|
||||
mg.should have_at_least(1).errors_on(:name)
|
||||
end
|
||||
xit "should not be valid with dubble name" do
|
||||
s=FactoryGirl.create(:studium)
|
||||
mg=FactoryGirl.build(:modulgruppe, name: "Gruppe 1", desc: "132")
|
||||
mg.studium=s
|
||||
mg.save
|
||||
mg=FactoryGirl.build(:modulgruppe, name: "Gruppe 2", desc: "133")
|
||||
mg.studium=s
|
||||
mg.should_not be_valid
|
||||
mg.should have_at_least(1).errors_on(:name)
|
||||
end
|
||||
|
||||
it "should be valid with same name on different studien" do
|
||||
s=FactoryGirl.create(:studium)
|
||||
s2=FactoryGirl.create(:other_studium)
|
||||
mg=FactoryGirl.build(:modulgruppe, name: "Gruppe")
|
||||
mg.studium=s
|
||||
mg.save
|
||||
mg=FactoryGirl.build(:other_modulgruppe, name: "Gruppe")
|
||||
mg.studium=s2
|
||||
mg.should be_valid
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
27
spec/models/studium_spec.rb
Normal file
27
spec/models/studium_spec.rb
Normal file
@@ -0,0 +1,27 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Studium do
|
||||
[:name, :zahl].each do |attr|
|
||||
it "should not be valid without #{attr}" do
|
||||
s = FactoryGirl.build(:studium, attr=>nil)
|
||||
s.should_not be_valid
|
||||
end
|
||||
end
|
||||
it "should create studium with valid data" do
|
||||
s=FactoryGirl.build(:studium)
|
||||
lambda {
|
||||
s.save!}.should change {Studium.count()}.by(1)
|
||||
end
|
||||
it "should not accept double entrys" do
|
||||
FactoryGirl.create(:studium)
|
||||
s=FactoryGirl.build(:studium)
|
||||
s.should_not be_valid
|
||||
s.should have_at_least(1).error_on(:name)
|
||||
s.should have_at_least(1).error_on(:zahl)
|
||||
end
|
||||
it "should expect zahl to be 000.000" do
|
||||
s=FactoryGirl.build(:studium, :zahl=>"000000")
|
||||
s.should_not be_valid
|
||||
s.should have_at_least(1).error_on(:zahl)
|
||||
end
|
||||
end
|
||||
38
spec/spec_helper.rb
Normal file
38
spec/spec_helper.rb
Normal file
@@ -0,0 +1,38 @@
|
||||
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
||||
ENV["RAILS_ENV"] ||= 'test'
|
||||
require File.expand_path("../../config/environment", __FILE__)
|
||||
require 'rspec/rails'
|
||||
require 'rspec/autorun'
|
||||
|
||||
# Requires supporting ruby files with custom matchers and macros, etc,
|
||||
# in spec/support/ and its subdirectories.
|
||||
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
|
||||
|
||||
RSpec.configure do |config|
|
||||
# ## Mock Framework
|
||||
#
|
||||
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
||||
#
|
||||
# config.mock_with :mocha
|
||||
# config.mock_with :flexmock
|
||||
# config.mock_with :rr
|
||||
|
||||
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
||||
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
||||
|
||||
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
||||
# examples within a transaction, remove the following line or assign false
|
||||
# instead of true.
|
||||
config.use_transactional_fixtures = true
|
||||
|
||||
# If true, the base class of anonymous controllers will be inferred
|
||||
# automatically. This will be the default behavior in future versions of
|
||||
# rspec-rails.
|
||||
config.infer_base_class_for_anonymous_controllers = false
|
||||
|
||||
# Run specs in random order to surface order dependencies. If you find an
|
||||
# order dependency and want to debug it, you can fix the order by providing
|
||||
# the seed, which is printed after each run.
|
||||
# --seed 1234
|
||||
config.order = "random"
|
||||
end
|
||||
Reference in New Issue
Block a user