def restore_group_meetings(json):
    for group_meeting in json:
        group_year = GroupYear.get(group=group_meeting["group"], year="active")
        GroupMeeting(group=group_year,
                     meeting=UUID(group_meeting["meeting"]),
                     code=UUID(group_meeting["code"]))
    arr = GroupMeeting.select()[:]
    print("===RESTORED {0} {1}===".format(len(arr), "GroupMeetings"))
Beispiel #2
0
def get_active_group_email_datas_for_meeting(
        meeting_id: UUID) -> List[GroupMeetingEmailData]:
    group_meetings = list(
        GroupMeeting.select(
            lambda group_meeting: group_meeting.meeting.id == meeting_id and
            group_meeting.group.year == "active"))

    gm_email_datas = []
    for group_meeting in group_meetings:
        m = group_meeting.meeting
        group = group_meeting.group.group
        task_names = get_tasks_for_group_meeting(group_meeting)

        gm_email_datas.append(
            GroupMeetingEmailData(meeting=MeetingData(
                id=m.id,
                year=m.year,
                date=m.date,
                last_upload=m.last_upload,
                lp=m.lp,
                meeting_no=m.meeting_no),
                                  group_name=group.name,
                                  group_year=group_meeting.group.year,
                                  group_display_name=group.display_name,
                                  group_code=group_meeting.code,
                                  task_names=task_names))

    return gm_email_datas
def restore_group_meeting_tasks(json):
    for group_meeting_task in json:
        group = GroupYear.get(group=group_meeting_task["group"], year="active")
        meeting = UUID(group_meeting_task["meeting"])
        group_meeting = GroupMeeting.get(group=group, meeting=meeting)
        GroupMeetingTask(group=group_meeting, task=group_meeting_task["task"])
    arr = GroupMeetingTask.select()[:]
    print("===RESTORED {0} {1}===".format(len(arr), "GroupMeetingTasks"))
def create_group_meeting(meeting_id: uuid, group_name: str,
                         year: str) -> GroupMeeting:
    group = get_group_year(group_name, year)
    group_meeting = get_group_meeting(meeting_id=meeting_id,
                                      group_name=group_name,
                                      year=year)
    if group_meeting is None:
        group_meeting = GroupMeeting(meeting=meeting_id, group=group)
    return group_meeting
def get_group_meetings():
    arr = []
    group_meetings = GroupMeeting.select()
    for meeting in group_meetings:
        arr.append({
            "group": meeting.group.name,
            "meeting": str(meeting.meeting.id),
            "code": str(meeting.code)
        })

    print("===SAVING {0} {1}===".format(len(arr), "GroupMeetings"))
    return arr
def restore_group_meeting_files(json):
    for group_meeting_file in json:
        group_year = GroupYear.get(group=group_meeting_file["group"],
                                   year="active")
        group_meeting = GroupMeeting.get(group=group_year,
                                         meeting=UUID(
                                             group_meeting_file["meeting"]))
        group_task = GroupMeetingTask.get(group=group_meeting,
                                          task=group_meeting_file["task"])
        date = datetime.strptime(group_meeting_file["date"], date_format)
        GroupMeetingFile(group_task=group_task,
                         file_location=group_meeting_file["file_location"],
                         date=date)
    arr = GroupMeetingFile.select()[:]
    print("===RESTORED {0} {1}===".format(len(arr), "GroupMeetingFile"))
def get_group_meeting_by_code(code: UUID) -> Optional[GroupMeeting]:
    return GroupMeeting.get(code=code)
def get_group_meeting(meeting_id: UUID, group_name: str,
                      year: str) -> Optional[GroupMeeting]:
    group_year = get_group_year(group_name, year)
    return GroupMeeting.get(group=group_year, meeting=meeting_id)