Abkürzungen zu Studien hinzugefügt

This commit is contained in:
Thomas Blazek
2013-08-13 17:22:29 +02:00
parent c8ce5a7c7c
commit b1f9ec1c39
7 changed files with 92 additions and 50 deletions

View File

@@ -12,14 +12,17 @@
# created_at :datetime not null # created_at :datetime not null
# updated_at :datetime not null # updated_at :datetime not null
class Studium < ActiveRecord::Base class Studium < ActiveRecord::Base
attr_accessible :desc, :name, :typ, :zahl, :semester attr_accessible :desc, :name,:abkuerzung, :typ, :zahl, :semester
has_many :modulgruppen, inverse_of: :studium, :class_name => "Modulgruppe", :dependent => :destroy has_many :modulgruppen, inverse_of: :studium, :class_name => "Modulgruppe", :dependent => :destroy
has_many :semester, :dependent => :destroy has_many :semester, :dependent => :destroy
validates :abkuerzung, :length=>{:maximum=>5}, :format=>{:with=>/^[a-zA-z]{0,5}$/}
validates :typ, :inclusion => {:in => ["Bachelor","Master"] } validates :typ, :inclusion => {:in => ["Bachelor","Master"] }
validates :name, :uniqueness => true, :presence=>true validates :name, :uniqueness => true, :presence=>true
validates :zahl, :presence=>true, :format=>{:with=>/^0(33|66)[0-9]{3}$/}, :uniqueness => 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 translates :desc,:shortdesc, :versioning =>true,:fallbacks_for_empty_translations => true
def title_context
return self.abkuerzung.strip.empty? ? self.name : self.abkuerzung
end
def batch_add_semester def batch_add_semester
# Semester automatisch zu Studien hinzufügen # Semester automatisch zu Studien hinzufügen

View File

@@ -45,7 +45,7 @@
<ul> <ul>
<% modul.modulgruppen.each do |g| %> <% modul.modulgruppen.each do |g| %>
<li><%= link_to g.studium.name , studium_path(g.studium)%> (<%=link_to g.name, modulgruppe_path(g)%>)</li> <li><%= link_to g.studium.title_context , studium_path(g.studium)%> (<%=link_to g.name, modulgruppe_path(g)%>)</li>
<% end %> <% end %>
</ul> </ul>
</li> </li>

View File

@@ -1 +1 @@
<b><%=link_to modulgruppe.name, modulgruppe %></b> <%= ' ( ' + modulgruppe.studium.name + ')' unless modulgruppe.studium.nil? %> <b><%=link_to modulgruppe.name, modulgruppe %></b> <%= ' ( ' + modulgruppe.studium.title_context + ')' unless modulgruppe.studium.nil? %>

View File

@@ -5,18 +5,15 @@
<%= f.inputs do %> <%= f.inputs do %>
<div class="row-fluid"> <div class="row-fluid">
<div class="span6"> <%= f.input :name,:append=>"NAME", :wrapper_html=>{:class=>"span6"}%>
<%= f.input :name,:append=>"NAME" %>
</div> <%= f.input :abkuerzung, :wrapper_html=>{:class=>"span1"}%>
<div class="span3"> <%= f.input :zahl , :wrapper_html=>{:class=>"span2"}%>
<%= f.input :zahl %>
</div> <%= f.input :typ, :as=>:select, :include_blank=>false, :collection=>["Bachelor","Master"], :wrapper_html=>{:class=>"span2"}%>
<div class="span3">
<%= f.input :typ, :as=>:select, :include_blank=>false, :collection=>["Bachelor","Master"]%>
</div>
</div> </div>
<div class="row-fluid"> <div class="row-fluid">
<%= f.input :desc, :as=>:tinymce_text %> <%= f.input :desc, :as=>:tinymce_text , :wrapper_html=>{:class=>"span12"}%>
</div> </div>
<% end %> <% end %>

View File

@@ -7,17 +7,18 @@
<%= link_to "Alle Studien", studien_path %> </li> <%= link_to "Alle Studien", studien_path %> </li>
<% for s in Studium.all %> <% for s in Studium.all %>
<% if !@studium.nil? && s == @studium %> <% if !@studium.nil? && s == @studium %>
<li class="active">
<%= link_to s.name, s %> <li class="active" title="<%= s.name %>">
<%= link_to s.title_context, s %>
</li> </li>
<% else %> <% else %>
<li> <%= link_to s.name, s %></li> <li title="<%= s.name %>"> <%= link_to s.title_context, s %></li>
<% end %> <% end %>
<% end %> <% end %>
<% if request.fullpath == studien_verwalten_path %> <% if request.fullpath == studien_verwalten_path %>
<li class="active"> <li class="active pull-right">
<% else %> <% else %>
<li> <li class="pull-right">
<% end %> <% end %>
<%= link_to "Verwaltung", studien_verwalten_path %> <%= link_to "Verwaltung", studien_verwalten_path %>
</li> </li>

