author | Sverre Rabbelier <srabbelier@gmail.com> |
Sat, 22 Nov 2008 14:01:39 +0000 | |
changeset 554 | 68c7a1dd3c52 |
parent 551 | 2ee7ad5266a8 |
child 559 | 44e50e92621e |
permissions | -rw-r--r-- |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
2 |
# |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
4 |
# |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
8 |
# |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
10 |
# |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
16 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
17 |
"""Views for Site Settings. |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
18 |
""" |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
19 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
21 |
'"Sverre Rabbelier" <sverre@rabbelier.nl>', |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
22 |
] |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
23 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
24 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
25 |
from google.appengine.ext import db |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
26 |
from google.appengine.api import users |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
27 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
28 |
from django import forms |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
29 |
from django.utils.translation import ugettext_lazy |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
30 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
31 |
from soc.logic import dicts |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
32 |
from soc.logic import validate |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
33 |
from soc.views import helper |
551
2ee7ad5266a8
Define a default for rights['public'] in views/models/base.py. Alter rights
Todd Larsen <tlarsen@google.com>
parents:
544
diff
changeset
|
34 |
from soc.views.helper import access |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
35 |
from soc.views.helper import widgets |
534
c31cfbf1a20f
Replace HomeSettings with Presence Model class. Replace SiteSettings with
Todd Larsen <tlarsen@google.com>
parents:
513
diff
changeset
|
36 |
from soc.views.models import presence |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
37 |
|
534
c31cfbf1a20f
Replace HomeSettings with Presence Model class. Replace SiteSettings with
Todd Larsen <tlarsen@google.com>
parents:
513
diff
changeset
|
38 |
import soc.models.site |
c31cfbf1a20f
Replace HomeSettings with Presence Model class. Replace SiteSettings with
Todd Larsen <tlarsen@google.com>
parents:
513
diff
changeset
|
39 |
import soc.logic.models.site |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
40 |
import soc.logic.dicts |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
41 |
import soc.views.helper |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
42 |
import soc.views.helper.widgets |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
43 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
44 |
|
534
c31cfbf1a20f
Replace HomeSettings with Presence Model class. Replace SiteSettings with
Todd Larsen <tlarsen@google.com>
parents:
513
diff
changeset
|
45 |
class CreateForm(presence.SettingsValidationForm): |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
46 |
"""Django form displayed when creating or editing Site Settings. |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
47 |
""" |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
48 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
49 |
class Meta: |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
50 |
"""Inner Meta class that defines some behavior for the form. |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
51 |
""" |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
52 |
#: db.Model subclass for which the form will gather information |
534
c31cfbf1a20f
Replace HomeSettings with Presence Model class. Replace SiteSettings with
Todd Larsen <tlarsen@google.com>
parents:
513
diff
changeset
|
53 |
model = soc.models.site.Site |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
54 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
55 |
#: list of model fields which will *not* be gathered by the form |
537
f2bd9c465a6d
Fix getKeyValues() method footprint mismatches in soc.logic.models.site.Logic
Todd Larsen <tlarsen@google.com>
parents:
536
diff
changeset
|
56 |
exclude = ['inheritance_line', 'home', 'scope', 'scope_path', 'link_id'] |
490
7cfa2ad62944
Allow pre-seeding a create form
Sverre Rabbelier <srabbelier@gmail.com>
parents:
482
diff
changeset
|
57 |
|
544
10f9da7e0d17
Fix broken Site settings form by uncommenting code that was inadvertently
Todd Larsen <tlarsen@google.com>
parents:
542
diff
changeset
|
58 |
scope_path = forms.CharField(widget=forms.HiddenInput) |
490
7cfa2ad62944
Allow pre-seeding a create form
Sverre Rabbelier <srabbelier@gmail.com>
parents:
482
diff
changeset
|
59 |
|
544
10f9da7e0d17
Fix broken Site settings form by uncommenting code that was inadvertently
Todd Larsen <tlarsen@google.com>
parents:
542
diff
changeset
|
60 |
link_id = forms.CharField(widget=forms.HiddenInput) |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
61 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
62 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
63 |
class EditForm(CreateForm): |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
64 |
"""Django form displayed a Document is edited. |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
65 |
""" |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
66 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
67 |
pass |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
68 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
69 |
|
534
c31cfbf1a20f
Replace HomeSettings with Presence Model class. Replace SiteSettings with
Todd Larsen <tlarsen@google.com>
parents:
513
diff
changeset
|
70 |
class View(presence.View): |
499
d22e4fe8e64b
Fix missing dots in doc strings and some other doc string corrections.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
494
diff
changeset
|
71 |
"""View methods for the Document model. |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
72 |
""" |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
73 |
|
507
3603fdafabf7
Fold the _rights dictionary into params
Sverre Rabbelier <srabbelier@gmail.com>
parents:
502
diff
changeset
|
74 |
def __init__(self, original_params=None): |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
75 |
"""Defines the fields and methods required for the base View class |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
76 |
to provide the user with list, public, create, edit and delete views. |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
77 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
78 |
Params: |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
79 |
original_params: a dict with params for this View |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
80 |
""" |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
81 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
82 |
params = {} |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
83 |
|
542
7cc99461b64d
Remove redundant dicts for URL patterns and sidebar menu text, and use the
Todd Larsen <tlarsen@google.com>
parents:
537
diff
changeset
|
84 |
# TODO(alturin): add ugettext_lazy ? |
466
ad2908f1646a
Fix names typos in home_settings and site_settings modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
452
diff
changeset
|
85 |
params['name'] = "Site Settings" |
542
7cc99461b64d
Remove redundant dicts for URL patterns and sidebar menu text, and use the
Todd Larsen <tlarsen@google.com>
parents:
537
diff
changeset
|
86 |
params['name_short'] = "Site" |
466
ad2908f1646a
Fix names typos in home_settings and site_settings modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
452
diff
changeset
|
87 |
params['name_plural'] = "Site Settings" |
502
e1e24c0a4e82
Add new parameters to views: url_name which is name used in urls (instead of using lower entity names) and module_name which is used for constructing django urls. Append changes to all affected files. Fix some title names. Change urls that included underscores like "site_settings" into urls with slash "site/settings". Plus some other minor fixes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
500
diff
changeset
|
88 |
# lower name and replace " " with "/" |
e1e24c0a4e82
Add new parameters to views: url_name which is name used in urls (instead of using lower entity names) and module_name which is used for constructing django urls. Append changes to all affected files. Fix some title names. Change urls that included underscores like "site_settings" into urls with slash "site/settings". Plus some other minor fixes.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
500
diff
changeset
|
89 |
params['url_name'] = "site/settings" |
534
c31cfbf1a20f
Replace HomeSettings with Presence Model class. Replace SiteSettings with
Todd Larsen <tlarsen@google.com>
parents:
513
diff
changeset
|
90 |
params['module_name'] = "site" |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
91 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
92 |
params['edit_form'] = EditForm |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
93 |
params['create_form'] = CreateForm |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
94 |
|
542
7cc99461b64d
Remove redundant dicts for URL patterns and sidebar menu text, and use the
Todd Larsen <tlarsen@google.com>
parents:
537
diff
changeset
|
95 |
params['sidebar_defaults'] = [('/%s/edit', 'Edit %(name)s')] |
7cc99461b64d
Remove redundant dicts for URL patterns and sidebar menu text, and use the
Todd Larsen <tlarsen@google.com>
parents:
537
diff
changeset
|
96 |
params['sidebar_heading'] = params['name_short'] |
7cc99461b64d
Remove redundant dicts for URL patterns and sidebar menu text, and use the
Todd Larsen <tlarsen@google.com>
parents:
537
diff
changeset
|
97 |
|
554
68c7a1dd3c52
Renamed templates/soc/entity/list/entity_*.html to *.html
Sverre Rabbelier <srabbelier@gmail.com>
parents:
551
diff
changeset
|
98 |
params['public_template'] = 'soc/home/public.html' |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
99 |
|
551
2ee7ad5266a8
Define a default for rights['public'] in views/models/base.py. Alter rights
Todd Larsen <tlarsen@google.com>
parents:
544
diff
changeset
|
100 |
params['rights'] = { |
554
68c7a1dd3c52
Renamed templates/soc/entity/list/entity_*.html to *.html
Sverre Rabbelier <srabbelier@gmail.com>
parents:
551
diff
changeset
|
101 |
'unspecified': [access.checkIsDeveloper], |
551
2ee7ad5266a8
Define a default for rights['public'] in views/models/base.py. Alter rights
Todd Larsen <tlarsen@google.com>
parents:
544
diff
changeset
|
102 |
'any_access': [access.allow], |
554
68c7a1dd3c52
Renamed templates/soc/entity/list/entity_*.html to *.html
Sverre Rabbelier <srabbelier@gmail.com>
parents:
551
diff
changeset
|
103 |
'public': [access.allow] |
68c7a1dd3c52
Renamed templates/soc/entity/list/entity_*.html to *.html
Sverre Rabbelier <srabbelier@gmail.com>
parents:
551
diff
changeset
|
104 |
} |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
105 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
106 |
params = dicts.merge(original_params, params) |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
107 |
|
534
c31cfbf1a20f
Replace HomeSettings with Presence Model class. Replace SiteSettings with
Todd Larsen <tlarsen@google.com>
parents:
513
diff
changeset
|
108 |
presence.View.__init__(self, original_params=params) |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
109 |
|
534
c31cfbf1a20f
Replace HomeSettings with Presence Model class. Replace SiteSettings with
Todd Larsen <tlarsen@google.com>
parents:
513
diff
changeset
|
110 |
self._logic = soc.logic.models.site.logic |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
111 |
|
482
839740b061ad
Factor out direct use of the page object
Sverre Rabbelier <srabbelier@gmail.com>
parents:
477
diff
changeset
|
112 |
def main_public(self, request, page_name=None, **kwargs): |
499
d22e4fe8e64b
Fix missing dots in doc strings and some other doc string corrections.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
494
diff
changeset
|
113 |
"""Displays the main site settings page. |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
114 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
115 |
Args: |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
116 |
request: the standard Django HTTP request object |
500
44ea4620c5c0
Replace old page parameter doc string description with new one for page_name.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
499
diff
changeset
|
117 |
page_name: the page name displayed in templates as page and header title |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
118 |
kwargs: not used |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
119 |
""" |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
120 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
121 |
keys = self._logic.getKeyFieldNames() |
537
f2bd9c465a6d
Fix getKeyValues() method footprint mismatches in soc.logic.models.site.Logic
Todd Larsen <tlarsen@google.com>
parents:
536
diff
changeset
|
122 |
|
f2bd9c465a6d
Fix getKeyValues() method footprint mismatches in soc.logic.models.site.Logic
Todd Larsen <tlarsen@google.com>
parents:
536
diff
changeset
|
123 |
# No entity in this case, since Site key values are hard-coded for the |
f2bd9c465a6d
Fix getKeyValues() method footprint mismatches in soc.logic.models.site.Logic
Todd Larsen <tlarsen@google.com>
parents:
536
diff
changeset
|
124 |
# Site singleton, so pass in None to match parent method footprint. |
f2bd9c465a6d
Fix getKeyValues() method footprint mismatches in soc.logic.models.site.Logic
Todd Larsen <tlarsen@google.com>
parents:
536
diff
changeset
|
125 |
values = self._logic.getKeyValues(None) |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
126 |
key_values = dicts.zip(keys, values) |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
127 |
|
482
839740b061ad
Factor out direct use of the page object
Sverre Rabbelier <srabbelier@gmail.com>
parents:
477
diff
changeset
|
128 |
return self.public(request, page_name, **key_values) |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
129 |
|
482
839740b061ad
Factor out direct use of the page object
Sverre Rabbelier <srabbelier@gmail.com>
parents:
477
diff
changeset
|
130 |
def main_edit(self, request, page_name=None, **kwargs): |
499
d22e4fe8e64b
Fix missing dots in doc strings and some other doc string corrections.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
494
diff
changeset
|
131 |
"""Displays the edit page for the main site settings page. |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
132 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
133 |
Args: |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
134 |
request: the standard Django HTTP request object |
500
44ea4620c5c0
Replace old page parameter doc string description with new one for page_name.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
499
diff
changeset
|
135 |
page_name: the page name displayed in templates as page and header title |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
136 |
kwargs: not used |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
137 |
""" |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
138 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
139 |
keys = self._logic.getKeyFieldNames() |
537
f2bd9c465a6d
Fix getKeyValues() method footprint mismatches in soc.logic.models.site.Logic
Todd Larsen <tlarsen@google.com>
parents:
536
diff
changeset
|
140 |
|
f2bd9c465a6d
Fix getKeyValues() method footprint mismatches in soc.logic.models.site.Logic
Todd Larsen <tlarsen@google.com>
parents:
536
diff
changeset
|
141 |
# No entity in this case, since Site key values are hard-coded for the |
f2bd9c465a6d
Fix getKeyValues() method footprint mismatches in soc.logic.models.site.Logic
Todd Larsen <tlarsen@google.com>
parents:
536
diff
changeset
|
142 |
# Site singleton, so pass in None to match parent method footprint. |
f2bd9c465a6d
Fix getKeyValues() method footprint mismatches in soc.logic.models.site.Logic
Todd Larsen <tlarsen@google.com>
parents:
536
diff
changeset
|
143 |
values = self._logic.getKeyValues(None) |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
144 |
key_values = dicts.zip(keys, values) |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
145 |
|
490
7cfa2ad62944
Allow pre-seeding a create form
Sverre Rabbelier <srabbelier@gmail.com>
parents:
482
diff
changeset
|
146 |
return self.edit(request, page_name, seed=key_values, **key_values) |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
147 |
|
494
5e9c656a1b68
Refactored SiteMap to be generic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
493
diff
changeset
|
148 |
def getDjangoURLPatterns(self): |
499
d22e4fe8e64b
Fix missing dots in doc strings and some other doc string corrections.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
494
diff
changeset
|
149 |
"""See base.View.getDjangoURLPatterns(). |
494
5e9c656a1b68
Refactored SiteMap to be generic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
493
diff
changeset
|
150 |
""" |
5e9c656a1b68
Refactored SiteMap to be generic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
493
diff
changeset
|
151 |
|
5e9c656a1b68
Refactored SiteMap to be generic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
493
diff
changeset
|
152 |
patterns = super(View, self).getDjangoURLPatterns() |
534
c31cfbf1a20f
Replace HomeSettings with Presence Model class. Replace SiteSettings with
Todd Larsen <tlarsen@google.com>
parents:
513
diff
changeset
|
153 |
patterns += [(r'^$','soc.views.models.site.main_public')] |
536
6f267b8ad28b
Add a page name for 'Edit Main Site Settings'
Sverre Rabbelier <srabbelier@gmail.com>
parents:
535
diff
changeset
|
154 |
|
6f267b8ad28b
Add a page name for 'Edit Main Site Settings'
Sverre Rabbelier <srabbelier@gmail.com>
parents:
535
diff
changeset
|
155 |
page_name = "Edit Site Settings" |
534
c31cfbf1a20f
Replace HomeSettings with Presence Model class. Replace SiteSettings with
Todd Larsen <tlarsen@google.com>
parents:
513
diff
changeset
|
156 |
patterns += [(r'^' + self._params['url_name'] + '/edit$', |
536
6f267b8ad28b
Add a page name for 'Edit Main Site Settings'
Sverre Rabbelier <srabbelier@gmail.com>
parents:
535
diff
changeset
|
157 |
'soc.views.models.site.main_edit', |
6f267b8ad28b
Add a page name for 'Edit Main Site Settings'
Sverre Rabbelier <srabbelier@gmail.com>
parents:
535
diff
changeset
|
158 |
{'page_name': page_name}, page_name)] |
494
5e9c656a1b68
Refactored SiteMap to be generic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
493
diff
changeset
|
159 |
return patterns |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
160 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
161 |
view = View() |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
162 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
163 |
create = view.create |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
164 |
edit = view.edit |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
165 |
delete = view.delete |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
166 |
list = view.list |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
167 |
public = view.public |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
168 |
main_public = view.main_public |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
169 |
main_edit = view.main_edit |