mirror of
https://github.com/postgres/pgweb.git
synced 2025-08-06 09:57:57 +00:00
Add page with list of all pending moderation requests, and link it
(somewhat hackishly) onto the header of the administration pages.
This commit is contained in:
@ -24,6 +24,11 @@ from survey.models import Survey
|
||||
from models import Organisation
|
||||
from forms import OrganisationForm
|
||||
|
||||
# models needed to generate unapproved list
|
||||
from docs.models import DocComment
|
||||
from downloads.models import Product
|
||||
from profserv.models import ProfessionalService
|
||||
|
||||
# Front page view
|
||||
def home(request):
|
||||
news = NewsArticle.objects.filter(approved=True)[:5]
|
||||
@ -88,3 +93,28 @@ def organisationform(request, itemid):
|
||||
'managers': (request.user, ),
|
||||
})
|
||||
|
||||
|
||||
# Pending moderation requests (this is part of the /admin/ interface :O)
|
||||
def _generate_unapproved(objects):
|
||||
if not len(objects): return None
|
||||
return { 'name': objects[0]._meta.verbose_name_plural, 'entries':
|
||||
[{'url': '/admin/%s/%s/%s/' % (x._meta.app_label, x._meta.module_name, x.pk), 'title': unicode(x)} for x in objects]
|
||||
}
|
||||
|
||||
|
||||
@login_required
|
||||
def admin_pending(request):
|
||||
n = NewsArticle.objects.filter(approved=False)
|
||||
app_list = [
|
||||
_generate_unapproved(NewsArticle.objects.filter(approved=False)),
|
||||
_generate_unapproved(Event.objects.filter(approved=False)),
|
||||
_generate_unapproved(Organisation.objects.filter(approved=False)),
|
||||
_generate_unapproved(DocComment.objects.filter(approved=False)),
|
||||
_generate_unapproved(Product.objects.filter(approved=False)),
|
||||
_generate_unapproved(ProfessionalService.objects.filter(approved=False)),
|
||||
_generate_unapproved(Quote.objects.filter(approved=False)),
|
||||
]
|
||||
|
||||
return render_to_response('core/admin_pending.html', {
|
||||
'app_list': [x for x in app_list if x],
|
||||
})
|
||||
|
@ -75,6 +75,8 @@ urlpatterns = patterns('',
|
||||
(r'^about/event\.(\d+)$', 'pgweb.legacyurl.views.event'),
|
||||
(r'^community/signup', 'pgweb.legacyurl.views.signup'),
|
||||
|
||||
# Override some URLs in admin, to provide our own pages
|
||||
(r'^admin/pending/$', 'pgweb.core.views.admin_pending'),
|
||||
# Uncomment the next line to enable the admin:
|
||||
(r'^admin/(.*)', admin.site.root),
|
||||
|
||||
|
7
templates/admin/base_site.html
Normal file
7
templates/admin/base_site.html
Normal file
@ -0,0 +1,7 @@
|
||||
{%extends "admin/base.html"%}
|
||||
{%block branding%}Welcome to the PostgreSQL website administration site{%endblock%}
|
||||
{%block pretitle%}
|
||||
<p>
|
||||
View <a href="/admin/pending/">pending</a> moderation requests.
|
||||
</p>
|
||||
{%endblock%}
|
21
templates/core/admin_pending.html
Normal file
21
templates/core/admin_pending.html
Normal file
@ -0,0 +1,21 @@
|
||||
{%extends "admin/base.html"%}
|
||||
{%block breadcrumbs%}
|
||||
<div class="breadcrumbs"><a href="/admin/">Home</a> › Pending
|
||||
{%endblock%}
|
||||
|
||||
{%block content%}
|
||||
<div id="content-main">
|
||||
{%for app in app_list %}
|
||||
<div class="module">
|
||||
<table summary="Pending {{app.name}}" width="600">
|
||||
<caption><a class="section">Pending {{app.name}}</a></caption>
|
||||
{%for entry in app.entries%}
|
||||
<tr class="row{%cycle '1' '2'%}">
|
||||
<td><a href="{{entry.url}}">{{entry.title}}</a></td>
|
||||
</tr>
|
||||
{%endfor%}
|
||||
</table>
|
||||
</div>
|
||||
{%endfor%}
|
||||
</div>
|
||||
{%endblock%}
|
Reference in New Issue
Block a user