forked from bofh/fetsite
public neuigkeit/rubrik -calentry link
This commit is contained in:
@@ -15,4 +15,5 @@ class Calendar < ActiveRecord::Base
|
||||
has_and_belongs_to_many :calentries
|
||||
mount_uploader :picture, PictureUploader
|
||||
resourcify
|
||||
scope :public, -> { where(:public => :true) }
|
||||
end
|
||||
|
||||
@@ -20,8 +20,19 @@ class Neuigkeit < ActiveRecord::Base
|
||||
validates :rubrik, :presence=>true
|
||||
validates :author, :presence=>true
|
||||
translates :title,:text, :versioning=>true, :fallbacks_for_empty_translations => true
|
||||
|
||||
scope :published, -> {where("datum >= ?", Time.now.to_date)}
|
||||
scope :recent, -> { where("updated_at >= ? ",Time.now - 7.days)}
|
||||
|
||||
has_one :calentry, :as => :object
|
||||
scope :published, -> {where("datum >= ? AND datum IS NOT NULL", Time.now.to_date)}
|
||||
scope :recent, -> { published.where("updated_at >= ? ",Time.now - 7.days)}
|
||||
def datum_nilsave
|
||||
self.datum.nil? ? Time.now + 42.years : self.datum
|
||||
end
|
||||
def public
|
||||
self.rubrik.public && self.datum >=Time.now.to_date
|
||||
end
|
||||
def publish
|
||||
self.datum = Time.now
|
||||
end
|
||||
def reverse_publish
|
||||
self.datum = nil
|
||||
end
|
||||
end
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
class Rubrik < ActiveRecord::Base
|
||||
attr_accessible :desc, :name, :prio
|
||||
has_many :neuigkeiten, :class_name => "Neuigkeit"
|
||||
has_many :calentries, :through => :neuigkeiten, :as=>:object
|
||||
resourcify
|
||||
def moderator
|
||||
u=User.with_role(:newsmoderator).first
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
class AddPublicToRubrikneuigkeiten < ActiveRecord::Migration
|
||||
def up
|
||||
add_column :rubriken, :public,:boolean
|
||||
Rubrik.update_all(:public => :true)
|
||||
end
|
||||
def down
|
||||
remove_column :rubriken, :public
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user