Skip to content

Instantly share code, notes, and snippets.

@MichaelMartinez
Created May 15, 2012 21:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save MichaelMartinez/2705105 to your computer and use it in GitHub Desktop.
Save MichaelMartinez/2705105 to your computer and use it in GitHub Desktop.
Calendar Implementation

TODO

28 May 2012

  1. All the model stuff from 22 May 2012 as I didn't have time See discussion below
    • Figure out roster - Users? Or separate Roster "scaffolding"?
    • Diagram the relationships
    • Assignment = button v. drag and drop v. select open spots
    • 8 hour conundrum
  2. Cut off areas of app with before_filter :authenticate_user! && authorize! :index, @user, :message => 'Not authorized as an administrator.'
  3. Install sevenwire/forgery and use it to create fake users/assignments/etc.

Roster

  1. Belongs to shift && shift has one roster?
  2. Shift is also ROSTER?
  3. Assign "Users" to units and list users based on assignment?
  4. Simply a matter of assignment per shift Ie. Loop through battalions and stations and units. If vac, sick, light duty, or family medical are encountered alert missing personnel slot.
  5. Provide a list of open spots to Admin / Staffing
  6. Mechanism to assign member / user to unit
  7. User needs Fire Profile with Rank, IBM number

22 May 2012

  1. Cut off areas of app with before_filter :authenticate_user! && authorize! :index, @user, :message => 'Not authorized as an administrator.'
  2. Upload 37 signals book and CSS book to Tablet for Mexico
  3. ~~Moar

22 May 2012

  1. Figure out roster - Users? Or separate Roster "scaffolding"?
  2. Diagram the relationships
  3. Assignment = button v. drag and drop v. select open spots
  4. 8 hour conundrum
  5. Cut off areas of app with before_filter :authenticate_user! && authorize! :index, @user, :message => 'Not authorized as an administrator.'
  6. Spruce up Calendar CSS
  7. After login -> return to calendar
  8. Add _navigation links for Calendar, Battalion, Stations and (roster, User, or whatever)
  9. Merge back into master and create topic branch before any major change

21 May 2012

  1. Run app as is with new rails_admin Whitelist enabled see what happens This worked
  2. Colorize shifts
  3. Figure out roster - Users? Or separate Roster?
  4. continue iterating on shifts/show.html.erb
    • Add if station.battalion_id == battalion.id then print the station info needs more work, but it generally worked
    • As it stands now, every battalion gets assigned the station even if it doesn't have that station
    • Maybe filp this <% @battalions.each do |battalion| %> <% @stations.each do |station| %> so station comes first?? Doesn't work

Event_Calendar Implementation

The EventCalendar plugin is only concerned with displaying events. (Or really any model as long as it has name, start_at, and end_at fields.) How they are created is entirely up to you. It does include a generator to get you up and running, but doesn't go as far as creating the event controller and views. For that you could run the following Rails scaffold: script/generate scaffold Event start_at:datetime end_at:datetime

This will give you the controller and views you're looking for.

  • The calendar_controller needs to have the strips instance variable changed to the model you are trying to display @event_strips = Shift.event_strips_for_month(@shown_month)
# Changes the colors
def color
   if self.name == "A Shift"
     self[:color] || '#C10000'
   elsif self.name == "B Shift"
     self[:color] || '#0C0882'
   else
     self[:color] || '#08820A'
   end
 end

Abandoning this for now _ See the Event_Calendar implementation

Add Shift Scaffolding

  1. duty_day:string
  2. shift_day:datetime

Details for table_builder

  • Easy to make work with rails 3.2.3
  • The only hangup so far is an easy fix; <% calendar_for ... and I added <%= calendar_for
  • As of Midnight; the calendar scrolls months
  • TODO:
    1. Add shifts
    2. colorize shifts
    3. integrate ice_cube for recurrence
    4. figure out how to add different model data to this action

ice_cube integration - Below is best bet as of now

  • Create the shifts in app using the form
  • Use the juno tasks model & controller as a template.
  • Once the shifts are created, disable the form and proceed to next step!
  • USE THIS AS MODEL & CONTROLLER!!! Task Model with IceCube -- The Controller
    class Task < ActiveRecord::Base
      include IceCube

    serialize :options, Hash

    validates_presence_of :action
    validates_presence_of :name
    validates_presence_of :options
    validates_presence_of :schedule
    validates_presence_of :state

    # @return [IceCube::Schedule]
    def schedule
      if read_attribute(:schedule)
        Schedule.from_yaml(read_attribute(:schedule))
      else
        nil
      end
    end

    # @param [IceCube::Schedule]
    def schedule=(value)
      write_attribute(:schedule, value.to_yaml)
    end
  end


    # == Schema Information
    # Schema version: 20100707084131
    #
    # Table name: tasks
    #
    #  id             :integer         not null, primary key
    #  state          :string(255)     not null
    #  action         :string(255)     not null
    #  options        :text            not null
    #  schedule       :text            not null
    #  next_occurence :datetime
    #  created_at     :datetime
    #  updated_at     :datetime
    #  name           :string(255)     not null
    #

Ice_cube examples and shit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment