Ejemplo n.º 1
0
def enroll_user_in_madrassa(user, madrassa_detail, role, enrollment_date):
    already_enrolled, enrollment = user_already_enrolled(user, madrassa_detail, role)
    if already_enrolled:
        return False, USER_ALREADY_ENROLLED, f"User Already enrolled. Enrollment ID {enrollment[gc.ID]}"

    max_index = select_max(ENROLLMENT)
    if max_index is None:
        return [], FAIL, "FAIL"

    index = select_max(ENROLLMENT) + 1
    r = enroll_user_in_madrassa_by_id(index, user, madrassa_detail, role, enrollment_date)
    if r:
        return r, SUCCESS, "Success"
    return r, FAIL, "Fail"
Ejemplo n.º 2
0
def set_new_madrassa_details(shift_id, course_id, madrassa_id):
    shift = find_shift_by_id(shift_id)
    if shift is None:
        return [], SHIFT_NOT_FOUND, "Shift Not Found"

    course = find_course_by_id(course_id)
    if course is None:
        return [], COURSE_NOT_FOUND, "Course Not Found"

    madrassa = find_madrassa_by_id(madrassa_id)
    if madrassa is None:
        return [], MADRASSA_NOT_FOUND, "Madrassa Not Found"

    madrassa_detail = find_madrassa_detail_by_shift_course_madrassa(
        shift_id, course_id, madrassa_id)
    if madrassa_detail:
        return [], ALREADY_EXIST, f"Madrassa_details already exist with id={madrassa_detail[gc.ID]}"

    max_index = select_max(MADRASSA_DETAILS)
    if max_index is None:
        return [], FAIL, "FAIL"

    index = max_index + 1
    r = insert_madrassa_detail_by_id(index, shift_id, course_id, madrassa_id)
    if r:
        data = get_madrassa_detail_by_id(index)
        return data, SUCCESS, "SUCCESS"
    return [], FAIL, "FAIL"
Ejemplo n.º 3
0
def add_new_status(status):
    max_index = select_max(ATTENDANCE)
    if max_index is None:
        return False
    index = max_index + 1
    r = insert_new_attendance_status_by_id(index, status)
    if r:
        status = find_attendance_status_id_by_name(status)
        return status
    return False
Ejemplo n.º 4
0
def add_new_role(name):
    max_index = select_max(ROLE)
    if max_index is None:
        return [], FAIL, "FAIL"
    index = max_index + 1
    r = insert_role_by_id(index, name)
    if r:
        role = find_role_by_id(index)
        return role, SUCCESS, "SUCCESS"
    return [], FAIL, "FAIL"
Ejemplo n.º 5
0
def add_new_gender(name):
    max_index = select_max(GENDER)
    if max_index is None:
        return [], FAIL, "FAIL"

    index = max_index + 1
    r = insert_gender_by_id(index, name)
    if r:
        gender = find_gender_by_id(index)
        return gender, SUCCESS, "SUCCESS"
    return [], FAIL, "FAIL"
Ejemplo n.º 6
0
def add_new_course(name):
    max_index = select_max(COURSE)
    if max_index is None:
        return [], FAIL, "FAIL"

    index = max_index + 1
    r = insert_course_by_id(index, name)
    if r:
        course = find_course_by_id(index)
        return course, SUCCESS, "SUCCESS"
    return [], FAIL, "FAIL"
Ejemplo n.º 7
0
def add_new_madrassa(name):
    max_index = select_max(MADRASSA)
    if max_index is None:
        return [], FAIL, "FAIL"

    index = max_index + 1
    r = insert_madrassa_by_id(index, name)
    if r:
        madrassa = find_madrassa_by_id(index)
        return madrassa, SUCCESS, "SUCCESS"
    return [], FAIL, "FAIL"
Ejemplo n.º 8
0
def add_new_shift(name, start_time, end_time):
    max_index = select_max(SHIFT)
    if max_index is None:
        return [], FAIL, "FAIL"

    index = max_index + 1
    r = insert_shift_by_id(index, name, start_time, end_time)
    if r:
        shift = find_shift_by_id(index)
        return shift, SUCCESS, "SUCCESS"
    return [], FAIL, "FAIL"
Ejemplo n.º 9
0
def create_attendance_for_enrollment_at_date(enrollment_id, date):
    max_index = select_max(ATTENDANCE_RECORD)
    if max_index is None:
        return False
    index = max_index + 1
    status = find_attendance_status_id_by_name(DEFAULT_ATTENDANCE_STATUS)
    if status is None:
        status = add_new_status(DEFAULT_ATTENDANCE_STATUS)

    if not status:
        return False
    r = insert_attendance_record_by_id(index, date, enrollment_id,
                                       status[gc.ID])
    return r
Ejemplo n.º 10
0
def add_new_user(user):
    # importing here due to circular import error

    from helper.gender import find_gender_by_id
    gender = find_gender_by_id(user[gc.GENDER_ID])
    if gender is None:
        return [], GENDER_NOT_FOUND, "gender Not Found"

    max_index = select_max(USER)
    if max_index is None:
        return [], FAIL, "FAIL"

    index = max_index + 1
    r = insert_user_by_id(index, user)
    if r:
        user = find_user_by_id(index)
        return user, SUCCESS, "SUCCESS"
    return [], FAIL, "FAIL"