-
-
Notifications
You must be signed in to change notification settings - Fork 331
/
views.py
47 lines (35 loc) · 1.15 KB
/
views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.shortcuts import render
from djconfig import config
from ...core.utils.paginator import yt_paginate
from ...core.utils.decorators import administrator_required
from ..models import Topic
@administrator_required
def _index(request, queryset, template):
topics = yt_paginate(
queryset,
per_page=config.topics_per_page,
page_number=request.GET.get('page', 1)
)
context = {'topics': topics, }
return render(request, template, context)
def deleted(request):
# Private topics cant be deleted, closed or pinned so we are ok
return _index(
request,
queryset=Topic.objects.filter(is_removed=True),
template='spirit/topic/admin/deleted.html'
)
def closed(request):
return _index(
request,
queryset=Topic.objects.filter(is_closed=True),
template='spirit/topic/admin/closed.html'
)
def pinned(request):
return _index(
request,
queryset=Topic.objects.filter(is_pinned=True) | Topic.objects.filter(is_globally_pinned=True),
template='spirit/topic/admin/pinned.html'
)