app/soc/views/settings.py
author Pawel Solyga <Pawel.Solyga@gmail.com>
Mon, 10 Nov 2008 23:18:06 +0000
changeset 471 dcb1f7821b39
parent 445 31927f21970d
child 482 839740b061ad
permissions -rw-r--r--
Remove stop parameter from home_settings and site_settings views. This is something Sverre didn't mean to commit :-) Add missing params description to the models Base class docs. Patch by: Pawel Solyga
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
79
58001ec7720c Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
58001ec7720c Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     2
#
58001ec7720c Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     3
# Copyright 2008 the Melange authors.
58001ec7720c Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     4
#
58001ec7720c Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
58001ec7720c Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
58001ec7720c Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
58001ec7720c Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     8
#
58001ec7720c Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
58001ec7720c Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    10
#
58001ec7720c Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
58001ec7720c Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
58001ec7720c Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
58001ec7720c Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
58001ec7720c Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
58001ec7720c Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    16
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
    17
"""Home page settings views.
88
9a8180f0941a Some additional __doc__ comments (with some ideas for future plans) and removal
Todd Larsen <tlarsen@google.com>
parents: 81
diff changeset
    18
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
    19
edit: settings view for authorized Developers, Administrators, etc.
79
58001ec7720c Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    20
"""
58001ec7720c Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    21
58001ec7720c Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    22
__authors__ = [
58001ec7720c Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    23
  '"Pawel Solyga" <pawel.solyga@gmail.com>',
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
    24
  '"Todd Larsen" <tlarsen@google.com>',
79
58001ec7720c Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    25
  ]
58001ec7720c Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    26
58001ec7720c Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    27
314
dfaf249c12b2 Rearrange imports in home.py so they apply to new discussed format (separate "from ..." and "import ..." blocks). Add Delete Document functionality.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 311
diff changeset
    28
from google.appengine.ext import db
141
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
    29
324
05e21c089be6 Add missing import in soc/views/site/sponsor/list.py which caused exception when app was deployed and first site you visited was "List Site Sponsors". Update files according to recent django update and django backwards incompatibility (for example newforms is changed to forms).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 321
diff changeset
    30
from django import forms
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
    31
from django.utils.translation import ugettext_lazy
141
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
    32
309
7190b224c701 Made the existing code use the new soc.logic.models
Sverre Rabbelier <srabbelier@gmail.com>
parents: 305
diff changeset
    33
from soc.logic import models
249
325fb70c61a9 Replace common module with validate module. Move validation function from feed module to validate module and remove feed.py. Correct any usage of validation functions from common and feed modules into validate module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 225
diff changeset
    34
from soc.logic import validate
309
7190b224c701 Made the existing code use the new soc.logic.models
Sverre Rabbelier <srabbelier@gmail.com>
parents: 305
diff changeset
    35
from soc.logic.models import document
270
7dd6d8347b56 Move helpers/template_helpers.py to helper/templates.py.
Todd Larsen <tlarsen@google.com>
parents: 249
diff changeset
    36
from soc.views import helper
303
4f1bb54ddae5 Moved soc/logic/helper/access to soc/views/helper/access
Sverre Rabbelier <srabbelier@gmail.com>
parents: 299
diff changeset
    37
from soc.views.helper import access
365
74dec172944e Create decorators module in view/helper and add view decorator that catches exceptions like DeadlineExceededError, MemoryError, AssertionError (this code is being moved from respond function). Add view decorator to all view functions. In addition remove not needed imports from all affected files and fix too long lines.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 358
diff changeset
    38
from soc.views.helper import decorators
314
dfaf249c12b2 Rearrange imports in home.py so they apply to new discussed format (separate "from ..." and "import ..." blocks). Add Delete Document functionality.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 311
diff changeset
    39
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
    40
import soc.logic.models.home_settings
314
dfaf249c12b2 Rearrange imports in home.py so they apply to new discussed format (separate "from ..." and "import ..." blocks). Add Delete Document functionality.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 311
diff changeset
    41
import soc.models.document
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
    42
import soc.models.home_settings
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
    43
import soc.models.work
274
56e1c1721299 Move helpers/forms_helpers.py to helper/forms.py.
Todd Larsen <tlarsen@google.com>
parents: 272
diff changeset
    44
import soc.views.helper.forms
272
00cea07656c0 Move helpers/response_helpers.py to helper/responses.py.
Todd Larsen <tlarsen@google.com>
parents: 271
diff changeset
    45
import soc.views.helper.responses
270
7dd6d8347b56 Move helpers/template_helpers.py to helper/templates.py.
Todd Larsen <tlarsen@google.com>
parents: 249
diff changeset
    46
