def to_api_json(self):
     return {
         'id': self.id,
         'jobKey': self.job_key,
         'failed': self.failed,
         'startedAt': to_isoformat(self.started_at),
         'finishedAt': self.finished_at and to_isoformat(self.finished_at),
     }
Exemple #2
0
 def to_api_json(self):
     return {
         'id': self.id,
         'templateType': self.template_type,
         'typeName': self.get_template_type_options()[self.template_type],
         'name': self.name,
         'subjectLine': self.subject_line,
         'message': self.message,
         'createdAt': to_isoformat(self.created_at),
         'updatedAt': to_isoformat(self.updated_at),
     }
Exemple #3
0
    def to_api_json(self):
        def _format(date):
            return localize_datetime(date).strftime('%Y-%m-%d')

        return {
            'id': self.id,
            'name': self.name,
            'startDate': _format(self.start_date),
            'endDate': _format(self.end_date),
            'createdAt': to_isoformat(self.created_at),
            'updatedAt': to_isoformat(self.updated_at),
        }
Exemple #4
0
 def to_api_json(self):
     return {
         'id': self.id,
         'disabled': self.disabled,
         'key': self.key,
         'schedule': {
             'type':
             self.job_schedule_type,
             'value':
             int(self.job_schedule_value) if self.job_schedule_type
             in ['minutes', 'seconds'] else self.job_schedule_value,
         },
         'createdAt': to_isoformat(self.created_at),
         'updatedAt': to_isoformat(self.updated_at),
     }
Exemple #5
0
 def to_api_json(self):
     if self.capability == 'screencast':
         recording_types = ['presentation_audio']
     else:
         recording_types = ALL_RECORDING_TYPES.keys(
         ) if self.is_auditorium else ['presenter_presentation_audio']
     return {
         'id':
         self.id,
         'location':
         self.location,
         'capability':
         self.capability,
         'capabilityName':
         self.get_room_capability_options()[self.capability]
         if self.capability else None,
         'createdAt':
         to_isoformat(self.created_at),
         'isAuditorium':
         self.is_auditorium,
         'kalturaResourceId':
         self.kaltura_resource_id,
         'recordingTypeOptions':
         {type_: ALL_RECORDING_TYPES[type_]
          for type_ in recording_types},
     }
Exemple #6
0
 def to_api_json(self):
     if self.capability == 'screencast':
         recording_type_options = {'presentation_audio': 'Audio + Projection'}
     else:
         premium_cost = app.config['COURSE_CAPTURE_PREMIUM_COST']
         camera_with_operator_label = f'Audio + Projection + Camera with Operator (${premium_cost})'
         camera_without_operator_label = 'Audio + Projection + Camera without Operator'
         if self.is_auditorium:
             recording_type_options = {
                 'presenter_presentation_audio_with_operator': camera_with_operator_label,
                 'presenter_presentation_audio': camera_without_operator_label,
             }
         else:
             recording_type_options = {
                 'presenter_presentation_audio': camera_without_operator_label,
             }
     return {
         'id': self.id,
         'location': self.location,
         'capability': self.capability,
         'capabilityName': self.get_room_capability_options()[self.capability] if self.capability else None,
         'createdAt': to_isoformat(self.created_at),
         'isAuditorium': self.is_auditorium,
         'kalturaResourceId': self.kaltura_resource_id,
         'recordingTypeOptions': recording_type_options,
     }
Exemple #7
0
 def to_api_json(self):
     recording_type_options = {
         'presentation_audio': 'Presentation + Audio',
     }
     if self.is_auditorium:
         recording_type_options['presenter_audio'] = 'Presenter + Audio'
         recording_type_options[
             'presenter_presentation_audio'] = 'Presenter + Presentation + Audio'
     return {
         'id':
         self.id,
         'location':
         self.location,
         'capability':
         self.capability,
         'capabilityName':
         self.get_room_capability_options()[self.capability]
         if self.capability else None,
         'createdAt':
         to_isoformat(self.created_at),
         'isAuditorium':
         self.is_auditorium,
         'kalturaResourceId':
         self.kaltura_resource_id,
         'recordingTypeOptions':
         recording_type_options,
     }
Exemple #8
0
 def to_api_json(self):
     return {
         'sectionId': self.section_id,
         'termId': self.term_id,
         'crossListedSectionIds': self.cross_listed_section_ids,
         'createdAt': to_isoformat(self.created_at),
     }
 def to_api_json(self):
     return {
         'termId': self.term_id,
         'sectionId': self.section_id,
         'hasOptedOut': self.has_opted_out,
         'createdAt': to_isoformat(self.created_at),
     }
Exemple #10
0
 def to_api_json(self):
     return {
         'canvasCourseSiteId': self.canvas_course_site_id,
         'canvasCourseSiteName': self.canvas_course_site_name,
         'sectionId': self.section_id,
         'termId': self.term_id,
         'createdAt': to_isoformat(self.created_at),
     }
Exemple #11
0
 def to_api_json(self):
     return {
         'id': self.id,
         'sectionId': self.section_id,
         'templateType': self.template_type,
         'templateTypeName': EmailTemplate.get_template_type_options()[self.template_type],
         'termId': self.term_id,
         'createdAt': to_isoformat(self.created_at),
     }
