kommentare für gremium und calentry

This commit is contained in:
Andreas Stephanides
2013-09-11 20:08:08 +02:00
parent 1951549486
commit 09c182048c
2 changed files with 17 additions and 14 deletions

View File

@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# == Schema Information
#
# Table name: calentries
@@ -17,14 +18,13 @@ class Calentry < ActiveRecord::Base
validates :start, :presence => true
validates :typ, :presence => true
before_save :get_public
belongs_to :object, polymorphic: true
belongs_to :object, polymorphic: true # Objekt zu dem der Calentry gehört (derzeit ein Newsartikel)
validate do |entry|
validate do |entry|
if entry.ende.nil?
errors.add(:ende, "Es muss ein Endzeitpunkt vorhanden sein")
end
end
end
resourcify
def get_public
@@ -38,7 +38,11 @@ class Calentry < ActiveRecord::Base
start.to_date
end
def name
summary
unless self.object.nil?
self.object.name
else
summary
end
end
scope :public, -> { where(:public => :true) }
scope :upcoming, -> { where("start >= ?" , Time.now).where("start <= ?", 8.days.from_now) }