import soc.views.helper.templates
271
01e90bb21b7e Replace helpers/custom_widgets.py with helper/widgets.py.
Todd Larsen <tlarsen@google.com>
parents: 270
diff changeset
    47
import soc.views.helper.widgets
314
dfaf249c12b2 Rearrange imports in home.py so they apply to new discussed format (separate "from ..." and "import ..." blocks). Add Delete Document functionality.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 311
diff changeset
    48
import soc.views.out_of_band
79
58001ec7720c Home site templates and basic view.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff changeset
    49
88
9a8180f0941a Some additional __doc__ comments (with some ideas for future plans) and removal
Todd Larsen <tlarsen@google.com>
parents: 81
diff changeset
    50
408
7cd6bdfbf95c Inherit from BaseForm in all forms instead of from DbModelForm. This change doesn't include changes to templates and usage of as_table everywhere (work in progress).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 405
diff changeset
    51
class SettingsValidationForm(helper.forms.BaseForm):
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
    52
  """Django form displayed when creating or editing Settings.
405
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
    53
  
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
    54
  This form includes validation functions for Settings fields.
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
    55
  """
271
01e90bb21b7e Replace helpers/custom_widgets.py with helper/widgets.py.
Todd Larsen <tlarsen@google.com>
parents: 270
diff changeset
    56
141
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
    57
  def clean_feed_url(self):
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
    58
    feed_url = self.cleaned_data.get('feed_url')
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
    59
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
    60
    if feed_url == '':
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
    61
      # feed url not supplied (which is OK), so do not try to validate it
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
    62
      return None
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
    63
    
249
325fb70c61a9 Replace common module with validate module. Move validation function from feed module to validate module and remove feed.py. Correct any usage of validation functions from common and feed modules into validate module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 225
diff changeset
    64
    if not validate.isFeedURLValid(feed_url):
141
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
    65
      raise forms.ValidationError('This URL is not a valid ATOM or RSS feed.')
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
    66
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
    67
    return feed_url
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
    68
206
832335761384 Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents: 164
diff changeset
    69
405
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
    70
class SettingsForm(SettingsValidationForm):
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
    71
  """Django form displayed when creating or editing Settings.
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
    72
  """
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
    73
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
    74
  class Meta:
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
    75
    """Inner Meta class that defines some behavior for the form.
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
    76
    """
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
    77
    #: db.Model subclass for which the form will gather information
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
    78
    model = soc.models.home_settings.HomeSettings
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
    79
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
    80
    #: list of model fields which will *not* be gathered by the form
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
    81
    exclude = ['inheritance_line', 'home']
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
    82
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
    83
408
7cd6bdfbf95c Inherit from BaseForm in all forms instead of from DbModelForm. This change doesn't include changes to templates and usage of as_table everywhere (work in progress).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 405
diff changeset
    84
class DocSelectForm(helper.forms.BaseForm):
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
    85
  """Django form displayed to select a Document.
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
    86
  """
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
    87
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
    88
  # TODO(tlarsen): partial_path will be a hard-coded read-only
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
    89
  #   field for some (most?) User Roles
445
31927f21970d Major site restructuring, also deleting of many unused or obsolete documents
Sverre Rabbelier <srabbelier@gmail.com>
parents: 435
diff changeset
    90
  doc_partial_path = forms.CharField(required=False,
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
    91
      label=soc.models.work.Work.partial_path.verbose_name,
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
    92
      help_text=soc.models.work.Work.partial_path.help_text)
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
    93
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
    94
  # TODO(tlarsen): actually, using these two text fields to specify
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
    95
  #   the Document is pretty cheesy; this needs to be some much better
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
    96
  #   Role-scoped Document selector that we don't have yet
445
31927f21970d Major site restructuring, also deleting of many unused or obsolete documents
Sverre Rabbelier <srabbelier@gmail.com>
parents: 435
diff changeset
    97
  doc_link_name = forms.CharField(required=False,
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
    98
      label=soc.models.work.Work.link_name.verbose_name,
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
    99
      help_text=soc.models.work.Work.link_name.help_text)
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   100
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   101
  class Meta:
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   102
    model = None
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   103
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   104
445
31927f21970d Major site restructuring, also deleting of many unused or obsolete documents
Sverre Rabbelier <srabbelier@gmail.com>
parents: 435
diff changeset
   105
DEF_HOME_EDIT_TMPL = 'soc/site_settings/edit.html'
141
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
   106
365
74dec172944e Create decorators module in view/helper and add view decorator that catches exceptions like DeadlineExceededError, MemoryError, AssertionError (this code is being moved from respond function). Add view decorator to all view functions. In addition remove not needed imports from all affected files and fix too long lines.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 358
diff changeset
   107