Exemple #12
0
 def to_api_json(self, rooms_by_id=None):
     room_feed = None
     if self.room_id:
         if rooms_by_id:
             room_feed = rooms_by_id.get(self.room_id, None).to_api_json()
         else:
             room_feed = Room.get_room(self.room_id).to_api_json()
     formatted_days = format_days(self.meeting_days)
     return {
         'id':
         self.id,
         'alerts':
         self.alerts or [],
         'createdAt':
         to_isoformat(self.created_at),
         'instructorUids':
         self.instructor_uids,
         'kalturaScheduleId':
         self.kaltura_schedule_id,
         'meetingDays':
         formatted_days,
         'meetingDaysNames':
         get_names_of_days(formatted_days),
         'meetingEndDate':
         datetime.strftime(self.meeting_end_date, '%Y-%m-%d'),
         'meetingEndTime':
         self.meeting_end_time,
         'meetingEndTimeFormatted':
         format_time(self.meeting_end_time),
         'meetingStartDate':
         datetime.strftime(self.meeting_start_date, '%Y-%m-%d'),
         'meetingStartTime':
         self.meeting_start_time,
         'meetingStartTimeFormatted':
         format_time(self.meeting_start_time),
         'publishType':
         self.publish_type,
         'publishTypeName':
         NAMES_PER_PUBLISH_TYPE[self.publish_type],
         'recordingType':
         self.recording_type,
         'recordingTypeName':
         NAMES_PER_RECORDING_TYPE[self.recording_type],
         'room':
         room_feed,
         'sectionId':
         self.section_id,
         'termId':
         self.term_id,
     }
Exemple #13
0
 def to_api_json(self):
     return {
         'approvedBy': get_calnet_user_for_uid(app, self.approved_by_uid),
         'wasApprovedByAdmin': self.approver_type == 'admin',
         'createdAt': to_isoformat(self.created_at),
         'crossListedSectionIds': self.cross_listed_section_ids,
         'publishType': self.publish_type,
         'publishTypeName': NAMES_PER_PUBLISH_TYPE[self.publish_type],
         'recordingType': self.recording_type,
         'recordingTypeName': NAMES_PER_RECORDING_TYPE[self.recording_type],
         'room': Room.get_room(self.room_id).to_api_json()
         if self.room_id else None,
         'sectionId': self.section_id,
         'termId': self.term_id,
     }
Exemple #14
0
 def to_api_json(self):
     return {
         'id':
         self.id,
         'recipientUids':
         self.recipient_uids,
         'sectionId':
         self.section_id,
         'templateType':
         self.template_type,
         'templateTypeName':
         EmailTemplate.get_template_type_options()[self.template_type],
         'termId':
         self.term_id,
         'sentAt':
         to_isoformat(self.sent_at),
     }
Exemple #15
0
 def to_api_json(self):
     return {
         'createdAt': to_isoformat(self.created_at),
         'crossListedSectionIds': self.cross_listed_section_ids,
         'instructorUids': self.instructor_uids,
         'meetingDays': format_days(self.meeting_days),
         'meetingEndTime': format_time(self.meeting_end_time),
         'meetingStartTime': format_time(self.meeting_start_time),
         'publishType': self.publish_type,
         'publishTypeName': NAMES_PER_PUBLISH_TYPE[self.publish_type],
         'recordingType': self.recording_type,
         'recordingTypeName': NAMES_PER_RECORDING_TYPE[self.recording_type],
         'room': Room.get_room(self.room_id).to_api_json()
         if self.room_id else None,
         'sectionId': self.section_id,
         'termId': self.term_id,
     }
def job_schedule():
    api_json = {
        'autoStart': app.config['JOBS_AUTO_START'],
        'jobs': [],
        'secondsBetweenJobsCheck':
        app.config['JOBS_SECONDS_BETWEEN_PENDING_CHECK'],
        'startedAt': to_isoformat(background_job_manager.get_started_at()),
    }
    for job in Job.get_all(include_disabled=True):
        job_class = next(
            (j for j in BackgroundJobManager.available_job_classes()
             if j.key() == job.key), None)
        if job_class:
            api_json['jobs'].append({
                **job.to_api_json(),
                **_job_class_to_json(job_class),
            })
    return tolerant_jsonify(api_json)
Exemple #17
0
 def to_api_json(self, rooms_by_id=None):
     room_feed = None
     if self.room_id:
         if rooms_by_id:
             room_feed = rooms_by_id.get(self.room_id, None).to_api_json()
         else:
             room_feed = Room.get_room(self.room_id).to_api_json()
     return {
         'approvedBy': get_calnet_user_for_uid(app, self.approved_by_uid),
         'wasApprovedByAdmin': self.approver_type == 'admin',
         'createdAt': to_isoformat(self.created_at),
         'publishType': self.publish_type,
         'publishTypeName': NAMES_PER_PUBLISH_TYPE[self.publish_type],
         'recordingType': self.recording_type,
         'recordingTypeName': NAMES_PER_RECORDING_TYPE[self.recording_type],
         'room': room_feed,
         'sectionId': self.section_id,
         'termId': self.term_id,
     }