Esempio n. 1
0
def allelements(request, elem_type):
    elemdict = {
        'blog': Blog,
        'info': Info,
        'file': Fileserve,
    }
    element = elemdict[elem_type]
    api = ActivePageItems(request, element, pytz, datetime)
    active_elements = api.active_items
    addvariable = 'add' + elem_type
    varimagedefault = elem_type + 'imagedefault'
    context = {
        'addvar': addvariable,
        'varimgdef': varimagedefault,
        'element_type': elem_type,
        'elements': active_elements,
    }
    pl = PortalLoad(
        P,
        L,
        Pbi,
        1,
        Cmi,
        Cli,
    )
    context_lazy = pl.lazy_context(skins=S, context=context)
    template = 'strona/manage/allelements.html'
    return render(request, template, context_lazy)
Esempio n. 2
0
def allapplied(request):
    view_filter = ["-timeapplied", "owner__last_name", "status"]
    if 'sort' in request.POST:
        x = 0
        while x < 3:
            view_filter[x] = str(request.POST.get('view_filter'+str(x)))
            x = x+1
    apf = Apf.objects.order_by(view_filter[0], view_filter[1], view_filter[2])
    peqc = PageElement(QuarterClassB)
    aps = PageElement(Aps)
    ifr = PageElement(Ifr)
    sh = PageElement(Sh)
    pe_fi = PageElement(FormItems)
    ali = PageElement(Ali)
    att = PageElement(Att)
    context = {
     'applied': apf,
     'view_filter': view_filter,
     'setter': peqc.listed,
     'appstatus': aps.listed,
     'roomchange': ifr.listed,
     'hotelselector': sh.listed,
     'formitem': pe_fi.baseattrs,
     'applist': ali.listed,
     'attools': att.baseattrs,
     }
    pl = PortalLoad(P, L, Pbi, 1, Cmi, Cli, )
    context_lazy = pl.lazy_context(skins=S, context=context)
    template = 'panels/council/allapplied.html'
    return render(request, template, context_lazy)
Esempio n. 3
0
def allusers(request):
    query = request.GET.get('q', None)
    view_filter = ["-last_name", "first_name", "quarter"]
    if 'sort' in request.POST:
        x = 0
        while x < 3:
            view_filter[x] = str(request.POST.get('view_filter'+str(x)))
            x = x+1
    usr = User.objects.order_by(view_filter[0], view_filter[1], view_filter[2])
    if query is not None:
        usr = usr.filter(
         Q(first_name__icontains=query)|
         Q(last_name__icontains=query)|
         Q(citizenship__icontains=query))
    pe_fi = PageElement(FormItems)
    peqc = PageElement(QuarterClassB)
    usli = PageElement(Usli)
    att = PageElement(Att)
    context = {
     'userdetails': usr,
     'setter': peqc.listed,
     'view_filter': view_filter,
     'formitem': pe_fi.baseattrs,
     'userlist': usli.listed,
     'attools': att.baseattrs,
     }
    pl = PortalLoad(P, L, Pbi, 1, Cmi, Cli, )
    context_lazy = pl.lazy_context(skins=S, context=context)
    template = 'panels/council/allusers.html'
    return render(request, template, context_lazy)
Esempio n. 4
0
def allparties(request):
    userdata = User.objects.get(
     id=request.user.id)
    view_filter = "2"
    if 'subbutton' in request.POST:
        view_filter = str(request.POST.get('view_filter'))
    elif 'changeparty' in request.POST:
        request.session['partyid'] = request.POST.get('partyid')
        return redirect('changemeparty')
    elif 'apply_spontaneously' in request.POST:
        form = IniForm(request.POST, instance=userdata)
        if form.is_valid():
            form.save()
            return redirect('dsapply')
    ap = AllParties(
     request, HParty, pytz, datetime, FormItems, Hpi, QuarterClassB,
     view_filter=view_filter, )
    userlevel = request.user.role_council
    if userlevel > 1:
        userlevel = 1
    cmenu = [1, Cmi, Cli]
    umenu = [0, Umi, Uli]
    menusdict = menu_switcher(cmenu, umenu)
    userkey = 'menu'+str(userlevel)
    d_num = menusdict[userkey][0]
    d_menu = menusdict[userkey][1]
    d_list = menusdict[userkey][2]
    pl = PortalLoad(P, L, Pbi, d_num, d_menu, d_list)
    context_lazy = pl.lazy_context(skins=S, context=ap.context)
    template = 'panels/common/allparties.html'
    return render(request, template, context_lazy)
