Files
postgres-web/pgweb/profserv/views.py
Magnus Hagander 5ffe6c389c Re-work moderation of submitted items
This includes a number of new features:

* Move some moderation functionality into shared places, so we don't
  keep re-inventing the wheel.
* Implement three-state moderation, where the submitter can edit their
  item and then explicitly say "i'm done, please moderate this now".
  This is currently only implemented for News, but done in a reusable
  way.
* Move moderation workflow to it's own set of URLs instead of
  overloading it on the general admin interface. Admin interface remains
  for editing things, but these are now separated out into separate
  things.
* Do proper stylesheet clearing for moderation of markdown fields, using
  a dynamic sandboxed iframe, so it's not ruined by the /admin/ css.
* Move moderation email notification into dedicated moderation code,
  thereby simplifying the admin subclassing we did which was in some
  places quite fragile.
* Reset date of news postings to the date of their approval, when
  approved. This avoids some annoying ordering issues.
2020-09-10 14:52:41 +02:00

52 lines
1.6 KiB
Python

from django.http import Http404
from pgweb.util.contexts import render_pgweb
from .models import ProfessionalService
regions = (
('africa', 'Africa'),
('asia', 'Asia'),
('europe', 'Europe'),
('northamerica', 'North America'),
('oceania', 'Oceania'),
('southamerica', 'South America'),
)
def root(request, servtype):
title = servtype == 'support' and 'Professional Services' or 'Hosting Providers'
what = servtype == 'support' and 'support' or 'hosting'
support = servtype == 'support'
return render_pgweb(request, 'support', 'profserv/root.html', {
'title': title,
'support': support,
'regions': regions,
'what': what,
})
def region(request, servtype, regionname):
regname = [n for r, n in regions if r == regionname]
if not regname:
raise Http404
regname = regname[0]
what = servtype == 'support' and 'support' or 'hosting'
whatname = servtype == 'support' and 'Professional Services' or 'Hosting Providers'
title = "%s - %s" % (whatname, regname)
support = servtype == 'support'
# DB model is a bit funky here, so use the extra-where functionality to filter properly.
# Field names are cleaned up earlier, so it's safe against injections.
services = ProfessionalService.objects.select_related('org').filter(approved=True).extra(where=["region_%s AND provides_%s" % (regionname, what), ])
return render_pgweb(request, 'support', 'profserv/list.html', {
'title': title,
'support': support,
'what': what,
'whatname': whatname,
'regionname': regname,
'services': services,
})