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
# updated_at :datetime not null
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 :semester, :dependent => :destroy
validates :abkuerzung, :length=>{:maximum=>5}, :format=>{:with=>/^[a-zA-z]{0,5}$/}
validates :typ, :inclusion => {:in => ["Bachelor","Master"] }
validates :name, :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 title_context
return self.abkuerzung.strip.empty? ? self.name : self.abkuerzung
end
def batch_add_semester
# Semester automatisch zu Studien hinzufügen