app/soc/views/models/presence.py
changeset 1051 c532dd9def48
parent 1007 3b66772d21a5
child 1079 be1aacb33b0f
equal deleted inserted replaced
1050:77aab03aa693 1051:c532dd9def48
    64 
    64 
    65     new_params['extra_dynaexclude'] = ['home', 'tos']
    65     new_params['extra_dynaexclude'] = ['home', 'tos']
    66     new_params['home_template'] = 'soc/presence/home.html'
    66     new_params['home_template'] = 'soc/presence/home.html'
    67 
    67 
    68     new_params['create_extra_dynafields'] = {
    68     new_params['create_extra_dynafields'] = {
    69         # override some editors
       
    70         'home_link_id': forms.CharField(required=False,
    69         'home_link_id': forms.CharField(required=False,
    71             label=ugettext('Home page Document link ID'),
    70             label=ugettext('Home page Document link ID'),
    72             help_text=soc.models.work.Work.link_id.help_text),
       
    73 
       
    74         'tos_link_id': forms.CharField(required=False,
       
    75             label=ugettext('Terms of Service Document link ID'),
       
    76             help_text=soc.models.work.Work.link_id.help_text),
    71             help_text=soc.models.work.Work.link_id.help_text),
    77 
    72 
    78         # add cleaning of the link id and feed url
    73         # add cleaning of the link id and feed url
    79         'clean_link_id': cleaning.clean_link_id,
    74         'clean_link_id': cleaning.clean_link_id,
    80         'clean_feed_url': cleaning.clean_feed_url,
    75         'clean_feed_url': cleaning.clean_feed_url,
   133       if entity.home:
   128       if entity.home:
   134         form.fields['home_link_id'].initial = entity.home.link_id
   129         form.fields['home_link_id'].initial = entity.home.link_id
   135     except db.Error:
   130     except db.Error:
   136       pass
   131       pass
   137 
   132 
   138     try:
       
   139       if entity.tos:
       
   140         form.fields['tos_link_id'].initial = entity.tos.link_id
       
   141     except db.Error:
       
   142       pass
       
   143 
       
   144     super(View, self)._editGet(request, entity, form)
   133     super(View, self)._editGet(request, entity, form)
   145 
   134 
   146   def _editPost(self, request, entity, fields):
   135   def _editPost(self, request, entity, fields):
   147     """See base.View._editPost().
   136     """See base.View._editPost().
   148     """
   137     """
   155     home_doc = document_logic.logic.getFromFields(
   144     home_doc = document_logic.logic.getFromFields(
   156       scope_path=scope_path, link_id=home_link_id)
   145       scope_path=scope_path, link_id=home_link_id)
   157 
   146 
   158     fields['home'] = home_doc
   147     fields['home'] = home_doc
   159 
   148 
   160     tos_link_id = fields['tos_link_id']
       
   161 
       
   162     # TODO notify the user if tos_doc is not found
       
   163     tos_doc = document_logic.logic.getFromFields(
       
   164       scope_path=scope_path, link_id=tos_link_id)
       
   165 
       
   166     fields['tos'] = tos_doc
       
   167 
       
   168     super(View, self)._editPost(request, entity, fields)
   149     super(View, self)._editPost(request, entity, fields)