link Profile und Gremien an neuigkeit

This commit is contained in:
Andreas Stephanides
2014-04-23 17:15:59 +02:00
parent 63f3b09a5d
commit 73a2627cd3
8 changed files with 30 additions and 5 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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