summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Hagander2011-08-24 14:56:00 +0000
committerMagnus Hagander2011-08-24 14:56:00 +0000
commit965767e992786e5d1801541e5b493c26a1752d98 (patch)
tree09a5bbe2468e10c4adef1b4a980b57ea42dc660d
parentadabe319ae9980c97918e6a4a59f491f1f899d1e (diff)
Add edit for professional services
-rw-r--r--pgweb/account/urls.py3
-rw-r--r--pgweb/account/views.py7
-rw-r--r--pgweb/profserv/forms.py16
-rw-r--r--pgweb/profserv/views.py8
-rw-r--r--pgweb/util/contexts.py1
-rw-r--r--templates/account/index.html11
6 files changed, 45 insertions, 1 deletions
diff --git a/pgweb/account/urls.py b/pgweb/account/urls.py
index a3129915..8eaa21fc 100644
--- a/pgweb/account/urls.py
+++ b/pgweb/account/urls.py
@@ -18,6 +18,9 @@ urlpatterns = patterns('',
# Organisation information
(r'^orglist/$', 'account.views.orglist'),
+ # Professional services
+ (r'^services/(.*)/$', 'profserv.views.profservform'),
+
# Docs comments
(r'^comments/(new)/(.*)/(.*)/$', 'docs.views.commentform'),
diff --git a/pgweb/account/views.py b/pgweb/account/views.py
index 27f8630d..d4b83d99 100644
--- a/pgweb/account/views.py
+++ b/pgweb/account/views.py
@@ -16,6 +16,7 @@ from pgweb.news.models import NewsArticle
from pgweb.events.models import Event
from pgweb.core.models import Organisation
from pgweb.downloads.models import Product
+from pgweb.profserv.models import ProfessionalService
from forms import SignupForm
@@ -26,11 +27,13 @@ def home(request):
myevents = Event.objects.filter(org__managers=request.user, approved=False)
myorgs = Organisation.objects.filter(managers=request.user, approved=False)
myproducts = Product.objects.filter(publisher__managers=request.user, approved=False)
+ myprofservs = ProfessionalService.objects.filter(organisation__managers=request.user, approved=False)
return render_to_response('account/index.html', {
'newsarticles': myarticles,
'events': myevents,
'organisations': myorgs,
'products': myproducts,
+ 'profservs': myprofservs,
}, NavContext(request, 'account'))
objtypes = {
@@ -46,6 +49,10 @@ objtypes = {
'title': 'Product',
'objects': lambda u: Product.objects.filter(publisher__managers=u),
},
+ 'services': {
+ 'title': 'Professional service',
+ 'objects': lambda u: ProfessionalService.objects.filter(organisation__managers=u),
+ },
'organisations': {
'title': 'Organisation',
'objects': lambda u: Organisation.objects.filter(managers=u),
diff --git a/pgweb/profserv/forms.py b/pgweb/profserv/forms.py
new file mode 100644
index 00000000..ee3b0c44
--- /dev/null
+++ b/pgweb/profserv/forms.py
@@ -0,0 +1,16 @@
+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['organisation'].queryset = Organisation.objects.filter(managers=user, approved=True)
+ class Meta:
+ model = ProfessionalService
+ exclude = ('submitter', 'approved', )
+
diff --git a/pgweb/profserv/views.py b/pgweb/profserv/views.py
index cf08d148..0dbb0bcc 100644
--- a/pgweb/profserv/views.py
+++ b/pgweb/profserv/views.py
@@ -4,10 +4,12 @@ from django.template import TemplateDoesNotExist, loader, Context
from django.contrib.auth.decorators import login_required
from django.db.models import Q
+from pgweb.util.decorators import ssl_required
from pgweb.util.contexts import NavContext
from pgweb.util.helpers import simple_form
from models import ProfessionalService
+from forms import ProfessionalServiceForm
regions = (
('africa','Africa'),
@@ -54,3 +56,9 @@ def region(request, servtype, regionname):
'services': services,
}, NavContext(request, 'support'))
+
+# Forms to edit
+@ssl_required
+@login_required
+def profservform(request, itemid):
+ return simple_form(ProfessionalService, itemid, request, ProfessionalServiceForm)
diff --git a/pgweb/util/contexts.py b/pgweb/util/contexts.py
index 10bc3464..d47fe16e 100644
--- a/pgweb/util/contexts.py
+++ b/pgweb/util/contexts.py
@@ -79,6 +79,7 @@ sitenav = {
{'title': 'News Articles', 'link':'/account/edit/news/'},
{'title': 'Events', 'link':'/account/edit/events/'},
{'title': 'Products', 'link':'/account/edit/products/'},
+ {'title': 'Professional Services', 'link':'/account/edit/services/'},
{'title': 'Organisations', 'link':'/account/edit/organisations/'},
]},
{'title': 'Change password', 'link':'/account/changepwd/'},
diff --git a/templates/account/index.html b/templates/account/index.html
index acba8cb7..c8d9d222 100644
--- a/templates/account/index.html
+++ b/templates/account/index.html
@@ -34,7 +34,7 @@ please contact <a href="webmaster@postgresql.org">webmaster@postgresql.org</a>
and let us know which objects to connect together.
</p>
-{%if newsarticles or events or organisations or products %}
+{%if newsarticles or events or organisations or products or profservs %}
<h2>Submissions awaiting moderation</h2>
<p>
You have submitted the following objects that are still waiting moderator
@@ -77,6 +77,15 @@ approval before they are published:
</ul>
{%endif%}
+{%if profservs%}
+<h3>Professional Services</h3>
+<ul>
+{%for profserv in profservs%}
+<li><a href="/account/services/{{profserv.id}}">{{profserv}}</a></li>
+{%endfor%}
+</ul>
+{%endif%}
+
{%endif%}
{%endblock%}