integrate calendar with meetings

This commit is contained in:
Andreas Stephanides
2015-01-18 14:32:20 +01:00
parent e5966bccce
commit b46e19b466
6 changed files with 17 additions and 3 deletions

View File

@@ -1,5 +1,11 @@
module ApplicationHelper
def clean_calendar(cal)
cal.rubrik.meetingtyps.each do |mt|
mt.meetings.each do |m|
m.calentry.calendar=cal
end
end
end
def strip_control_chars(value)
value.chars.inject("") do |str, char|
unless char.ascii_only? && (char.ord < 32 || char.ord == 127)

View File

@@ -32,6 +32,7 @@ class Calentry < ActiveRecord::Base
resourcify
def get_public
self.calendar=self.object.calendar unless object.nil? || object.calendar.nil?
self.public = (self.try(:object).nil?)? (self.calendar.try(:public?)) : object.try(:public?)
true
end

View File

@@ -8,12 +8,16 @@ class Meeting < ActiveRecord::Base
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
has_one :calendar, :through=>:meetingtyp
has_one :rubrik, :through=>:meetingtyp
accepts_nested_attributes_for :calentry
# validate :agenda, :presence=>true
# validate :protocol, :presence=>true
validate :parent, :presence=>true
validate :calentry, :presence=>true
before_validation :fix_calentry
def title
self.text
end
@@ -39,6 +43,7 @@ class Meeting < ActiveRecord::Base
end
def fix_calentry
self.calentry.object=self unless self.calentry.nil?
self.calentry.calendar = self.meetingtyp.rubrik.calendar
end
def public?
! (self.intern)

View File

@@ -2,5 +2,6 @@ class Meetingtyp < ActiveRecord::Base
attr_accessible :agendaintern, :desc, :name, :protocolintern
belongs_to :rubrik
validate :rubrik, :presence=>true
has_many :meetings
has_one :calendar, through: :rubrik
end

View File

@@ -20,7 +20,7 @@ class Neuigkeit < ActiveRecord::Base
validates :rubrik, :presence=>true
validates :author, :presence=>true
translates :title,:text, :versioning=>{:gem=>:paper_trail, :options=>{:fallbacks_for_empty_translations => true}}
has_one :calendar, through: :rubrik
has_many :calentries, as: :object
has_many :nlinks
has_one :meeting

View File

@@ -1,3 +1,4 @@
# == Schema Information
#
# Table name: themen