Beispiel #1
0
def copy_course(request):
	request_params = request['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)
	categories = site.categories
	courses = site.courses
	data = {
		'title': 'Созданы курсы',
		'categories': categories,
		'courses': courses,
	}
	content = render('create_course.html', object_list=data)
	code = '202 Accepted'
	return code, content
Beispiel #2
0
	def __call__(self, request):
		logger.log('Прикрепление курсов')
		course_id = int(request['request_params']['course_id'])
		user_id = int(request['request_params']['user_id'])
		course = site.get_course(course_id)
		course_name = course.name
		user = site.find_user_by_id(user_id)
		site.create_personal_course(course_name, course_id, user_id)
		personal_courses, quantity = User.course_count(user)
		User.discount_course(user, quantity)
		courses = site.courses
		data = {
			'title': 'Выбрать пользователя и привязать курсы',
			'user': user,
			'courses': courses,
			'personal_courses': personal_courses,
			'quantity': quantity,
		}
		content = render('view_selected_user.html', object_list=data)
		code = '202 Accepted'
		return code, content
	def __call__(self, request):
		logger.log('Прикрепление курсов')
		user_id = int(request['request_params']['user_id'])
		name_course = request['request_params']['name_course']
		user = site.find_user_by_id(user_id)
		course = site.get_course(name_course)
		user.courses.append(course)
		user.course_count()
		user.discount_course()
		personal_courses = user.courses
		courses = site.courses
		quantity = user.quantity_of_courses
		data = {
			'title': 'Выбрать пользователя и привязать курсы',
			'user': user,
			'courses': courses,
			'personal_courses': personal_courses,
			'quantity': quantity,
		}
		content = render('view_selected_user.html', object_list=data)
		code = '202 Accepted'
		return code, content