@decorators.view
445
31927f21970d Major site restructuring, also deleting of many unused or obsolete documents
Sverre Rabbelier <srabbelier@gmail.com>
parents: 435
diff changeset
   108
def edit(request, page=None, partial_path=None, link_name=None, 
31927f21970d Major site restructuring, also deleting of many unused or obsolete documents
Sverre Rabbelier <srabbelier@gmail.com>
parents: 435
diff changeset
   109
         logic=models.home_settings.logic,
405
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
   110
         settings_form_class=SettingsForm,
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   111
         template=DEF_HOME_EDIT_TMPL):
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   112
  """View for authorized User to edit contents of a home page.
141
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
   113
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
   114
  Args:
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
   115
    request: the standard django request object.
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   116
    page: a soc.logic.site.page.Page object which is abstraction that
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   117
      combines a Django view with sidebar menu info
405
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
   118
    path: path that is used to uniquely identify settings
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
   119
    logic: settings logic object
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
   120
    settings_form_class:
141
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
   121
    template: the template path to use for rendering the template.
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
   122
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
   123
  Returns:
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
   124
    A subclass of django.http.HttpResponse with generated template.
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
   125
  """
294
1fdaab4a6ef2 Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 290
diff changeset
   126
1fdaab4a6ef2 Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 290
diff changeset
   127
  try:
1fdaab4a6ef2 Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 290
diff changeset
   128
    access.checkIsDeveloper(request)
303
4f1bb54ddae5 Moved soc/logic/helper/access to soc/views/helper/access
Sverre Rabbelier <srabbelier@gmail.com>
parents: 299
diff changeset
   129
  except  soc.views.out_of_band.AccessViolationResponse, alt_response:
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   130
    # TODO(tlarsen): change this to just limit Settings paths that can be
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   131
    #   viewed or modified by the User in their current Role
294
1fdaab4a6ef2 Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 290
diff changeset
   132
    return alt_response.response()
1fdaab4a6ef2 Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 290
diff changeset
   133
141
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
   134
  # create default template context for use with any templates
272
00cea07656c0 Move helpers/response_helpers.py to helper/responses.py.
Todd Larsen <tlarsen@google.com>
parents: 271
diff changeset
   135
  context = helper.responses.getUniversalContext(request)
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   136
  context['page'] = page
294
1fdaab4a6ef2 Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 290
diff changeset
   137
141
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
   138
  settings_form = None
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   139
  doc_select_form = None
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   140
  home_doc = None
141
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
   141
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
   142
  if request.method == 'POST':
405
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
   143
    settings_form = settings_form_class(request.POST)
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   144
    doc_select_form = DocSelectForm(request.POST)
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   145
    
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   146
    if doc_select_form.is_valid() and settings_form.is_valid():
435
829fe8302a8b Refactor out the abundance of dictionary (un)packing
Sverre Rabbelier <srabbelier@gmail.com>
parents: 408
diff changeset
   147
      fields = {}
405
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
   148
      
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
   149
      # Ask for all the fields and pull them out 
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
   150
      for field in settings_form.cleaned_data:
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
   151
        value = settings_form.cleaned_data.get(field)
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
   152
        fields[field] = value
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
   153
445
31927f21970d Major site restructuring, also deleting of many unused or obsolete documents
Sverre Rabbelier <srabbelier@gmail.com>
parents: 435
diff changeset
   154
      doc_partial_path = doc_select_form.cleaned_data.get('doc_partial_path')
31927f21970d Major site restructuring, also deleting of many unused or obsolete documents
Sverre Rabbelier <srabbelier@gmail.com>
parents: 435
diff changeset
   155
      doc_link_name = doc_select_form.cleaned_data.get('doc_link_name')
294
1fdaab4a6ef2 Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents: 290
diff changeset
   156
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   157
      home_doc = document.logic.getFromFields(
445
31927f21970d Major site restructuring, also deleting of many unused or obsolete documents
Sverre Rabbelier <srabbelier@gmail.com>
parents: 435
diff changeset
   158
          partial_path=doc_partial_path, link_name=doc_link_name)
299
a1cc853a56e5 Refactor nearly all the soc.logic code to use the Base class
Sverre Rabbelier <srabbelier@gmail.com>
parents: 294
diff changeset
   159
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   160
      if home_doc:
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   161
        fields['home'] = home_doc
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   162
        context['notice'] = ugettext_lazy('Settings saved.')
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   163
      else:
390
d12c95ade374 Remove unused imports, fix too long lines and indentions.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 377
diff changeset
   164
        context['notice'] = ugettext_lazy(
d12c95ade374 Remove unused imports, fix too long lines and indentions.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 377
diff changeset
   165
            'Document not specified or could not be found; ' \
d12c95ade374 Remove unused imports, fix too long lines and indentions.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 377
diff changeset
   166
            'other Settings saved.')
141
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
   167
435
829fe8302a8b Refactor out the abundance of dictionary (un)packing
Sverre Rabbelier <srabbelier@gmail.com>
parents: 408
diff changeset
   168
      key_fields = logic.getKeyFieldsFromDict(fields)
829fe8302a8b Refactor out the abundance of dictionary (un)packing
Sverre Rabbelier <srabbelier@gmail.com>
parents: 408
diff changeset
   169
      settings = logic.updateOrCreateFromFields(fields, key_fields)
141
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
   170
      
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   171
      if settings.home:
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   172
        home_doc = settings.home
141
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
   173
  else: # request.method == 'GET'
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   174
    # try to fetch HomeSettings entity by unique key_name
445
31927f21970d Major site restructuring, also deleting of many unused or obsolete documents
Sverre Rabbelier <srabbelier@gmail.com>
parents: 435
diff changeset
   175
    settings = logic.getFromFields(partial_path=partial_path, 
31927f21970d Major site restructuring, also deleting of many unused or obsolete documents
Sverre Rabbelier <srabbelier@gmail.com>
parents: 435
diff changeset
   176
                                   link_name=link_name)
141
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
   177
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   178
    if settings:
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   179
      # populate form with the existing HomeSettings entity
405
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
   180
      settings_form = settings_form_class(instance=settings)
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   181
314
dfaf249c12b2 Rearrange imports in home.py so they apply to new discussed format (separate "from ..." and "import ..." blocks). Add Delete Document functionality.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 311
diff changeset
   182
      # check if ReferenceProperty to home Document is valid
dfaf249c12b2 Rearrange imports in home.py so they apply to new discussed format (separate "from ..." and "import ..." blocks). Add Delete Document functionality.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 311
diff changeset
   183
      try:
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   184
        home_doc = settings.home
314
dfaf249c12b2 Rearrange imports in home.py so they apply to new discussed format (separate "from ..." and "import ..." blocks). Add Delete Document functionality.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 311
diff changeset
   185
      except db.Error:
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   186
        pass
314
dfaf249c12b2 Rearrange imports in home.py so they apply to new discussed format (separate "from ..." and "import ..." blocks). Add Delete Document functionality.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 311
diff changeset
   187
    
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   188
      if home_doc:
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   189
        doc_select_form = DocSelectForm(initial={
445
31927f21970d Major site restructuring, also deleting of many unused or obsolete documents
Sverre Rabbelier <srabbelier@gmail.com>
parents: 435
diff changeset
   190
            'doc_partial_path': home_doc.partial_path,
31927f21970d Major site restructuring, also deleting of many unused or obsolete documents
Sverre Rabbelier <srabbelier@gmail.com>
parents: 435
diff changeset
   191
            'doc_link_name': home_doc.link_name})
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   192
      else:
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   193
        doc_select_form = DocSelectForm()
206
832335761384 Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents: 164
diff changeset
   194
    else:
832335761384 Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents: 164
diff changeset
   195
      # no SiteSettings entity exists for this key_name, so show a blank form
405
f3525c1288ed Add Google Analytics support to Site Settings. The reason I created additional SettingsValidationForm is because you cannot inherit from Form that has already defined Meta class, so it's sort of workaround for that. I didn't want to have same validation functions in both Form classes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 390
diff changeset
   196
      settings_form = settings_form_class()
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   197
      doc_select_form = DocSelectForm()
206
832335761384 Make use of PolyModel for Works, Documents, etc. Add some (but not all) of
Todd Larsen <tlarsen@google.com>
parents: 164
diff changeset
   198
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   199
  context.update({'settings_form': settings_form,
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   200
                  'doc_select_form': doc_select_form,
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   201
                  'home_doc': home_doc})
141
e120c24b89e2 Added Melange front page edit view where you can change title, content, feed url. Created SiteSettings and Document models and some logic for them. Added isFeedURLValid function in soc/logic/feed.py. Created some functions for handling datastore updates of different kinds of Models (soc/logic/model.py). Fixed some typos and too long lines of code.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 88
diff changeset
   202
  
377
d94ec6f104cc Refactor various site views into more generic locations, in preparation for
Todd Larsen <tlarsen@google.com>
parents: 370
diff changeset
   203
  return helper.responses.respond(request, template, context)