Esempio n. 5
0
def showmydata(request):
    userdata = User.objects.get(id=request.user.id)
    if request.method == 'POST':
        form = IniForm(request.POST, instance=userdata)
        if form.is_valid():
            form.save()
            return redirect('userdatapersonal')
    else:
        pe_fi = PageElement(FormItems)
        peqc = PageElement(QuarterClassB)
        form = IniForm()
        quarter = userdata.__dict__['quarter']
        myquarter = peqc.list_specific(int(quarter) - 1)
        quarterlist = peqc.listed
        context = {
            'formitem': pe_fi.baseattrs,
            'form': form,
            'setter': myquarter,
            'setlist': quarterlist,
            'udata': userdata,
        }
        # zdefiniuj dodatkowe konteksty tutaj.
        pl = PortalLoad(
            P,
            L,
            Pbi,
            0,
            Umi,
            Uli,
        )
        context_lazy = pl.lazy_context(skins=S, context=context)
        template = 'panels/user/mydata.html'
        return render(request, template, context_lazy)
Esempio n. 6
0
def setmylanguage(request):
    userdata = User.objects.get(id=request.user.id)
    if 'sendlang' in request.POST:
        form = LangForm(request.POST, instance=userdata)
        userlang = request.POST.get('sendlang')
        if form.is_valid():
            form.save(userlang)
        return redirect('setmylanguage')
    else:
        lang = request.user.language
        userflag = "lang_flag_" + lang
        p_item = PageElement(P)
        p_item_objects = p_item.baseattrs
        preqlist = list(p_item_objects.__dict__.keys())
        # Zmień 'langpos' na 2 jeśli chcesz uniemożliwić tłumaczenie na Angielski.
        # Zmień na 0 jeśli chcesz umożliwić tłumaczenie na Polski (niezalecane).
        langpos = 1
        flagslist = preqlist[langpos + 3:len(L) + 3]
        lang_tups = L[langpos:]
        lang_ids = []
        for lang_tup in lang_tups:
            lang_ids.append(lang_tup[0])
        context = {
            "userflag": userflag,
            "lang_ids": lang_ids,
            "flagsobjects": p_item_objects,
            "flagslist": flagslist,
        }
        pl = PortalLoad(P, L, Pbi, 3, Tmi, Tli)
        context_lazy = pl.lazy_context(skins=S, context=context)
        template = 'panels/translator/setmylanguage.html'
        return render(request, template, context_lazy)
Esempio n. 7
0
def elementstranslate(request):
    lang = request.user.language
    instance = P.objects.get(id=1)
    p_item = PageElement(P)
    p_item_names = p_item.get_attrnames(L, 2)
    p_item_names = p_item_names[1:]  # Obcinacz flagi
    p_item_names_lang = []
    for item in p_item_names:
        item = str(item) + "_" + lang
        p_item_names_lang.append(item)
    print(p_item_names_lang)
    if request.method == 'POST':
        form = PageItemForm(request.POST,
                            instance=instance,
                            upd_fields=p_item_names_lang)
        if form.is_valid():
            form.save()
            return redirect('elementstranslate')
    else:
        p_item_objects = p_item.get_setlist(0, L, 2)
        p_item_objects = p_item_objects[1:]  # Obcinacz flagi
        # Dla szerszego spektrum sprawdź wzór na change_element
        form = PageItemForm(instance=instance, upd_fields=p_item_names_lang)
        context = {
            "trans_from_list": p_item_objects,
            "trans_to_list": p_item_names_lang,
            "form": form,
        }
        pl = PortalLoad(P, L, Pbi, 3, Tmi, Tli)
        context_lazy = pl.lazy_context(skins=S, context=context)
        template = 'panels/translator/elementstranslate.html'
        return render(request, template, context_lazy)
