Sha256: bdf19c03fdfa0de4c51d2ecdda2430fc226a4f2ba5784eb42355dbba5cbaa8fc
Contents?: true
Size: 1.36 KB
Versions: 53
Compression:
Stored size: 1.36 KB
Contents
module ContentProviders # Provides multiple forms for a Participant to enter past Activities. class PastActivityForm < BitCore::ContentProvider def render_current(options) participant = options.view_context.current_participant options.view_context.render( template: "think_feel_do_engine/activities/past_activity_form", locals: { timestamps: timestamps(participant), activity: participant.activities.build, create_path: options.view_context.participant_data_path } ) end def data_attributes [ :start_time, :end_time, :activity_type_title, :actual_pleasure_intensity, :actual_accomplishment_intensity ] end def data_class_name "Activity" end def show_nav_link? false end private def most_recent_awake_period(participant) if participant.unfinished_awake_periods.exists? participant.most_recent_unfinished_awake_period else participant.awake_periods.last end end def timestamps(participant) period = most_recent_awake_period(participant) start_time, end_time = period.start_time, period.end_time times = [] (start_time.to_i..(end_time.to_i - 1.hour)).step(1.hour) do |timestamp| times << timestamp end times end end end
Version data entries
53 entries across 53 versions & 1 rubygems