app/soc/views/models/home_settings.py
changeset 452 160c748988a2
parent 446 0b479d573a4c
child 466 ad2908f1646a
equal deleted inserted replaced
451:c79a84c59f42 452:160c748988a2
    28 from django import forms
    28 from django import forms
    29 from django.utils.translation import ugettext_lazy
    29 from django.utils.translation import ugettext_lazy
    30 
    30 
    31 from soc.logic import dicts
    31 from soc.logic import dicts
    32 from soc.logic import validate
    32 from soc.logic import validate
       
    33 from soc.logic.models import document as document_logic
    33 from soc.views import helper
    34 from soc.views import helper
    34 from soc.views.helper import widgets
    35 from soc.views.helper import widgets
    35 from soc.views.models import base
    36 from soc.views.models import base
    36 
    37 
    37 import soc.models.home_settings
    38 import soc.models.home_settings
   127       'list_pagination': 'soc/list/list_pagination.html',
   128       'list_pagination': 'soc/list/list_pagination.html',
   128       'list_row': 'soc/home_settings/list/home_row.html',
   129       'list_row': 'soc/home_settings/list/home_row.html',
   129       'list_heading': 'soc/home_settings/list/home_heading.html',
   130       'list_heading': 'soc/home_settings/list/home_heading.html',
   130     }
   131     }
   131 
   132 
   132     params['delete_redirect'] = 'home/list'
   133     params['delete_redirect'] = '/home/list'
   133     params['create_redirect'] = 'home/edit'
   134     params['create_redirect'] = '/home/edit'
   134 
   135 
   135     params['save_message'] = [ugettext_lazy('Profile saved.')]
   136     params['save_message'] = [ugettext_lazy('Profile saved.')]
   136 
   137 
   137     params['edit_params'] = {
   138     params['edit_params'] = {
   138         self.DEF_SUBMIT_MSG_PARAM_NAME: self.DEF_SUBMIT_MSG_PROFILE_SAVED,
   139         self.DEF_SUBMIT_MSG_PARAM_NAME: self.DEF_SUBMIT_MSG_PROFILE_SAVED,
   167   def _editGet(self, request, entity, form):
   168   def _editGet(self, request, entity, form):
   168     """See base.View._editGet().
   169     """See base.View._editGet().
   169     """
   170     """
   170 
   171 
   171     try:
   172     try:
   172       form.fields['doc_partial_path'].initial = entity.home.partial_path
   173       if entity.home:
   173       form.fields['doc_link_name'].initial = entity.home.link_name
   174         form.fields['doc_partial_path'].initial = entity.home.partial_path
       
   175         form.fields['doc_link_name'].initial = entity.home.link_name
   174     except db.Error:
   176     except db.Error:
   175       pass
   177       pass
       
   178 
       
   179   def _editPost(self, request, entity, fields):
       
   180     """See base.View._editPost().
       
   181     """
       
   182 
       
   183     doc_partial_path = fields['doc_partial_path']
       
   184     doc_link_name = fields['doc_link_name']
       
   185 
       
   186     # TODO notify the user if home_doc is not found
       
   187     home_doc = document_logic.logic.getFromFields(
       
   188     partial_path=doc_partial_path, link_name=doc_link_name)
       
   189 
       
   190     fields['home'] = home_doc
   176 
   191 
   177 
   192 
   178 view = View()
   193 view = View()
   179 
   194 
   180 create = view.create
   195 create = view.create