View File

@@ -0,0 +1,5 @@
class AddAbkuerzungToStudien < ActiveRecord::Migration
def change
add_column :studien, :abkuerzung, :string
end
end

View File

@@ -11,28 +11,22 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20130812070544) do ActiveRecord::Schema.define(:version => 20130813145651) do
create_table "beispiel_translations", :force => true do |t| create_table "attachments", :force => true do |t|
t.string "locale" t.string "name"
t.text "desc"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.integer "beispiele_id" t.integer "thema_id"
end end
add_index "beispiel_translations", ["locale"], :name => "index_beispiel_translations_on_locale"
create_table "beispiele", :force => true do |t| create_table "beispiele", :force => true do |t|
t.string "name" t.string "name"
t.text "desc" t.text "desc"
t.integer "lva_id" t.integer "lva_id"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.string "file_file_name" t.string "beispieldatei"
t.string "file_content_type"
t.integer "file_file_size"
t.datetime "file_updated_at"
end end
create_table "calendars", :force => true do |t| create_table "calendars", :force => true do |t|
@@ -60,6 +54,25 @@ ActiveRecord::Schema.define(:version => 20130812070544) do
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
end end
create_table "frage_translations", :force => true do |t|
t.string "locale"
t.string "title"
t.text "text"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "fragen_id"
end
add_index "frage_translations", ["locale"], :name => "index_frage_translations_on_locale"
create_table "fragen", :force => true do |t|
t.string "title"
t.text "text"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "thema_id"
end
create_table "lva_translations", :force => true do |t| create_table "lva_translations", :force => true do |t|
t.integer "lva_id" t.integer "lva_id"
t.string "locale" t.string "locale"
@@ -91,14 +104,11 @@ ActiveRecord::Schema.define(:version => 20130812070544) do
t.integer "modul_id" t.integer "modul_id"
end end
create_table "lvas_semesters", :id => false, :force => true do |t| create_table "lvas_semesters", :force => true do |t|
t.integer "lva_id" t.integer "lva_id"
t.integer "semester_id" t.integer "semester_id"
end end
add_index "lvas_semesters", ["lva_id", "semester_id"], :name => "index_lvas_semesters_on_lva_id_and_semester_id"
add_index "lvas_semesters", ["semester_id"], :name => "index_lvas_semesters_on_semester_id"
create_table "modul_translations", :force => true do |t| create_table "modul_translations", :force => true do |t|
t.integer "modul_id" t.integer "modul_id"
t.string "locale" t.string "locale"
@@ -156,18 +166,6 @@ ActiveRecord::Schema.define(:version => 20130812070544) do
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
end end
create_table "pages", :force => true do |t|
t.string "name"
t.string "url"
t.integer "parent_id"
t.integer "lft"
t.integer "rgt"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "pages", ["parent_id"], :name => "index_pages_on_parent_id"
create_table "roles", :force => true do |t| create_table "roles", :force => true do |t|
t.string "name" t.string "name"
t.integer "resource_id" t.integer "resource_id"
@@ -204,6 +202,7 @@ ActiveRecord::Schema.define(:version => 20130812070544) do
t.string "typ" t.string "typ"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.string "abkuerzung"
end end
create_table "studium_translations", :force => true do |t| create_table "studium_translations", :force => true do |t|
@@ -217,6 +216,43 @@ ActiveRecord::Schema.define(:version => 20130812070544) do
add_index "studium_translations", ["locale"], :name => "index_studium_translations_on_locale" add_index "studium_translations", ["locale"], :name => "index_studium_translations_on_locale"
create_table "thema_translations", :force => true do |t|
t.string "locale"
t.string "title"
t.text "text"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "themen_id"
end
add_index "thema_translations", ["locale"], :name => "index_thema_translations_on_locale"
create_table "themen", :force => true do |t|
t.string "title"
t.text "text"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "themengruppe_id"
end
create_table "themengruppe_translations", :force => true do |t|
t.string "locale"
t.string "title"
t.text "text"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "themengruppen_id"
end
add_index "themengruppe_translations", ["locale"], :name => "index_themengruppe_translations_on_locale"
create_table "themengruppen", :force => true do |t|
t.string "title"
t.text "text"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "users", :force => true do |t| create_table "users", :force => true do |t|
t.string "email", :default => "", :null => false t.string "email", :default => "", :null => false
t.string "encrypted_password", :default => "", :null => false t.string "encrypted_password", :default => "", :null => false