Merge branch 'thomasb/master'

This commit is contained in:
Andreas Stephanides
2013-07-25 14:47:59 +02:00
12 changed files with 102 additions and 55 deletions

View File

@@ -7,8 +7,9 @@ class ModulgruppenController < ApplicationController
@modulgruppen = Modulgruppe.all @modulgruppen = Modulgruppe.all
if !params[:studium_id].nil? if !params[:studium_id].nil?
@studium=Studium.find(params[:studium_id]) @studium=Studium.find(params[:studium_id])
else
@studium=Studium.first
end end
end end
# GET /modulgruppen/1 # GET /modulgruppen/1
@@ -27,6 +28,12 @@ class ModulgruppenController < ApplicationController
@modulgruppe = Modulgruppe.new @modulgruppe = Modulgruppe.new
if !params[:studium_id].nil? if !params[:studium_id].nil?
@studium=Studium.find(params[:studium_id]) @studium=Studium.find(params[:studium_id])
else
@studium=Studium.first
end
respond_to do |format|
format.html # new.html.erb
format.json { render json: @modulgruppe }
end end
end end

View File

@@ -10,6 +10,7 @@ class ModulsController < ApplicationController
format.html # index.html.erb format.html # index.html.erb
format.json { render json: @moduls } format.json { render json: @moduls }
end end
end end
# GET /moduls/1 # GET /moduls/1
@@ -27,8 +28,10 @@ class ModulsController < ApplicationController
# GET /moduls/new.json # GET /moduls/new.json
def new def new
@modul = Modul.new @modul = Modul.new
modulgruppe=Modulgruppe.find(params[:modulgruppen_id]) modulgruppe=Modulgruppe.find_by_id(params[:modulgruppen_id])
if !modulgruppe.nil?
@modul.modulgruppen<<modulgruppe @modul.modulgruppen<<modulgruppe
end
respond_to do |format| respond_to do |format|
format.html # new.html.erb format.html # new.html.erb
format.json { render json: @modul } format.json { render json: @modul }

View File

@@ -5,6 +5,8 @@ class StudienController < ApplicationController
def index def index
@studien = Studium.all @studien = Studium.all
@toolbar_elements<<{:icon =>:plus, :text=> I18n.t('studien.new') ,:path=>new_studium_path } @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 end
def show def show

View File

@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# == Schema Information # == Schema Information
# #
# Table name: lvas # Table name: lvas
@@ -24,9 +25,12 @@ class Lva < ActiveRecord::Base
translates :desc, :fallbacks_for_empty_translations => true translates :desc, :fallbacks_for_empty_translations => true
validates :lvanr, :presence=>true; # LVA Nr vorhanden? 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 :ects, :presence=>true; # ECTS vorhanden?
validates_presence_of :ects # ECTS vorhanden?
validates_presence_of :name # Name Eingetragen?
validates_presence_of :stunden # Stunden Eingetragen?
validates_presence_of :modul # Zugehöriges Modul eingetragen? (zumindest eines)
private private
## ##

View File

@@ -1,3 +1,4 @@
# -*- coding: undecided -*-
# == Schema Information # == Schema Information
# #
# Table name: moduls # Table name: moduls
@@ -16,6 +17,8 @@ class Modul < ActiveRecord::Base
has_and_belongs_to_many :lvas has_and_belongs_to_many :lvas
has_and_belongs_to_many :modulgruppen 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 translates :desc,:depend,:name, :versioning =>true, :fallbacks_for_empty_translations => true
end end

View File

@@ -16,10 +16,12 @@ class Modulgruppe < ActiveRecord::Base
attr_accessible :name, :phase, :typ,:desc, :studium_id attr_accessible :name, :phase, :typ,:desc, :studium_id
belongs_to :studium, :foreign_key => "studium_id" belongs_to :studium, :foreign_key => "studium_id"
has_and_belongs_to_many :moduls has_and_belongs_to_many :moduls
resourcify resourcify
validates :studium_id, :presence => true
validates :studium, :presence => true validates :studium_id, :presence => true # Bei der Abfrage ist student_id entscheidend
validates :name, :uniqueness =>{:scope => :studium}, :presence=>true 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 :phase, :inclusion => {:in => [1, 2, 3, 4]} validates :phase, :inclusion => {:in => [1, 2, 3, 4]}
validates :typ, :inclusion => {:in => ["Pflicht","Vertiefungspflicht","Wahl"] } validates :typ, :inclusion => {:in => ["Pflicht","Vertiefungspflicht","Wahl"] }
translates :name,:desc, :versioning =>true,:fallbacks_for_empty_translations => true translates :name,:desc, :versioning =>true,:fallbacks_for_empty_translations => true

View File

@@ -1,7 +1,7 @@
<% @lva.modul.each do |modul| %> <% @lva.modul.each do |modul| %>
<% modul.modulgruppen.each do |g| %> <% modul.modulgruppen.each do |g| %>
<ul class="breadcrumb"> <ul class="breadcrumb">
<li><%= link_to g.studium.name , studium_path(g)%> <li><%= link_to g.studium.name , studium_path(g.studium)%>
<span class="divider">/</span></li> <span class="divider">/</span></li>
<li><%= link_to g.name , modulgruppe_path(g)%><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> <li><%= link_to modul.name , modul_path(modul)%></li>

View File