Esempio n. 8
0
def translatorpanel(request):
    language = request.user.language
    if language == '':
        return redirect('setmylanguage')
    else:
        # zdefiniuj dodatkowe konteksty tutaj.
        pl = PortalLoad(P, L, Pbi, 3, Tmi, Tli)
        context_lazy = pl.lazy_context(skins=S)
    template = 'panels/translator/panel_tlumacza.html'
    return render(request, template, context_lazy)
Esempio n. 9
0
def changemeparty(request):
    userdata = User.objects.get(
     id=request.user.id)
    party_id = request.session.get('partyid')
    # Formularz serwisowy pola niewymagane
    service = False
    if request.method == 'POST':
        instance = HParty.objects.get(id=int(party_id))
        instance2 = G404(HParty, id=int(party_id))
        form = PartyForm(request.POST, instance=instance2)
        if form.is_valid():
            form.save(userdata)
            return redirect('allparties')
    else:
        party_id = request.session.get('partyid')
        varlist = []
        varlist.append(party_id)
        instance = G404(HParty, id=party_id)
        form = PartyForm(instance=instance)
        quart = int(instance.quarter)
        varlist.append(quart)
        pe_fi = PageElement(FormItems)
        sh = PageElement(Sh)
        ifr = PageElement(Ifr)
        tper = PageElement(Tper)
        stf = PageElement(Stf)
        std = PageElement(Std)
        sch = PageElement(Sch)
        scs = PageElement(Scs)
        peqc = PageElement(QuarterClassB)
        hpi = PageElement(Hpi)
        context = {
         'udata': userdata,
         'formitem': pe_fi.baseattrs,
         'form2': form,
         'houselist': sh.listed,
         'staylist': ifr.listed,
         'periodlist': tper.listed,
         'facultylist': stf.listed,
         'degreelist': std.listed,
         'spouselist': sch.listed,
         'scaselist': scs.listed,
         'setlist': peqc.listed,
         'p_item': hpi.baseattrs,
         'varlist': varlist,
         'service': service,
         }
        pl = PortalLoad(P, L, Pbi, 1, Cmi, Cli, )
        context_lazy = pl.lazy_context(skins=S, context=context)
        template = 'forms/partymaker.html'
        return render(request, template, context_lazy)
Esempio n. 10
0
def changeuser(request, user_id):
    service = True
    userdata = User.objects.get(
     id=user_id)
    roledict = {1: False, 2: True, 3: True, 4: True}
    dictrole = {None: 1, 'on': 2}
    if 'quarter' in request.POST:
        form = IniForm(request.POST, instance=userdata)
        if form.is_valid():
            form.save()
            return redirect('changeuser', user_id)
    elif 'power' in request.POST:
        form2 = PowerForm(request.POST, instance=userdata)
        if form2.is_valid():
            key = request.POST.get('role_council')
            form2.save(dictrole[key])
            return redirect('changeuser', user_id)
    else:
        if userdata.role_council is None:
            cform = BasicPowerForm(request.POST, instance=userdata)
            if cform.is_valid():
                cform.save(1)
                return redirect('changeuser', user_id)
        key2 = userdata.role_council
        form = IniForm()
        form2 = PowerForm(
         instance=userdata, initial={'role_council': roledict[key2]})
        pe_fi = PageElement(FormItems)
        quarter = userdata.__dict__['quarter']
        peqc = PageElement(QuarterClassB)
        if quarter == '':
            myquarter = 'Nieprzydzielony!!!'
        else:
            myquarter = peqc.list_specific(int(quarter)-1)
        quarterlist = peqc.listed
        att = PageElement(Att)
        context = {
         'form': form,
         'form2': form2,
         'service2': service,
         'setter': myquarter,
         'setlist': quarterlist,
         'udata': userdata,
         'formitem': pe_fi.baseattrs,
         'attools': att.baseattrs,
         }
        pl = PortalLoad(P, L, Pbi, 1, Cmi, Cli, )
        context_lazy = pl.lazy_context(skins=S, context=context)
        template = 'panels/user/mydata.html'
        return render(request, template, context_lazy)
