This commit is contained in:
Andreas Stephanides
2014-12-14 21:30:21 +01:00
parent aa98919e88
commit 07944bce89
16 changed files with 104 additions and 26 deletions

View File

@@ -3,7 +3,7 @@ class Meeting < ActiveRecord::Base
belongs_to :meetingtyp
attr_accessible :desc, :intern, :name, :parent_id, :parent_type, :calentry,:calentry_attributes, :meetingtyp_id
belongs_to :neuigkeit
has_one :protocol, :class_name=>'Document', :conditions=>{:typ=>10}, :as=>:parent
has_one :agenda , :as=>:parent,:conditions=>{:typ=>11}, :class_name=>'Document'
has_one :calentry, as: :object
@@ -12,17 +12,29 @@ class Meeting < ActiveRecord::Base
# validate :protocol, :presence=>true
validate :parent, :presence=>true
validate :calentry, :presence=>true
before_validation :fix_calentry
before_validation :fix_calentry
def title
self.text
end
def text
unless self.meetingtyp.try(:name).to_s.empty?
t = self.meetingtyp.name.to_s+", "
else
t = parent.title", " if self.name.empty?
t = parent.title.to_s + ", " if self.name.empty?
end
t= t+ self.name
t = t + " " + I18n.l(self .calentry.start)
t= t+ self.name.to_s
t = t + " " + I18n.l(self.calentry.start) unless self.calentry.nil?
t
end
def create_announcement(user)
n = Neuigkeit.new
n.title=self.text
n.text ="Agenda im Anhang"
n.rubrik = self.meetingtyp.rubrik
n.author=user
self.neuigkeit= n
end
def fix_calentry
self.calentry.object=self unless self.calentry.nil?
end