Esempio n. 1
0
def index(request):
    # теоретические материалы
    theoretics = utils.api_request(
        'engdel/article/tag/{0}.json'.format('theoretics')
    )
    theoretics = json.loads(theoretics)
    # практические материалы
    practice = utils.api_request(
        'engdel/article/tag/{0}.json'.format('practice')
    )
    practice = json.loads(practice)
    # языкознание
    linguistics = utils.api_request(
        'engdel/article/tag/{0}.json'.format('linguistics')
    )
    linguistics = json.loads(linguistics)
    # методолгоия
    methods = _get_tag_articles('methods')
    #психология
    psi = _get_tag_articles('psi')
    return render_to_response(
        'frontend/index.html',
        {
            'theoretics': theoretics[0:settings.FRON_MAX_COUNT_ARTICLES],
            'practice': practice[0:settings.FRON_MAX_COUNT_ARTICLES],
            'linguistics': linguistics[0:settings.FRON_MAX_COUNT_ARTICLES],
            'methods': methods['methods'][0:settings.FRON_MAX_COUNT_ARTICLES],
            'psi': psi['psi'][0:settings.FRON_MAX_COUNT_ARTICLES],
        },
        context_instance=RequestContext(request)
    )
Esempio n. 2
0
def school_job(request, article_name):
    data = _get_tag_articles('school')
    content = utils.api_request(
        'engdel/article/{0}.json'.format(article_name)
    )
    if not content:
        raise Http404
    content = json.loads(content)
    data['about_content'] = content

    if request.method == 'POST': # пару проверок формы
        form = ContactForm(request.POST)
        if form.is_valid():
            messages.add_message(
                request, messages.INFO,
                'Ваши данные сохранены. Мы обязательно с вами свяжемся.'
            )
            form.save() # сохраняем нашу форму в базу
            return redirect('school_job')
    else:
        form = ContactForm()
    data['form'] = form
    return render_to_response(
        'frontend/school/school_job.html',
        data,
        context_instance=RequestContext(request)
    )
Esempio n. 3
0
def _get_tag_articles(tag):
    tag_articles = utils.api_request(
        'engdel/article/tag/{0}.json'.format(tag)
    )
    tag_articles = json.loads(tag_articles)
    return {
        'category': tag,
        tag: tag_articles
    }
Esempio n. 4
0
def word(request, word):
    data = _get_tag_articles('words')
    content = utils.api_request('engdel/article/{0}.json'.format(word))
    if not content:
        raise Http404
    content = json.loads(content)
    data['about_content'] = content
    data['category'] = 'training'
    return render_to_response('frontend/training/word.html',
                              data,
                              context_instance=RequestContext(request))
Esempio n. 5
0
def linguistics(request):
    linguistics = utils.api_request(
        'engdel/article/tag/{0}.json'.format('linguistics')
    )
    linguistics = json.loads(linguistics)
    return render_to_response(
        'frontend/linguistics.html',
        {
            'category': 'linguistics',
            'linguistics': linguistics
        },
        context_instance=RequestContext(request)
    )
Esempio n. 6
0
def practice(request):
    practice = utils.api_request(
        'engdel/article/tag/{0}.json'.format('practice')
    )
    practice = json.loads(practice)
    return render_to_response(
        'frontend/practice.html',
        {
            'category': 'practice',
            'practice': practice
        },
        context_instance=RequestContext(request)
    )
Esempio n. 7
0
def theoretics(request):
    theoretics = utils.api_request(
        'engdel/article/tag/{0}.json'.format('theoretics')
    )
    theoretics = json.loads(theoretics)
    return render_to_response(
        'frontend/theoretics.html',
        {
            'category': 'theoretics',
            'theoretics': theoretics
        },
        context_instance=RequestContext(request)
    )
Esempio n. 8
0
def school(request, article_name):
    data = _get_tag_articles('school')
    content = utils.api_request(
        'engdel/article/{0}.json'.format(article_name)
    )
    if not content:
        raise Http404
    content = json.loads(content)
    data['about_content'] = content
    return render_to_response(
        'frontend/school/school.html',
        data,
        context_instance=RequestContext(request)
    )
Esempio n. 9
0
def word(request, word):
    data = _get_tag_articles('words')
    content = utils.api_request(
        'engdel/article/{0}.json'.format(word)
    )
    if not content:
        raise Http404
    content = json.loads(content)
    data['about_content'] = content
    data['category'] = 'training'
    return render_to_response(
        'frontend/training/word.html',
        data,
        context_instance=RequestContext(request)
    )
Esempio n. 10
0
def article(request, article_name):
    def get_main_tag(tags):
        for tag in settings.MAIN_CATEGORY:
            if tag in tags:
                return tag
        return ''

    content = utils.api_request(
        'engdel/article/{0}.json'.format(article_name)
    )
    if not content:
        raise Http404
    content = json.loads(content)
    if not get_main_tag(content['tags']):
        raise Http404
    return render_to_response(
        'frontend/article.html',
        {
            'content': content,
            'category': get_main_tag(content['tags']),
        },
        context_instance=RequestContext(request)
    )
Esempio n. 11
0
 def get_articles_url(self, category):
     tag_articles = utils.api_request(
         'engdel/article/tag/{0}.json'.format(category)
     )
     tag_articles = json.loads(tag_articles)
     return [art['name'] for art in tag_articles]
Esempio n. 12
0
 def get_articles_url(self, category):
     tag_articles = utils.api_request(
         'engdel/article/tag/{0}.json'.format(category))
     tag_articles = json.loads(tag_articles)
     return [art['name'] for art in tag_articles]