summaryrefslogtreecommitdiff
path: root/pgweb/profserv
diff options
context:
space:
mode:
authorMagnus Hagander2019-01-17 19:47:43 +0000
committerMagnus Hagander2019-01-17 19:47:43 +0000
commit0883ac6423857246cca412c159af7914ad06e631 (patch)
treed6bdc96b342301b97858f409873f66b030c76490 /pgweb/profserv
parent87237f6536a1e6df112ca34818cf8459cb04fc68 (diff)
Fix whitespace and indentation, per pep8
Diffstat (limited to 'pgweb/profserv')
-rw-r--r--pgweb/profserv/admin.py2
-rw-r--r--pgweb/profserv/forms.py4
-rw-r--r--pgweb/profserv/models.py11
-rw-r--r--pgweb/profserv/struct.py1
-rw-r--r--pgweb/profserv/views.py29
5 files changed, 28 insertions, 19 deletions
diff --git a/pgweb/profserv/admin.py b/pgweb/profserv/admin.py
index b644146c..722a8451 100644
--- a/pgweb/profserv/admin.py
+++ b/pgweb/profserv/admin.py
@@ -3,9 +3,11 @@ from django.contrib import admin
from pgweb.util.admin import PgwebAdmin
from models import ProfessionalService
+
class ProfessionalServiceAdmin(PgwebAdmin):
list_display = ('__unicode__', 'approved',)
list_filter = ('approved',)
search_fields = ('org__name',)
+
admin.site.register(ProfessionalService, ProfessionalServiceAdmin)
diff --git a/pgweb/profserv/forms.py b/pgweb/profserv/forms.py
index 8df2ff40..3ec70a93 100644
--- a/pgweb/profserv/forms.py
+++ b/pgweb/profserv/forms.py
@@ -3,13 +3,17 @@ from django import forms
from pgweb.core.models import Organisation
from models import ProfessionalService
+
class ProfessionalServiceForm(forms.ModelForm):
form_intro = """Note that in order to register a new professional service, you must first register an organisation.
If you have not done so, use <a href="/account/organisations/new/">this form</a>."""
+
def __init__(self, *args, **kwargs):
super(ProfessionalServiceForm, self).__init__(*args, **kwargs)
+
def filter_by_user(self, user):
self.fields['org'].queryset = Organisation.objects.filter(managers=user, approved=True)
+
class Meta:
model = ProfessionalService
exclude = ('submitter', 'approved', )
diff --git a/pgweb/profserv/models.py b/pgweb/profserv/models.py
index 180e1d43..7f5b58db 100644
--- a/pgweb/profserv/models.py
+++ b/pgweb/profserv/models.py
@@ -2,14 +2,15 @@ from django.db import models
from pgweb.core.models import Organisation
+
class ProfessionalService(models.Model):
approved = models.BooleanField(null=False, blank=False, default=False)
- org = models.OneToOneField(Organisation, null=False, blank=False,
- db_column="organisation_id",
- verbose_name="organisation",
- help_text="If no organisations are listed, please check the <a href=\"/account/orglist/\">organisation list</a> and contact the organisation manager or <a href=\"mailto:webmaster@postgresql.org\">webmaster@postgresql.org</a> if none are listed.")
- description = models.TextField(null=False,blank=False)
+ org = models.OneToOneField(Organisation, null=False, blank=False,
+ db_column="organisation_id",
+ verbose_name="organisation",
+ help_text="If no organisations are listed, please check the <a href=\"/account/orglist/\">organisation list</a> and contact the organisation manager or <a href=\"mailto:webmaster@postgresql.org\">webmaster@postgresql.org</a> if none are listed.")
+ description = models.TextField(null=False, blank=False)
employees = models.CharField(max_length=32, null=True, blank=True)
locations = models.CharField(max_length=128, null=True, blank=True)
region_africa = models.BooleanField(null=False, default=False, verbose_name="Africa")
diff --git a/pgweb/profserv/struct.py b/pgweb/profserv/struct.py
index 659753b2..c053d03b 100644
--- a/pgweb/profserv/struct.py
+++ b/pgweb/profserv/struct.py
@@ -1,5 +1,6 @@
from views import regions
+
def get_struct():
for key, name in regions:
yield ('support/professional_support/%s/' % key, None)
diff --git a/pgweb/profserv/views.py b/pgweb/profserv/views.py
index ad135d22..e618bee3 100644
--- a/pgweb/profserv/views.py
+++ b/pgweb/profserv/views.py
@@ -8,18 +8,19 @@ from models import ProfessionalService
from forms import ProfessionalServiceForm
regions = (
- ('africa','Africa'),
- ('asia','Asia'),
- ('europe','Europe'),
- ('northamerica','North America'),
- ('oceania','Oceania'),
- ('southamerica','South America'),
+ ('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'
+ 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,
@@ -29,19 +30,19 @@ def root(request, servtype):
def region(request, servtype, regionname):
- regname = [n for r,n in regions if r==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'
+ what = servtype == 'support' and 'support' or 'hosting'
+ whatname = servtype == 'support' and 'Professional Services' or 'Hosting Providers'
title = "%s - %s" % (whatname, regname)
- support = servtype=='support'
+ 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),])
+ 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,