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'}) +