app/soc/views/site/home.py
changeset 338 0d78f41dde9b
parent 324 05e21c089be6
child 342 72482d8e5b34
equal deleted inserted replaced
337:cb7d22b1e7d8 338:0d78f41dde9b
    52 import soc.views.helper.widgets
    52 import soc.views.helper.widgets
    53 import soc.views.out_of_band
    53 import soc.views.out_of_band
    54 
    54 
    55 
    55 
    56 class DocumentForm(helper.forms.DbModelForm):
    56 class DocumentForm(helper.forms.DbModelForm):
    57   content = forms.fields.CharField(widget=helper.widgets.TinyMCE())
    57   content = forms.fields.CharField(widget=helper.widgets.TinyMCE(
       
    58       attrs={'rows':10, 'cols':40}))
    58 
    59 
    59   class Meta:
    60   class Meta:
    60     """Inner Meta class that defines some behavior for the form.
    61     """Inner Meta class that defines some behavior for the form.
    61     """
    62     """
    62     #: db.Model subclass for which the form will gather information
    63     #: db.Model subclass for which the form will gather information
    63     model = soc.models.document.Document
    64     model = soc.models.document.Document
    64     
    65     
    65     #: list of model fields which will *not* be gathered by the form
    66     #: list of model fields which will *not* be gathered by the form
    66     exclude = ['partial_path', 'link_name',
    67     exclude = ['partial_path', 'link_name',
    67                'user', 'modified', 'created', 'inheritance_line']
    68                'founder', 'modified', 'created', 'inheritance_line']
    68 
    69 
    69 
    70 
    70 class SiteSettingsForm(helper.forms.DbModelForm):
    71 class SiteSettingsForm(helper.forms.DbModelForm):
    71   """Django form displayed when creating or editing Site Settings.
    72   """Django form displayed when creating or editing Site Settings.
    72   """
    73   """
   159 
   160 
   160     if document_form.is_valid() and settings_form.is_valid():
   161     if document_form.is_valid() and settings_form.is_valid():
   161       link_name = DEF_SITE_HOME_DOC_LINK_NAME
   162       link_name = DEF_SITE_HOME_DOC_LINK_NAME
   162       partial_path=DEF_SITE_SETTINGS_PATH
   163       partial_path=DEF_SITE_SETTINGS_PATH
   163       logged_in_id = users.get_current_user()
   164       logged_in_id = users.get_current_user()
   164       user = models.user.logic.getFromFields(email=logged_in_id.email())
   165       founder = models.user.logic.getFromFields(email=logged_in_id.email())
   165 
   166 
   166       properties = {
   167       properties = {
   167         'title': document_form.cleaned_data.get('title'),
   168         'title': document_form.cleaned_data.get('title'),
   168         'short_name': document_form.cleaned_data.get('short_name'),
   169         'short_name': document_form.cleaned_data.get('short_name'),
   169         'abstract': document_form.cleaned_data.get('abstract'),
   170         'abstract': document_form.cleaned_data.get('abstract'),
   170         'content': document_form.cleaned_data.get('content'),
   171         'content': document_form.cleaned_data.get('content'),
   171         'link_name': link_name,
   172         'link_name': link_name,
   172         'partial_path': partial_path,
   173         'partial_path': partial_path,
   173         'id': logged_in_id,
   174         'id': logged_in_id,
   174         'user': user,
   175         'founder': founder,
   175       }
   176       }
   176 
   177 
   177       site_doc = document.logic.updateOrCreateFromFields(
   178       site_doc = document.logic.updateOrCreateFromFields(
   178           properties, partial_path=partial_path, link_name=link_name)
   179           properties, partial_path=partial_path, link_name=link_name)
   179       
   180