meetings added, documents added

This commit is contained in:
Andreas Stephanides
2014-11-26 20:36:04 +01:00
parent c2ea1782ff
commit 87dd70ea44
32 changed files with 304 additions and 21 deletions

View File

@@ -116,7 +116,12 @@ class Ability
cannot :delete, Neuigkeit
end
# Calendar
if( user.has_role?("fetuser") || user.has_role?("fetadmin"))
can :manage, Document
can :manage, Meeting
can :manage, Meetingtyp
end
# Rechteverwaltung Kalender

View File

@@ -1,3 +1,9 @@
class Document < ActiveRecord::Base
attr_accessible :etherpadkey, :name, :parent, :text, :typ
belongs_to :parent, :polymorphic => true
validate :name, :length=>{minimum:3}
validate :text, :presence=>true
validate :typ, :presence=>true
validate :parent, :presence=>true
end

32
app/models/meeting.rb Normal file
View File

@@ -0,0 +1,32 @@
class Meeting < ActiveRecord::Base
belongs_to :parent, :polymorphic=>true
belongs_to :meetingtyp
attr_accessible :desc, :intern, :name
has_one :protocol, :class_name=>'Document', :conditions=>{:typ=>10}, :as=>:parent
has_one :agenda , :as=>:parent,:conditions=>{:typ=>11}, :class_name=>'Document'
validate :agenda, :presence=>true
validate :protocol, :presence=>true
has_one :calentry, :as=>:object
def public?
! (self.intern)
end
def create_protocol
if self.protocol.nil?
d=Document.new
d.typ=10
d.name="Protokoll"
d.save
self.protocol=d
end
end
def create_agenda
if self.agenda.nil?
d=Document.new
d.typ=11
d.name="Agenda"
d.save
self.agenda=d
end
end
end

3
app/models/meetingtyp.rb Normal file
View File

@@ -0,0 +1,3 @@
class Meetingtyp < ActiveRecord::Base
attr_accessible :agendaintern, :desc, :name, :protocolintern
end

View File

@@ -21,6 +21,8 @@ include Rails.application.routes.url_helpers
validates :themengruppe, :presence => true
validates :title, :presence => true
validates :text, :presence => true
has_many :meetings, :as=>:parent
has_many :documents, :as=>:parent
scope :public, where(:isdraft=>false).includes(:themengruppe).where("themengruppen.public"=>true)
default_scope order("themen.priority").reverse_order
# scope :search, ->(query) {where("themen.text like ? or themen.title like ?", "%#{query}%", "%#{query}%")}