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 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) def strip_control_chars(value)
value.chars.inject("") do |str, char| value.chars.inject("") do |str, char|
unless char.ascii_only? && (char.ord < 32 || char.ord == 127) unless char.ascii_only? && (char.ord < 32 || char.ord == 127)

View File

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

View File

@@ -8,12 +8,16 @@ class Meeting < ActiveRecord::Base
has_one :protocol, :class_name=>'Document', :conditions=>{:typ=>10}, :as=>:parent has_one :protocol, :class_name=>'Document', :conditions=>{:typ=>10}, :as=>:parent
has_one :agenda , :as=>:parent,:conditions=>{:typ=>11}, :class_name=>'Document' has_one :agenda , :as=>:parent,:conditions=>{:typ=>11}, :class_name=>'Document'
has_one :calentry, as: :object has_one :calentry, as: :object
has_one :calendar, :through=>:meetingtyp
has_one :rubrik, :through=>:meetingtyp
accepts_nested_attributes_for :calentry accepts_nested_attributes_for :calentry
# validate :agenda, :presence=>true # validate :agenda, :presence=>true
# validate :protocol, :presence=>true # validate :protocol, :presence=>true
validate :parent, :presence=>true validate :parent, :presence=>true
validate :calentry, :presence=>true validate :calentry, :presence=>true
before_validation :fix_calentry before_validation :fix_calentry
def title def title
self.text self.text
end end
@@ -39,6 +43,7 @@ class Meeting < ActiveRecord::Base
end end
def fix_calentry def fix_calentry
self.calentry.object=self unless self.calentry.nil? self.calentry.object=self unless self.calentry.nil?
self.calentry.calendar = self.meetingtyp.rubrik.calendar
end end
def public? def public?
! (self.intern) ! (self.intern)

View File

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

View File

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

View File

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