app/soc/views/models/mentor.py
changeset 1726 711c8dcab67e
parent 1659 ed1a0f139a21
child 1763 6bd59cad39a5
--- a/app/soc/views/models/mentor.py	Sat Mar 07 19:45:38 2009 +0000
+++ b/app/soc/views/models/mentor.py	Sat Mar 07 19:46:18 2009 +0000
@@ -31,6 +31,7 @@
 from soc.views.helper import access
 from soc.views.helper import decorators
 from soc.views.helper import dynaform
+from soc.views.helper import redirects
 from soc.views.helper import params as params_helper
 from soc.views.helper import widgets
 from soc.views.models import organization as org_view
@@ -192,10 +193,8 @@
     if 'scope_path' in form.initial:
       scope_path = form.initial['scope_path']
     elif 'scope_path' in request.POST:
-      # TODO: do this nicely
       scope_path = request.POST['scope_path']
     else:
-      # TODO: is this always sufficient?
       form.fields['mentor_agreement'] = None
       return
 
@@ -204,9 +203,18 @@
     if not (entity and entity.scope and entity.scope.mentor_agreement):
       return
 
-    content = entity.scope.mentor_agreement.content
+    agreement = entity.scope.mentor_agreement
+
+    if not (entity and agreement):
+      return
 
-    form.fields['mentor_agreement'].widget.text = content
+    content = agreement.content
+    params = {'url_name': 'document'}
+
+    widget = form.fields['mentor_agreement'].widget
+    widget.text = content
+    widget.url = redirects.getPublicRedirect(agreement, params)
+
 
 view = View()