def get_contact_view(request):
    links_menu = request.get('links_menu')
    if request['method'] == 'POST':
        data = request['data']
        title = data['title']
        text = data['text']
        email = data['email']
        print(
            f'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n'
            f'Поступило сообщение от {email}:\n'
            f'Тема: {title}\n'
            f'Текст: {text}\n'
            f'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++')
        return '200 OK', render('contact.html', links_menu=links_menu)
    return '200 OK', render('contact.html', links_menu=links_menu)
Exemple #2
0
    def render_template_with_context(self, links_menu):
        template_name = self.get_template()
        context = self.get_context_data()

        return '200 OK', render(template_name,
                                **context,
                                links_menu=links_menu)
Exemple #3
0
def create_course(request):
    if request['method'] == 'POST':
        data = request['data']
        name = data['name']
        name = Application.decode_value(name)
        category_id = data.get('category_id')
        category = None
        if category_id:
            category = site.find_category_by_id(int(category_id))
            course = site.create_course('record', name, category)
            course.observers.append(email_notifier)
            course.observers.append(sms_notifier)
            site.courses.append(course)
        categories = site.categories
        return '200 OK', render('create_course.html', categories=categories)
    else:
        categories = site.categories
        return '200 OK', render('create_course.html', categories=categories)
Exemple #4
0
def get_about_view(request):
    addresses = [
        'Москва, ул. Ударная, 13', 'Санкт-Петербург, ул. Моховая, 23',
        'Казань, пр. Мира, 10'
    ]
    links_menu = request.get('links_menu')
    return '200 OK', render('about.html',
                            objects_list=addresses,
                            links_menu=links_menu)
def create_course(request):
    links_menu = request.get('links_menu')
    if request['method'] == 'POST':
        data = request['data']
        name = data['name']
        name = App.decode_value(name)
        category_id = data.get('category_id')
        if category_id:
            category = site.find_category_by_id(int(category_id))
            course = site.create_course('record', name, category)
            course.observers.append(email_notifier)
            course.observers.append(sms_notifier)
            site.courses.append(course)
        categories = site.categories
        logger.log(f'Создаем новый курс {name}')
        return '200 OK', render('create_course.html', links_menu=links_menu)
    else:
        categories = site.categories
        return '200 OK', render('create_course.html', categories=categories,
                                links_menu=links_menu)
Exemple #6
0
def copy_course(request):
    request_params = request['request_params']
    name = request_params['name']
    name = Application.decode_value(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)
def copy_course(request):
    logger.log('Копируем курс')
    links_menu = request.get('links_menu')
    request_params = request['request_params']
    name = request_params['name']
    old_course = site.get_course(name)
    if old_course:
        new_name = f'копия_курса_{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,
                            links_menu=links_menu)
def get_index_view(request):
    logger.log('Получаем главную страницу')
    links_menu = request.get('links_menu')
    return '200 OK', render('index.html', links_menu=links_menu)
Exemple #9
0
def main_view(request):
    logger.log('Список курсов')
    return '200 OK', render('course_list.html', objects_list=site.courses)