# HG changeset patch # User Lennard de Rijk # Date 1235336503 0 # Node ID d69b00439d599b3613116f31901cc6a795447139 # Parent fa794d29cbae3b9876cc452e5059eb3653d969d2 Added listing of your own student proposals. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed diff -r fa794d29cbae -r d69b00439d59 app/soc/views/models/student_proposal.py --- a/app/soc/views/models/student_proposal.py Sun Feb 22 21:00:25 2009 +0000 +++ b/app/soc/views/models/student_proposal.py Sun Feb 22 21:01:43 2009 +0000 @@ -31,6 +31,7 @@ from soc.logic import dicts from soc.logic.models import organization as org_logic from soc.logic.models import student as student_logic +from soc.logic.models import user as user_logic from soc.views.helper import access from soc.views.helper import decorators from soc.views.helper import redirects @@ -64,6 +65,8 @@ [['proposer', 'org_admin', 'mentor', 'host'], ['active', 'inactive'], ['new', 'pending', 'accepted', 'rejected']])] rights['list'] = ['checkIsDeveloper'] + rights['list_self'] = [ + ('checkIsStudent', ['scope_path', ['active', 'inactive']])] rights['apply'] = [ ('checkIsStudent', ['scope_path', ['active']]), ('checkCanStudentPropose', 'scope_path')] @@ -84,6 +87,9 @@ (r'^%(url_name)s/(?Papply)/%(scope)s$', 'soc.views.models.%(module_name)s.create', 'Create a new %(name)s'), + (r'^%(url_name)s/(?Plist_self)/%(scope)s$', + 'soc.views.models.%(module_name)s.list_self', + 'List my %(name_plural)s') ] new_params['extra_django_patterns'] = patterns @@ -159,6 +165,27 @@ else: context['mentor_name'] = "No mentor assigned" + @decorators.merge_params + def listSelf(self, request, access_type, + page_name=None, params=None, **kwargs): + """Lists all proposals from the current logged-in user. + + For params see base.View.public(). + """ + + user_entity = user_logic.logic.getForCurrentAccount() + filter = {'user': user_entity} + student_entity = student_logic.logic.getForFields(filter, unique=True) + + filter = {'scope' : student_entity, + 'status': ['new', 'pending', 'accepted', 'rejected']} + + list_params = params.copy() + list_params['list_description'] = 'List of my %(name_plural)s' % list_params + + return self.list(request, access_type=access_type, page_name=page_name, + params=list_params, filter=filter, **kwargs) + view = View() admin = view.admin @@ -166,6 +193,7 @@ delete = view.delete edit = view.edit list = view.list +list_self = view.listSelf public = view.public export = view.export pick = view.pick