Class: Orange::CalendarResource

Inherits:
ModelResource show all
Defined in:
lib/orange-more/events/resources/calendar_resource.rb

Instance Attribute Summary

Attributes inherited from ModelResource

#model_class

Instance Method Summary collapse

Methods inherited from ModelResource

#afterDelete, #afterSave, #beforeDelete, #beforeNew, #beforeSave, #create, #delete, #do_list_view, #do_view, #edit, #find_list, #find_one, #index, #list, #new, new, #onDelete, #onNew, #onSave, #save, #show, #table_row, use, #view, #view_opts

Methods inherited from RoutableResource

#routable, #route

Methods inherited from Resource

#afterLoad, call_me, #do_view, #find_extras, #init, #initialize, #options, #orange, #orange_name, #routable, #set_orange, set_orange, #view, #view_opts

Methods included from ClassInheritableAttributes

#cattr_accessor, #cattr_reader, #cattr_writer, eval_in_accessor_module, fetch_value, store_value

Constructor Details

This class inherits a constructor from Orange::Resource

Instance Method Details

#afterNew(packet, obj, opts = {}) ⇒ Object



27
28
29
# File 'lib/orange-more/events/resources/calendar_resource.rb', line 27

def afterNew(packet, obj, opts = {})
  obj.orange_site = packet['site'] unless obj.orange_site
end

#calendar(packet, opts = {}) ⇒ Object



22
23
24
25
# File 'lib/orange-more/events/resources/calendar_resource.rb', line 22

def calendar(packet, opts = {})
  template = (opts[:template] || "calendar").to_sym
  do_list_view(packet, template, opts)
end

#stack_initObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/orange-more/events/resources/calendar_resource.rb', line 5

def stack_init
  orange[:admin, true].add_link("Settings", :resource => @my_orange_name, :text => 'Calendars')
  orange[:radius].define_tag "calendar" do |tag|
 	  template = tag.attr["template"] || false
 	  if tag.attr["name"]
 	    calendars = tag.attr["name"].split.map{|x| model_class.first(:name => x)}
      unless tag.attr["main"] && tag.attr["main"] == "false"
        calendars << model_class.all(:main => true)
      end
    else
      calendars = model_class.all
    end
    events = OrangeEvent.all(:calendar => calendars, :order => [:starts.asc], :limit => 10)
    orange[:calendar].calendar(tag.locals.packet, {:list => events, :template => template})
  end
end