# HG changeset patch # User Todd Larsen # Date 1232490621 0 # Node ID bb43b74c58f6b614c6b2f4c0be85fe922d480e0b # Parent 062290a3b3cfdccc4129eb99b7cd449bee360f45 A better way to add site-wide ToS link to *all* pages on the site. getUniversalContext() already fetches a copy of the Site settings, so use that to see if the site-wide ToS exist and produce a link. Patch by: Todd Larsen Review by: to-be-reviewed diff -r 062290a3b3cf -r bb43b74c58f6 app/soc/views/helper/responses.py --- a/app/soc/views/helper/responses.py Tue Jan 20 22:21:32 2009 +0000 +++ b/app/soc/views/helper/responses.py Tue Jan 20 22:30:21 2009 +0000 @@ -33,6 +33,7 @@ from soc.logic import system from soc.logic.models import site from soc.views import helper +from soc.views.helper import redirects from soc.views.helper import templates from soc.views.sitemap import sidebar @@ -116,7 +117,9 @@ if settings: context['ga_tracking_num'] = settings.ga_tracking_num - + + context['tos_link'] = getToSLink(settings) + return context @@ -168,4 +171,21 @@ context['message'] = error.message_fmt % context return respond(request, sibling_templates, context=context, - response_args=error.response_args) \ No newline at end of file + response_args=error.response_args) + +def getToSLink(presence): + """Returns link to 'show' the ToS Document if it exists, None otherwise. + + Args: + presence: Presence entity that may or may not have a tos property + """ + if not presence: + return None + + try: + tos_doc = presence.tos + except db.Error: + return None + + return redirects.getPublicRedirect(tos_doc, {'url_name': 'document'}) + diff -r 062290a3b3cf -r bb43b74c58f6 app/soc/views/models/presence.py --- a/app/soc/views/models/presence.py Tue Jan 20 22:21:32 2009 +0000 +++ b/app/soc/views/models/presence.py Tue Jan 20 22:30:21 2009 +0000 @@ -149,22 +149,6 @@ super(View, self).__init__(params=params) - def getToSLink(self, entity): - """Returns link to 'show' the ToS Document if it exists, None otherwise. - - Args: - entity: Presence entity that may or may not have a tos property - """ - if not entity: - return None - - try: - tos_doc = entity.tos - except db.Error: - return None - - return redirects.getPublicRedirect(tos_doc, {'url_name': 'document'}) - def _public(self, request, entity, context): """See base.View._public(). """ @@ -181,8 +165,6 @@ home_doc.content = helper.templates.unescape(home_doc.content) context['home_document'] = home_doc - context['tos_link'] = self.getToSLink(entity) - def _editGet(self, request, entity, form): """See base.View._editGet(). """