Пример #1
0
def pagemap(request):
    pe_i = pe(In)
    pe_b = pe(B)
    pe_f = pe(F)
    api = ActivePageItems(request, B, pytz, datetime)
    active_blogs = api.active_items
    api = ActivePageItems(request, In, pytz, datetime)
    active_infos = api.active_items
    api = ActivePageItems(request, F, pytz, datetime)
    active_files = api.active_items
    if request.user.is_authenticated:
        userlevel = request.user.role_council
        if userlevel > 0:
            active_blogs = pe_b.listed
            active_infos = pe_i.listed
            active_files = pe_f.listed
    context = {
        'blogs': active_blogs,
        'infos': active_infos,
        'files': active_files,
    }
    pl = PageLoad(P, L)
    context_lazy = pl.lazy_context(skins=S, context=context)
    template = 'strona/pagemap.html'
    return render(request, template, context_lazy)
Пример #2
0
def blog(request, blog_id):
    pe_b = pe(B)
    pe_b_id = pe_b.by_id(G404=G404, id=blog_id)
    pe_i = pe(In)
    pe_f = pe(F)
    context = {
        'blog': pe_b_id,
        'infos': pe_i.elements,
        'files': pe_f.elements,
    }
    pl = PageLoad(P, L)
    context_lazy = pl.lazy_context(skins=S, context=context)
    template = 'strona/blog.html'
    return render(request, template, context_lazy)
Пример #3
0
def change_element(request, form_type, form_id):
    userdata = User.objects.get(id=request.user.id)
    # form_type = request.session['element_type']
    # form_id = int(request.session['element_id'])
    formdict = {
        'blog': BlogForm,
        'info': InfoForm,
        'file': FileserveForm,
    }
    elemdict = {
        'blog': Blog,
        'info': Info,
        'file': Fileserve,
    }
    form_from_dict = formdict[form_type]
    element = elemdict[form_type]
    if request.method == 'POST':
        # form_from_dict = formdict[form_type]
        form = form_from_dict(data=request.POST, files=request.FILES)
        if form.is_valid():
            form.save(userdata)
            return redirect('staffpanel_c')
    else:
        instance = G404(element, id=form_id)
        # form = formdict[form_type]
        form = form_from_dict(instance=instance)
        pe_fi = pe(FormItems)
        pe_fe = pe(FormElement)
    pe_fi = pe(FormItems)
    context = {
        'diff': form_type,
        'udata': userdata,
        'form': form,
        'formitem': pe_fi.baseattrs,
        'f_item': pe_fe.baseattrs,
    }
    pl = PortalLoad(
        P,
        L,
        Pbi,
        1,
        Cmi,
        Cli,
    )
    context_lazy = pl.lazy_context(skins=S, context=context)
    template = 'strona/manage/makeelement.html'
    return render(request, template, context_lazy)
Пример #4
0
def make_element(request, form_type):
    userdata = User.objects.get(id=request.user.id)
    create = True
    formdict = {
        'blog': BlogForm,
        'info': InfoForm,
        'file': FileserveForm,
    }
    if request.method == 'POST':
        form_from_dict = formdict[form_type]
        form = form_from_dict(request.POST, request.FILES)
        if form.is_valid():
            form.save(userdata)
            return redirect('staffpanel_c')
    else:
        form = formdict[form_type]
        pe_fi = pe(FormItems)
        pe_fe = pe(FormElement)
    pe_fi = pe(FormItems)
    context = {
        'creator_form': create,
        'diff': form_type,
        'udata': userdata,
        'form': form,
        'formitem': pe_fi.baseattrs,
        'f_item': pe_fe.baseattrs,
    }
    pl = PortalLoad(
        P,
        L,
        Pbi,
        1,
        Cmi,
        Cli,
    )
    context_lazy = pl.lazy_context(skins=S, context=context)
    template = 'strona/manage/makeelement.html'
    return render(request, template, context_lazy)