# HG changeset patch # User Sverre Rabbelier # Date 1237762454 0 # Node ID 3aeda3007467c7c1a85c6d74d31544d8016845a3 # Parent fea8bdb439926db7a5355637a3810aa3fceda801 Make _public return True iff public page should be shown If the public page should not be shown, and 'public_redirect' is set, a redirect to 'public_redirect' will be returned. Patch by: Sverre Rabbelier diff -r fea8bdb43992 -r 3aeda3007467 app/soc/views/helper/params.py --- a/app/soc/views/helper/params.py Sun Mar 22 22:15:46 2009 +0000 +++ b/app/soc/views/helper/params.py Sun Mar 22 22:54:14 2009 +0000 @@ -130,6 +130,7 @@ new_params['delete_redirect'] = '/%(url_name)s/list' % params new_params['invite_redirect'] = '/request/list' new_params['edit_cancel_redirect'] = '/%(url_name)s/list' % params + new_params['public_redirect'] = None new_params['sidebar'] = None new_params['sidebar_grouping'] = 'main' diff -r fea8bdb43992 -r 3aeda3007467 app/soc/views/models/base.py --- a/app/soc/views/models/base.py Sun Mar 22 22:15:46 2009 +0000 +++ b/app/soc/views/models/base.py Sun Mar 22 22:54:14 2009 +0000 @@ -122,7 +122,10 @@ return helper.responses.errorResponse( error, request, template=params['error_public'], context=context) - self._public(request, entity, context) + if not self._public(request, entity, context): + redirect = params['public_redirect'] + if redirect: + return http.HttpResponseRedirect(redirect) context['entity'] = entity context['entity_type'] = params['name'] @@ -798,12 +801,15 @@ def _public(self, request, entity, context): """Performs any required processing to get an entity's public page. + Should return True iff the public page should be displayed. + Args: request: the django request object entity: the entity to make public context: the context object """ - pass + + return True def _editGet(self, request, entity, form): """Performs any required processing on the form to get its edit page. diff -r fea8bdb43992 -r 3aeda3007467 app/soc/views/models/group_app.py --- a/app/soc/views/models/group_app.py Sun Mar 22 22:15:46 2009 +0000 +++ b/app/soc/views/models/group_app.py Sun Mar 22 22:54:14 2009 +0000 @@ -133,15 +133,6 @@ super(View, self)._editPost(request, entity, fields) - def _public(self, request, entity, context): - """See base._public(). - """ - - context['entity_type_url'] = self._params['url_name'] - - super(View, self)._public(request, entity, context) - - @decorators.merge_params @decorators.check_access def list(self, request, access_type, diff -r fea8bdb43992 -r 3aeda3007467 app/soc/views/models/notification.py --- a/app/soc/views/models/notification.py Sun Mar 22 22:15:46 2009 +0000 +++ b/app/soc/views/models/notification.py Sun Mar 22 22:54:14 2009 +0000 @@ -199,6 +199,8 @@ context['entity_type_url'] = self._params['url_name'] context['entity_suffix'] = self._logic.getKeySuffix(entity) + return True + view = View() diff -r fea8bdb43992 -r 3aeda3007467 app/soc/views/models/presence.py --- a/app/soc/views/models/presence.py Sun Mar 22 22:15:46 2009 +0000 +++ b/app/soc/views/models/presence.py Sun Mar 22 22:54:14 2009 +0000 @@ -123,9 +123,13 @@ except db.Error: home_doc = None - if home_doc: - home_doc.content = helper.templates.unescape(home_doc.content) - context['home_document'] = home_doc + if not home_doc: + return False + + home_doc.content = helper.templates.unescape(home_doc.content) + context['home_document'] = home_doc + + return True def _editGet(self, request, entity, form): """See base.View._editGet().