app/soc/views/models/org_admin.py
changeset 1726 711c8dcab67e
parent 1663 032210fcb952
child 1730 2d877bb10306
equal deleted inserted replaced
1725:52d90bbc98dc 1726:711c8dcab67e
    31 from soc.logic.models import org_admin as org_admin_logic
    31 from soc.logic.models import org_admin as org_admin_logic
    32 from soc.logic.models import org_app as org_app_logic
    32 from soc.logic.models import org_app as org_app_logic
    33 from soc.views.helper import access
    33 from soc.views.helper import access
    34 from soc.views.helper import decorators
    34 from soc.views.helper import decorators
    35 from soc.views.helper import dynaform
    35 from soc.views.helper import dynaform
       
    36 from soc.views.helper import redirects
    36 from soc.views.helper import params as params_helper
    37 from soc.views.helper import params as params_helper
    37 from soc.views.helper import widgets
    38 from soc.views.helper import widgets
    38 from soc.views.models import organization as org_view
    39 from soc.views.models import organization as org_view
    39 from soc.views.models import role
    40 from soc.views.models import role
    40 
    41 
   192     form = context['form']
   193     form = context['form']
   193 
   194 
   194     if 'scope_path' in form.initial:
   195     if 'scope_path' in form.initial:
   195       scope_path = form.initial['scope_path']
   196       scope_path = form.initial['scope_path']
   196     elif 'scope_path' in request.POST:
   197     elif 'scope_path' in request.POST:
   197       # TODO: do this nicely
       
   198       scope_path = request.POST['scope_path']
   198       scope_path = request.POST['scope_path']
   199     else:
   199     else:
   200       # TODO: is this always sufficient?
       
   201       form.fields['admin_agreement'] = None
   200       form.fields['admin_agreement'] = None
   202       return
   201       return
   203 
   202 
   204     org_app = org_app_logic.logic.getFromKeyName(scope_path)
   203     org_app = org_app_logic.logic.getFromKeyName(scope_path)
   205 
   204 
   212     entity = org_logic.logic.getFromKeyName(scope_path)
   211     entity = org_logic.logic.getFromKeyName(scope_path)
   213 
   212 
   214     if not (entity and entity.scope and entity.scope.org_admin_agreement):
   213     if not (entity and entity.scope and entity.scope.org_admin_agreement):
   215       return
   214       return
   216 
   215 
   217     content = entity.scope.org_admin_agreement.content
   216     agreement = entity.scope.org_admin_agreement
   218 
   217 
   219     form.fields['admin_agreement'].widget.text = content
   218     if not (entity and agreement):
       
   219       return
       
   220 
       
   221     content = agreement.content
       
   222     params = {'url_name': 'document'}
       
   223 
       
   224     widget = form.fields['admin_agreement'].widget
       
   225     widget.text = content
       
   226     widget.url = redirects.getPublicRedirect(agreement, params)
   220 
   227 
   221 
   228 
   222 view = View()
   229 view = View()
   223 
   230 
   224 accept_invite = decorators.view(view.acceptInvite)
   231 accept_invite = decorators.view(view.acceptInvite)