Method: Osm::Activity#add_to_programme

Defined in:
lib/osm/activity.rb

#add_to_programme(api, section, date, notes = "") ⇒ Boolean

Add this activity to the programme in OSM

Parameters:

  • api (Osm::Api)

    The api to use to make the request

  • section (Osm::Section, Fixnum, #to_i)

    The Section (or it’s ID) to add the Activity to

  • date (Date, DateTime)

    The date of the Evening to add the Activity to (OSM will create the Evening if it doesn’t already exist)

  • notes (String) (defaults to: "")

    The notes which should appear for this Activity on this Evening

Returns:

  • (Boolean)

    Whether the activity was successfully added



207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/osm/activity.rb', line 207

def add_to_programme(api, section, date, notes="")
  require_ability_to(api, :write, :programme, section)

  data = api.perform_query("programme.php?action=addActivityToProgramme", {
    'meetingdate' => date.strftime(Osm::OSM_DATE_FORMAT),
    'activityid' => id,
    'sectionid' => section.to_i,
    'notes' => notes,
  })

  if (data == {'result'=>0})
    # The cached activity will be out of date - remove it
    cache_delete(api, ['activity', self.id])
    return true
  else
    return false
  end
end