app/soc/views/site/settings.py
changeset 517 661ab830e921
parent 516 ec1dcd70b97e
child 518 d9d31d316a74
equal deleted inserted replaced
516:ec1dcd70b97e 517:661ab830e921
     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_name=None, scope_path=None, link_id=None, 
       
    51          logic=models.site_settings.logic,
       
    52          settings_form_class=SiteSettingsForm,
       
    53          template=settings_views.DEF_HOME_EDIT_TMPL):
       
    54   """View for authorized User to edit contents of a Site Settings page.
       
    55 
       
    56   Args:
       
    57     request: the standard django request object.
       
    58     page_name: the page name displayed in templates as page and header title
       
    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_name=page_name, scope_path=scope_path, 
       
    68                              link_id=link_id, logic=logic,
       
    69                              settings_form_class=settings_form_class,
       
    70                              template=template)
       
    71