@@ -1,17 +1,17 @@
<div class="modulgruppe_phase_<%= modulgruppe.phase %>" > <div class="modulgruppe_phase_<%= modulgruppe.phase %>" >
<h2><%= link_to modulgruppe.name, modulgruppe_path(modulgruppe) %> <h2><%= link_to modulgruppe.name, modulgruppe_path(modulgruppe) %>
</h2> </h2>
<%= modulgruppe.desc%> <%= modulgruppe.desc%>
<%= render :partial=>'moduls/kurz', :collection=>modulgruppe.moduls, :as=>:modul%> <%= render :partial=>'moduls/kurz', :collection=>modulgruppe.moduls, :as=>:modul%>
<br> <br>
<% link_to '<i class="icon-pencil"></i>'.html_safe+I18n.t("common.edit"), edit_modulgruppe_path(modulgruppe) %> <% link_to '<i class="icon-pencil"></i>'.html_safe+I18n.t("common.edit"), edit_modulgruppe_path(modulgruppe) %>
<!-- dropdown menu links --> <!-- dropdown menu links -->
</ul> </ul>
</span> </span>
</div> </div>

View File

@@ -1,4 +1,4 @@
<h1>Listing modulgruppen</h1> <h1><%= I18n.t("modulgruppe.show.title")%></h1>
<table> <table>
<tr> <tr>
@@ -11,7 +11,7 @@
<th></th> <th></th>
</tr> </tr>
<% @modulgruppen.each do |modulgruppe| %> <% @modulgruppen.sort_by{|n| n[:name]}.each do |modulgruppe| %>
<tr> <tr>
<td><%= modulgruppe.typ %></td> <td><%= modulgruppe.typ %></td>
<td><%= modulgruppe.phase %></td> <td><%= modulgruppe.phase %></td>
@@ -24,7 +24,7 @@
<% end %> <% end %>
</table> </table>
<br /> <br>
<% if !@studium.nil? %> <% if !@studium.nil? %>
<%= link_to 'New Modulgruppe', new_modulgruppe_path %> <%= link_to 'New Modulgruppe', new_studium_modulgruppe_path(@studium) %>
<% end%> <% end%>

View File

@@ -1,9 +1,8 @@
<h1>Alle Module der Elektrotechnik</h1> <h1><%= I18n.t("modul.show.title") %></h1>
<table class="table" > <table class="table" >
<tr> <tr>
<th>Studium</th> <th>Modulgruppe (Studium)</th>
<th>Modulgruppe</th>
<th>Name</th> <th>Name</th>
<th>Desc</th> <th>Desc</th>
<th></th> <th></th>
@@ -11,12 +10,19 @@
<th></th> <th></th>
</tr> </tr>
<% @moduls.each do |modul| %> <% @moduls.sort_by{|n| n[:name]}.each do |modul| %>
<tr> <tr>
<td><%= %></td> <td>
<td><%= if !modul.modulgruppen.first.nil? <%modul.modulgruppen.sort_by{|n| n[:name]}.each do |m|%>
modul.modulgruppen.first[:name]
end %> </td>
<%=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.name %></td>
<td><%= modul.desc %></td> <td><%= modul.desc %></td>
<td><%= link_to 'Show', modul_path(modul) %></td> <td><%= link_to 'Show', modul_path(modul) %></td>
@@ -27,6 +33,7 @@ end %> </td>
</table> </table>
<br /> <br />
<% if !@studium.nil? %> <% #if !@studium.nil? %>
<%= link_to 'New Modul', new_modul_path() %> <%= link_to 'New Modul', new_modul_path() %>
<% end%> <% #end%>

View File

@@ -1,7 +1,7 @@
<h1><%= I18n.t("studien.list") %></h1> <h1><%= I18n.t("studien.list") %></h1>
<% @studien.each do |studium| %> <% @studien.sort_by{|z| z[:zahl]}.each do |studium| %>
<h2><%= link_to studium.zahl + " "+ studium.typ+" " + studium.name, studium_path(studium) %></h2> <h2><%= link_to studium.zahl + " "+ studium.typ+" " + studium.name, studium_path(studium) %></h2>
@@ -10,6 +10,6 @@
<br /> <br />
<% link_to I18n.t("studien.new"), new_studium_path %> <% link_to I18n.t("studien.new"), new_studium_path %>
<% link_to I18n.t("modulgruppe.show"), modulgruppen_path %>
<%= toolbar_html(@toolbar_elements) %> <%= toolbar_html(@toolbar_elements) %>

View File

@@ -15,12 +15,18 @@ de:
modul: modul:
edit: edit:
title: "Bearbeite Modul" title: "Bearbeite Modul"
show:
title: "Auflistung aller Module"
link: "Alle Module auflisten"
modulgruppe: modulgruppe:
typ: "Typ" typ: "Typ"
addmodul: "Neues Modul hinzufügen" addmodul: "Neues Modul hinzufügen"
studium: "Studium" studium: "Studium"
new: "Neue Modulgruppe" new: "Neue Modulgruppe"
show:
title: "Auflistung aller Modulgruppen"
link: "Modulgruppen auflisten"
home: home:
mtitle: "Menu" mtitle: "Menu"
@@ -65,3 +71,16 @@ de:
name: name:
blank: "Bitte geben sie einen Namen ein" blank: "Bitte geben sie einen Namen ein"
taken: "Der Name ist schon vergeben (Hier ist ein Bug)" taken: "Der Name ist schon vergeben (Hier ist ein Bug)"
lva:
attributes:
modul:
blank: "Wählen Sie zumindest ein Modul aus"
name:
blank: "Geben Sie bitte den Namen der LVA an"
ects:
blank: "Geben Sie die ECTS der LVA an"
stunden:
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."