Clean up the /accounts/ section. Still need to edit profile somehow,

but the submitted objects are now much nicer arranged.
This commit is contained in:
Magnus Hagander
2010-02-26 13:58:41 +01:00
parent 41e653c86c
commit c3be6c213f
5 changed files with 112 additions and 22 deletions

View File

@ -4,6 +4,9 @@ from django.conf.urls.defaults import *
urlpatterns = patterns('',
(r'^$', 'account.views.home'),
# List of items to edit
(r'^edit/(.*)/$', 'account.views.listobjects'),
# News & Events
(r'^news/(.*)/$', 'news.views.form'),
(r'^events/(.*)/$', 'events.views.form'),

View File

@ -1,6 +1,6 @@
from django.contrib.auth.models import User
import django.contrib.auth.views as authviews
from django.http import HttpResponseRedirect, HttpResponse
from django.http import HttpResponseRedirect, HttpResponse, Http404
from django.shortcuts import render_to_response
from django.contrib.auth.decorators import login_required
@ -15,10 +15,10 @@ from pgweb.downloads.models import Product
@ssl_required
@login_required
def home(request):
myarticles = NewsArticle.objects.filter(org__managers=request.user)
myevents = Event.objects.filter(org__managers=request.user)
myorgs = Organisation.objects.filter(managers=request.user)
myproducts = Product.objects.filter(publisher__managers=request.user)
myarticles = NewsArticle.objects.filter(org__managers=request.user, approved=False)
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)
return render_to_response('account/index.html', {
'newsarticles': myarticles,
'events': myevents,
@ -26,6 +26,38 @@ def home(request):
'products': myproducts,
}, NavContext(request, 'account'))
objtypes = {
'news': {
'title': 'News articles',
'objects': lambda u: NewsArticle.objects.filter(org__managers=u),
},
'events': {
'title': 'Events',
'objects': lambda u: Event.objects.filter(org__managers=u),
},
'products': {
'title': 'Products',
'objects': lambda u: Product.objects.filter(publisher__managers=u),
},
'organisations': {
'title': 'Organisations',
'objects': lambda u: Organisation.objects.filter(managers=u),
},
}
@ssl_required
@login_required
def listobjects(request, objtype):
if not objtypes.has_key(objtype):
raise Http404("Object type not found")
o = objtypes[objtype]
return render_to_response('account/objectlist.html', {
'objects': o['objects'](request.user),
'title': o['title'],
'suburl': objtype,
}, NavContext(request, 'account'))
@ssl_required
def login(request):
return authviews.login(request, template_name='account/login.html')

View File

@ -75,6 +75,12 @@ sitenav = {
],
'account': [
{'title': 'Your account', 'link':'/account'},
{'title': 'Edit data', 'link':'/account', 'submenu': [
{'title': 'News Articles', 'link':'/account/edit/news/'},
{'title': 'Events', 'link':'/account/edit/events/'},
{'title': 'Products', 'link':'/account/edit/products/'},
{'title': 'Organisations', 'link':'/account/edit/organisations/'},
]},
{'title': 'Logout', 'link':'/account/logout'},
],
}

View File

@ -3,45 +3,77 @@
{%block contents%}
<h1>Your account</h1>
<p>
This page contains information about your postgresql.org account.
From this section, you can manage all information on this site connected
to your PostgreSQL community account. Other than your basic profile
information, this includes news and events, professional services and
comments. Note that most of the data you submit to this site needs to be
approved by a moderator before it's published.
</p>
<h1>Submitted data</h1>
<p>
Submitted data should be moved to a subpage!
To submit a new record, or to edit an existing record, select the
type of record in the menu on the left.
</p>
<h2>News articles</h2>
<h2>Permissions model</h2>
<p>
News, Events, Products and Professional Services are attached to an
Organisation. One or more persons can be given permissions to manage
the data for an organisation. If you do not have permissions for an
organisation and think you should have, you need to contact the current
managers for that organisation.
</p>
<h2>Migrated data</h2>
<p>
For most of the data migrated from the old website has unfortunately not
been connected to the proper organisations and accounts. If you have any
data submitted that is not properly connected to you (most likely this
will be your account not being connected to the proper organisation(s)),
please contact <a href="webmaster@postgresql.org">webmaster@postgresql.org</a>
and let us know which objects to connect together.
</p>
<h2>Submissions awaiting moderation</h2>
<p>
You have submitted the following objects that are still waiting moderator
approval before they are published:
</p>
{%if newsarticles%}
<h3>News articles</h3>
<ul>
{%for article in newsarticles%}
<li><a {%if not article.approved%} style="color:red;"{%endif%} href="/account/news/{{article.id}}/">{{article}}</a></li>
<li><a href="/account/news/{{article.id}}/">{{article}}</a></li>
{%endfor%}
</ul>
<a href="/account/news/new/">Submit news</a>
{%endif%}
<h2>Events</h2>
{%if events%}
<h3>Events</h3>
<ul>
{%for event in events%}
<li><a {%if not event.approved%} style="color:red;"{%endif%} href="/account/events/{{event.id}}/">{{event}}</a></li>
<li><a href="/account/events/{{event.id}}/">{{event}}</a></li>
{%endfor%}
</ul>
<a href="/account/events/new/">Submit event</a>
{%endif%}
<h2>Organisations</h2>
{%if organisations%}
<h3>Organisations</h3>
<ul>
{%for org in organisations%}
<li><a {%if not org.approved%} style="color:red;"{%endif%} href="/account/organisations/{{org.id}}">{{org}}</a></li>
<li><a href="/account/organisations/{{org.id}}">{{org}}</a></li>
{%endfor%}
</ul>
<a href="/account/organisations/new/">New organisation</a>
{%endif%}
<h2>Products</h2>
{%if products%}
<h3>Products</h3>
<ul>
{%for product in products%}
<li><a {%if not product.approved%} style="color:red;"{%endif%} href="/account/products/{{product.id}}">{{product}}</a></li>
<li><a href="/account/products/{{product.id}}">{{product}}</a></li>
{%endfor%}
</ul>
<a href="/account/products/new/">New product</a>
{%endif%}
{%endblock%}

View File

@ -0,0 +1,17 @@
{%extends "base/page.html"%}
{%block title%}Your account{%endblock%}
{%block contents%}
<h1>{{title}}</h1>
<p>
Objects in red are awaiting moderator approval. Note that modifying a previously
approved object <i>may</i> result in it being un-approved if the changes are
extensive.
</p>
<ul>
{%for o in objects%}
<li><a {%if not o.approved%} "style='color:red;'" {%endif%}href="/account/{{suburl}}/{{o.id}}/">{{o}}</a></li>
{%endfor%}
</ul>
{%endblock%}