forked from bofh/fetsite
meeting
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
class Meetingtyp < ActiveRecord::Base
|
||||
attr_accessible :agendaintern, :desc, :name, :protocolintern
|
||||
belongs_to :rubrik
|
||||
validate :rubrik, :presence=>true
|
||||
end
|
||||
|
||||
@@ -23,7 +23,7 @@ class Neuigkeit < ActiveRecord::Base
|
||||
|
||||
has_many :calentries, as: :object
|
||||
has_many :nlinks
|
||||
|
||||
has_one :meeting
|
||||
mount_uploader :picture, PictureUploader
|
||||
|
||||
default_scope order(:datum).reverse_order
|
||||
@@ -38,7 +38,9 @@ class Neuigkeit < ActiveRecord::Base
|
||||
before_validation :sanitize
|
||||
|
||||
|
||||
|
||||
def is_annoncement?
|
||||
self.meeting.nil?
|
||||
end
|
||||
def self.published
|
||||
where("datum <= ? AND datum IS NOT NULL", Time.now.to_date)
|
||||
end
|
||||
|
||||
@@ -16,6 +16,7 @@ class Rubrik < ActiveRecord::Base
|
||||
has_many :published, :class_name => "Neuigkeit", :conditions=>["Neuigkeit.published"]
|
||||
has_many :calentries, :through => :neuigkeiten, :as=>:object
|
||||
resourcify
|
||||
has_many :meetingtyps
|
||||
has_one :calendar
|
||||
validates :calendar , :presence=>true
|
||||
before_validation :sanitize
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
class Studium < ActiveRecord::Base
|
||||
attr_accessible :desc, :name,:abkuerzung, :typ, :zahl, :semester, :picture, :picture_cache, :qualifikation,:struktur, :jobmoeglichkeiten, :lvas_attributes
|
||||
has_many :modulgruppen, inverse_of: :studium, :class_name => "Modulgruppe", :dependent => :destroy
|
||||
scope :search, ->(query) {where("name like ? or studien.desc like ?", "%#{query}%", "%#{query}%")}
|
||||
# scope :search, ->(query) {where("name like ? or studien.desc like ?", "%#{query}%", "%#{query}%")}
|
||||
has_many :moduls, :through=>:modulgruppen
|
||||
has_many :lvas, :through=>:moduls
|
||||
has_many :semester, :dependent => :destroy
|
||||
|
||||
Reference in New Issue
Block a user