Ejemplo n.º 1
0
def home(request):
    if request.user.is_authenticated():
        roles = get_roles(request.user)
        badroles = ('B-18000-STUDENT' not in roles
                    and 'B-18000-SUMA-ZAMESTNANEC' not in roles
                    and 'B-18000-UCASTNIK-CZV' not in roles)
        if badroles:
            auth_logout(request)
        teacher = 'B-18000-SUMA-ZAMESTNANEC' in roles
    else:
        badroles = False
        teacher = False

    signed_list = models.Signature.objects.filter(
        signed=True).order_by('-timestamp')
    paginator = Paginator(signed_list, 45)
    total = signed_list.count()

    page = request.GET.get('page')
    try:
        signatures = paginator.page(page)
    except PageNotAnInteger:
        signatures = paginator.page(1)
    except EmptyPage:
        signatures = paginator.page(paginator.num_pages)

    return render_to_response(
        'index.html', {
            'user': request.user,
            'badroles': badroles,
            'teacher': teacher,
            'signatures': signatures,
            'total': total,
        }, RequestContext(request))
Ejemplo n.º 2
0
def home(request):
    if request.user.is_authenticated():
        roles = get_roles(request.user)
        badroles = (
            "B-18000-STUDENT" not in roles
            and "B-18000-ZAMESTNANEC" not in roles
            and "B-18000-UCASTNIK-CZV" not in roles
        )
        if badroles:
            auth_logout(request)
        teacher = "B-18000-ZAMESTNANEC" in roles
    else:
        badroles = False
        teacher = False

    signed_list = models.Signature.objects.filter(signed=True).order_by("-timestamp")
    paginator = Paginator(signed_list, 45)
    total = signed_list.count()

    page = request.GET.get("page")
    try:
        signatures = paginator.page(page)
    except PageNotAnInteger:
        signatures = paginator.page(1)
    except EmptyPage:
        signatures = paginator.page(paginator.num_pages)

    return render_to_response(
        "index.html",
        {"user": request.user, "badroles": badroles, "teacher": teacher, "signatures": signatures, "total": total},
        RequestContext(request),
    )
Ejemplo n.º 3
0
def detail(user):
    if user.get_full_name():
        output = "%s (%s)" % (user.get_full_name(), user.username)
    else:
        output = user.username

    roles = get_roles(user)
    if "B-18000-ZAMESTNANEC" in roles:
        output += ' <span class="label label-info">zaměstnanec</span>'
    if "B-18000-STUDENT" in roles:
        output += ' <span class="label label-primary">student</span>'
    if "B-18000-UCASTNIK-CZV" in roles:
        output += ' <span class="label label-default">cžv</span>'

    return mark_safe(output)
Ejemplo n.º 4
0
def detail(user):
    if user.get_full_name():
        output = '%s (%s)' % (user.get_full_name(), user.username)
    else:
        output = user.username

    roles = get_roles(user)
    if 'B-18000-ZAMESTNANEC' in roles:
        output += ' <span class="label label-info">zaměstnanec</span>'
    if 'B-18000-STUDENT' in roles:
        output += ' <span class="label label-primary">student</span>'
    if 'B-18000-UCASTNIK-CZV' in roles:
        output += ' <span class="label label-default">cžv</span>'

    return mark_safe(output)