app/soc/views/site/settings.py
changeset 405 f3525c1288ed
child 411 c8ac5c1161e2
equal deleted inserted replaced
404:44223e50e1fc 405:f3525c1288ed
       
     1 #!/usr/bin/python2.5
       
     2 #
       
     3 # Copyright 2008 the Melange authors.
       
     4 #
       
     5 # Licensed under the Apache License, Version 2.0 (the "License");
       
     6 # you may not use this file except in compliance with the License.
       
     7 # You may obtain a copy of the License at
       
     8 #
       
     9 #   http://www.apache.org/licenses/LICENSE-2.0
       
    10 #
       
    11 # Unless required by applicable law or agreed to in writing, software
       
    12 # distributed under the License is distributed on an "AS IS" BASIS,
       
    13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    14 # See the License for the specific language governing permissions and
       
    15 # limitations under the License.
       
    16 
       
    17 """Site Settings views.
       
    18 
       
    19 edit: settings view for authorized Developers, Administrators, etc.
       
    20 """
       
    21 
       
    22 __authors__ = [
       
    23   '"Pawel Solyga" <pawel.solyga@gmail.com>',
       
    24   ]
       
    25 
       
    26 
       
    27 from soc.logic import models
       
    28 from soc.views import settings as settings_views
       
    29 from soc.views.helper import decorators
       
    30 
       
    31 import soc.logic.models.site_settings
       
    32 import soc.models.site_settings
       
    33 
       
    34 
       
    35 class SiteSettingsForm(settings_views.SettingsValidationForm):
       
    36   """Django form displayed when creating or editing Site Settings.
       
    37   """
       
    38 
       
    39   class Meta:
       
    40     """Inner Meta class that defines some behavior for the form.
       
    41     """
       
    42     #: db.Model subclass for which the form will gather information
       
    43     model = soc.models.site_settings.SiteSettings
       
    44 
       
    45     #: list of model fields which will *not* be gathered by the form
       
    46     exclude = ['inheritance_line', 'home']
       
    47 
       
    48 
       
    49 @decorators.view
       
    50 def edit(request, page=None, path=None, logic=models.site_settings.logic,
       
    51          settings_form_class=SiteSettingsForm,
       
    52          template=settings_views.DEF_HOME_EDIT_TMPL):
       
    53   """View for authorized User to edit contents of a Site Settings page.
       
    54 
       
    55   Args:
       
    56     request: the standard django request object.
       
    57     page: a soc.logic.site.page.Page object which is abstraction that
       
    58       combines a Django view with sidebar menu info
       
    59     path: path that is used to uniquely identify settings
       
    60     logic: settings logic object
       
    61     settings_form_class: class which should be used as Site Settings Form
       
    62     template: the template path to use for rendering the template.
       
    63 
       
    64   Returns:
       
    65     A subclass of django.http.HttpResponse with generated template.
       
    66   """
       
    67   return settings_views.edit(request, page=page, path=path, logic=logic,
       
    68                              settings_form_class=SiteSettingsForm,
       
    69                              template=template)