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"))
Esempio n. 2
0
def create_group_meeting_task(meeting_id: UUID, group_name: str, year: str,
                              task_name: str) -> Optional[GroupMeetingTask]:
    group_meeting_task = get_group_meeting_task(meeting_id, group_name, year,
                                                task_name)
    if group_meeting_task is None:
        group = get_group_meeting(meeting_id, group_name, year)
        task = get_task_by_name(task_name)
        group_meeting_task = GroupMeetingTask(group=group, task=task)
    return group_meeting_task
Esempio n. 3
0
def get_tasks_for_meeting(meeting_id: UUID) -> List[GroupTaskData]:
    group_tasks = GroupMeetingTask.select(
        lambda g_t: g_t.group.meeting.id == meeting_id)[:]
    group_task_datas = []
    for group_task in group_tasks:
        if group_task.task.name != "vberattelse" and group_task.task.name != "eberattelse":
            group_task_datas.append(
                GroupTaskData(group_task.group.group.group.name,
                              group_task.group.code, group_task.task.name))

    return group_task_datas
def get_group_meeting_tasks():
    arr = []
    group_meeting_tasks = GroupMeetingTask.select()
    for group_meeting_task in group_meeting_tasks:
        arr.append({
            "group": group_meeting_task.group.group.name,
            "meeting": str(group_meeting_task.group.meeting.id),
            "task": group_meeting_task.task.name
        })

    print("===SAVING {0} {1}===".format(len(arr), "GroupMeetingTasks"))
    return arr
Esempio n. 5
0
def get_tasks_for_meeting_bool_dict(
        meeting_id: UUID) -> Dict[GroupMeetingTask, bool]:
    """
    Returns a dictionary from each GroupMeetingTask of the given meeting to a boolean with value False
    """
    group_tasks = {}
    db_tasks = GroupMeetingTask.select(
        lambda g_t: g_t.group.meeting.id == meeting_id)
    for task in db_tasks:
        group_tasks[task] = False

    return group_tasks
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"))
Esempio n. 7
0
def get_group_meeting_task_from_code(code: UUID,
                                     task: str) -> GroupMeetingTask:
    group_meeting = get_group_meeting_by_code(code)
    return GroupMeetingTask.get(group=group_meeting, task=task)
Esempio n. 8
0
def get_group_meeting_task(meeting_id: UUID, group_name: str, year: str,
                           task_name: str) -> Optional[GroupMeetingTask]:
    task = get_task_by_name(task_name)
    group = get_group_meeting(meeting_id, group_name, year)
    return GroupMeetingTask.get(group=group, task=task)