Example #1
0
def student_create(request):
    data = request['params_post']
    if data:
        name = data['name']
        new_obj = site.create_user('student', name)
        site.students.append(new_obj)
    return '200 OK', render('create_student.html')
Example #2
0
def copy_course(request):
    request_params = request['params_get']
    print(request_params)
    name = request_params['name']
    old_course = site.get_course(name)
    if old_course:
        new_name = f'copy_{name}'
        new_course = old_course.clone()
        new_course.name = new_name
        site.courses.append(new_course)

    return '200 OK', render('course_list.html', objects_list=site.courses)
Example #3
0
def create_category(request):
    categories = site.categories
    if request['method'] == 'POST':
        data = request['params_post']
        name = data['name']
        category_id = data.get('category_id')
        category = None
        if category_id:
            category = site.find_category_by_id(int(category_id))

        new_category = site.create_category(name, category)
        site.categories.append(new_category)
    return '200 OK', render('create_category.html', categories=categories)
Example #4
0
def create_course(request):
    categories = site.categories
    if request['method'] == 'POST':
        data = request['params_post']
        name = data['name']
        category_id = data.get('category_id')
        print(category_id)
        category = None
        if category_id:
            category = site.find_category_by_id(int(category_id))
            course = site.create_course('record', name, category)
            site.courses.append(course)
    return '200 OK', render('create_course.html', categories=categories)
Example #5
0
def add_student_by_course(request):
    data = request['params_post']
    if data:
        add_student = data['student_name']
        add_course = data['course_name']
        student = site.get_student(add_student)
        course = site.get_course(add_course)
        student.courses.append(course)

    students = site.students
    courses = site.courses
    return '200 OK', render('add_student.html',
                            students=students,
                            courses=courses)
Example #6
0
def main_view(request):
    logger.log(f'Список курсов: {site.courses}')
    return '200 OK', render('course_list.html', objects_list=site.courses)
Example #7
0
def student_list(request):
    return '200 OK', render('student_list.html', objects_list=site.students)
Example #8
0
def category_list(request):
    logger.log('Список категорий')
    return '200 OK', render('category_list.html', objects_list=site.categories)