Esempio n. 11
0
def dormapply(request):
    userdata = User.objects.get(id=request.user.id)
    service = True
    if request.method == 'POST':
        form = ApplicationForm(request.POST)
        if form.is_valid():
            form.save(userdata, request=request)
            return redirect('userpanel')
    else:
        redir = party_switch(request)
        if redir == 1:
            return redirect('allparties')  # Gdzie przekierować?
        else:
            pe_fi = PageElement(FormItems)
            form = ApplicationForm()
            sh = PageElement(Sh)
            ifr = PageElement(Ifr)
            tper = PageElement(Tper)
            stf = PageElement(Stf)
            std = PageElement(Std)
            sch = PageElement(Sch)
            scs = PageElement(Scs)
            hp = PageElement(HParty)
            puzzle = hp.by_id(G404=G404, id=request.session['partyformid'])
            context = {
                'udata': userdata,
                'formitem': pe_fi.baseattrs,
                'form': form,
                'houselist': sh.list_shorter(cut_fr=1),
                'staylist': ifr.list_shorter(cut_fr=1),
                'periodlist': tper.list_shorter(cut_fr=1),
                'facultylist': stf.list_shorter(cut_fr=1),
                'degreelist': std.list_shorter(cut_fr=1),
                'spouselist': sch.list_shorter(cut_fr=1),
                'scaselist': scs.list_shorter(cut_fr=1),
                'service': service,
                'puzzle': puzzle
            }
            pl = PortalLoad(
                P,
                L,
                Pbi,
                0,
                Umi,
                Uli,
            )
            context_lazy = pl.lazy_context(skins=S, context=context)
            template = 'forms/dormapply.html'
            return render(request, template, context_lazy)
Esempio n. 12
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)
Esempio n. 13
0
def userpanel(request):
    quarter = request.user.quarter
    if quarter == '':
        return redirect('initial')
    else:
        # zdefiniuj dodatkowe konteksty tutaj.
        pl = PortalLoad(
            P,
            L,
            Pbi,
            0,
            Umi,
            Uli,
        )
        context_lazy = pl.lazy_context(skins=S)
    template = 'panels/user/panel_uzytkownika.html'
    return render(request, template, context_lazy)
Esempio n. 14
0
def makemeparty(request):
    userdata = User.objects.get(
     id=request.user.id)
    # Formularz serwisowy pola niewymagane
    service = False
    if request.method == 'POST':
        form = PartyForm(request.POST)
        if form.is_valid():
            form.save(userdata)
            return redirect('staffpanel_c')
    else:
        form = PartyForm()
        pe_fi = PageElement(FormItems)
        sh = PageElement(Sh)
        ifr = PageElement(Ifr)
        tper = PageElement(Tper)
        stf = PageElement(Stf)
        std = PageElement(Std)
        sch = PageElement(Sch)
        scs = PageElement(Scs)
        peqc = PageElement(QuarterClassB)
        hpi = PageElement(Hpi)
        context = {
         'udata': userdata,
         'formitem': pe_fi.baseattrs,
         'form2': form,
         'houselist': sh.listed,
         'staylist': ifr.listed,
         'periodlist': tper.listed,
         'facultylist': stf.listed,
         'degreelist': std.listed,
         'spouselist': sch.listed,
         'scaselist': scs.listed,
         'setlist': peqc.listed,
         'p_item': hpi.baseattrs,
         'service': service,
         }
        pl = PortalLoad(P, L, Pbi, 1, Cmi, Cli, )
        context_lazy = pl.lazy_context(skins=S, context=context)
        template = 'forms/partymaker.html'
        return render(request, template, context_lazy)
Esempio n. 15
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)
Esempio n. 16
0
def staffpanel_c(request):
    # zdefiniuj dodatkowe konteksty tutaj.
    pl = PortalLoad(P, L, Pbi, 1, Cmi, Cli)
    context_lazy = pl.lazy_context(skins=S)
    template = 'panels/council/panel_rady.html'
    return render(request, template, context_lazy)
Esempio n. 17
0
def staffpanel_h(request):
    # zdefiniuj dodatkowe konteksty tutaj.
    pl = PortalLoad(P, L, Pbi, 2, Hmi, Hli)
    context_lazy = pl.lazy_context(skins=S)
    template = 'panels/hotel/panel_akademika.html'
    return render(request, template, context_lazy)