forked from bofh/fetsite
link Profile und Gremien an neuigkeit
This commit is contained in:
@@ -21,6 +21,8 @@ class Gremium < ActiveRecord::Base
|
||||
|
||||
attr_accessible :desc, :name, :typ, :geschlecht,:thema_id, :memberships_attributes
|
||||
has_many :memberships # Mitgliedschaften bei dem Gremium
|
||||
has_many :nlinks, as: :link
|
||||
scope :search, ->(query) {where("gremien.name like ? or gremien.desc like ?", "%#{query}%", "%#{query}%")}
|
||||
|
||||
belongs_to :thema # Gehört zu einem Thema
|
||||
scope :tabs, -> { where(:typ => [1,3]).order(:typ).order(:name) } # Gremien die in Tabs angezeigt werden (Alle Anderen nur in der Liste
|
||||
@@ -31,6 +33,9 @@ class Gremium < ActiveRecord::Base
|
||||
def fall2
|
||||
Gremium::ART2FALL[self.geschlecht.to_i].to_s+" "+ self.name.to_s+ ((self.geschlecht.to_i==1||self.geschlecht.to_i==0)? "s":"")
|
||||
end
|
||||
def title
|
||||
name
|
||||
end
|
||||
def fall4
|
||||
Gremium::ART4FALL[self.geschlecht.to_i].to_s+" "+ self.name.to_s+ ((self.geschlecht.to_i==1||self.geschlecht.to_i==0)? "":"")
|
||||
end
|
||||
|
||||
@@ -29,7 +29,7 @@ class Neuigkeit < ActiveRecord::Base
|
||||
scope :unpublished, -> {where("datum >= ? OR datum IS NULL", Date.today)}
|
||||
scope :public, ->{includes(:rubrik).where("rubriken.public"=>:true)}
|
||||
scope :search, ->(query) {where("text like ? or title like ?", "%#{query}%", "%#{query}%")}
|
||||
LINKTYPES=["Thema", "Gallery", "Lva","Studium","Fetprofile"]
|
||||
LINKTYPES=["Thema", "Gallery", "Lva","Studium","Fetprofile", "Gremium"]
|
||||
accepts_nested_attributes_for :calentries, :allow_destroy=>true , :reject_if=> lambda{|a| a[:start].blank?}
|
||||
before_validation :sanitize
|
||||
has_many :nlinks
|
||||
|
||||
@@ -4,7 +4,7 @@ class Nlink < ActiveRecord::Base
|
||||
belongs_to :link, :polymorphic=>true
|
||||
validates :neuigkeit, :presence=>true
|
||||
validates :link, :presence=>true
|
||||
validates :link_id, :uniqueness=>{:scope=>[:neuigkeit_id]}
|
||||
validates :link_id, :uniqueness=>{:scope=>[:neuigkeit_id,:link_type]}
|
||||
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user