Ejemplo n.º 1
0
def get_authenticated_series(request, seriesid):
    if not request.user.is_authenticated:
        raise RedirectException("{0}?{1}".format(
            settings.LOGIN_URL,
            urllib.parse.urlencode({'next': request.build_absolute_uri()})))

    s = get_object_or_404(ConferenceSeries, pk=seriesid)
    if request.user.is_superuser:
        return s
    else:
        if s.administrators.filter(pk=request.user.id).exists():
            return s
        raise PermissionDenied()
Ejemplo n.º 2
0
def authenticate_backend_group(request, groupname):
    if not request.user.is_authenticated:
        raise RedirectException("{0}?{1}".format(settings.LOGIN_URL, urllib.parse.urlencode({'next': request.build_absolute_uri()})))

    if groupname not in PERMISSION_GROUPS:
        raise PermissionDenied("Group name not known")

    if request.user.is_superuser:
        return
    if request.user.groups.filter(name=groupname).exists():
        return

    raise PermissionDenied("Access denied")
Ejemplo n.º 3
0
def get_authenticated_conference(request, urlname=None, confid=None):
    if not request.user.is_authenticated:
        raise RedirectException("{0}?{1}".format(
            settings.LOGIN_URL,
            urllib.parse.urlencode({'next': request.build_absolute_uri()})))

    if confid:
        c = get_object_or_404(Conference, pk=confid)
    else:
        c = get_object_or_404(Conference, urlname=urlname)

    if request.user.is_superuser:
        return c
    else:
        if c.administrators.filter(pk=request.user.id).exists():
            return c
        if c.series.administrators.filter(pk=request.user.id).exists():
            return c
        raise PermissionDenied()