How to use the dispatch.apps.manager.decorators.staff_member_required function in dispatch

To help you get started, we’ve selected a few dispatch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ubyssey / dispatch / dispatch / apps / manager / views.py View on Github external
@staff_member_required
def user_edit(request, id):

    p = Person.objects.get(pk=id)

    if request.method == 'POST':
        form = PersonForm(request.POST, request.FILES, instance=p)
        if form.is_valid():
            form.save()
            return redirect(users)
    else:
        form = PersonForm(instance=p)

    context = {
        'title': 'Edit User',
        'person': p,
        'form': form,
github ubyssey / dispatch / dispatch / apps / manager / views.py View on Github external
@staff_member_required
def article_edit(request, id):

    context = {
        'title': 'Edit Article',
        'article': id,
    }

    return render(request, 'manager/article/edit.html', context)
github ubyssey / dispatch / dispatch / apps / manager / views.py View on Github external
@staff_member_required
def articles(request):
    q = request.POST.get('q', False)
    articles = Article.objects.all()

    if q:
        articles = articles.filter(title__icontains=q)

    return render_to_response(
        "manager/article/list.html",
        {
            'article_list' : articles
        },
        RequestContext(request, {}),
    )
github ubyssey / dispatch / dispatch / apps / manager / views.py View on Github external
@staff_member_required
def files(request):

    files = File.objects.all()

    context = {
        'title': 'Files',
        'files': files,
    }

    return render(request, 'manager/file/list.html', context)
github ubyssey / dispatch / dispatch / apps / manager / views.py View on Github external
@staff_member_required
def user_add(request):

    if request.method == 'POST':
        form = PersonForm(request.POST, request.FILES, user_form=False)
        if form.is_valid():
            form.save()
            return redirect(users)
    else:
        form = PersonForm(user_form=False)

    context = {
        'title': 'Add User',
        'form': form,
        'user_form': form.user_form,
    }
github ubyssey / dispatch / dispatch / apps / manager / views.py View on Github external
@staff_member_required
def users(request):
    users = Person.objects.filter(is_admin=True).order_by('full_name')
    q = request.GET.get('q', '')
    if q:
        users = users.filter(full_name__icontains=q)

    paginator = Paginator(users, 15) # Show 15 articles per page

    page = request.GET.get('page')

    try:
        persons = paginator.page(page)
    except PageNotAnInteger:
        # If page is not an integer, deliver first page.
        persons = paginator.page(1)
    except EmptyPage:
github ubyssey / dispatch / dispatch / apps / manager / views.py View on Github external
@staff_member_required
def article_add(request):
    section_id = request.GET.get('section', False)
    try:
        section = Section.objects.get(pk=section_id)
    except:
        section = None
    return render(request, 'manager/article/edit.html', {'section': section})
github ubyssey / dispatch / dispatch / apps / manager / views.py View on Github external
@staff_member_required
def file_delete(request, id):
    File.objects.get(pk=id).delete()
    return redirect(files)
github ubyssey / dispatch / dispatch / apps / manager / views.py View on Github external
@staff_member_required
def section(request, section):
    section = Section.objects.get(name=section)
    article_list = Article.objects.filter(section=section,is_active=True,head=True).order_by('-created_at')

    q = request.GET.get('q', '')
    if q:
        article_list = article_list.filter(headline__icontains=q)

    unpublished = article_list.exclude(status=Article.PUBLISHED).count()

    paginator = Paginator(article_list, 15) # Show 15 articles per page

    page = request.GET.get('page')

    try:
        articles = paginator.page(page)
github ubyssey / dispatch / dispatch / apps / manager / views.py View on Github external
@staff_member_required
def role_add(request):

    if request.method == 'POST':
        form = RoleForm(request.POST)
        if form.is_valid():
            form.save()
            return redirect(roles)
    else:
        form = RoleForm()

    context = {
        'title': 'Add Role',
        'form': form,
    }

    return render(request, "manager/role/edit.html", context)