Example #1
0
def entry_list(request, type_db=None, category_slug=None):
    lang = request.LANGUAGE_CODE
    templates = ["migdal/entry/entry_list.html"]

    if type_db:
        if app_settings.TYPES_ON_MAIN == (type_db,):
            return redirect('migdal_main')
        entry_type = app_settings.TYPES_DICT[type_db]
        templates = ["migdal/entry/%s/entry_list.html" % type_db] + templates
        submit = type_db == app_settings.TYPE_SUBMIT
    else:
        submit = app_settings.TYPES_ON_MAIN == (app_settings.TYPE_SUBMIT,)
        entry_type = None

    if category_slug:
        category = get_object_or_404(Category, **{'slug_%s' % lang: category_slug})
    else:
        category = None

    if category:
        set_current_object(request, category)

    promobox = 5 if entry_type is None and category is None else None

    object_list = api.entry_list(entry_type=entry_type, category=category, promobox=promobox)

    return render(request, templates, {
            'object_list': object_list,
            'category': category,
            'entry_type': entry_type,
            'submit': submit,
        })
Example #2
0
def entry(request, type_db=None, slug=None, entry=None):
    if entry is None:
        lang = request.LANGUAGE_CODE
        args = {'type': type_db, 'slug_%s' % lang: slug}
        entry = get_object_or_404(Entry, **args)
    if not entry.published and not request.user.has_perm('migdal.change_entry'):
        raise Http404
    set_current_object(request, entry, in_url=slug is not None)

    templates = ["migdal/entry/entry_detail.html"]
    if entry.type is not None:
        templates = ["migdal/entry/%s/entry_detail.html" % type_db] + templates
    return render(request, templates, {'entry': entry})