author | Sverre Rabbelier <srabbelier@gmail.com> |
Thu, 12 Mar 2009 22:30:04 +0000 | |
changeset 1815 | 7a9b69f36111 |
parent 1789 | 6f112b2ebd1f |
child 1901 | 5a98e8a8efb5 |
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 |
# |
1308
35b75ffcbb37
Partially reverted "Update the copyright notice for 2009."
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1307
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
446
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 django import forms |
1240
a94c9bcfa05d
Always return a site singleton and fix Edit Site Settings
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1144
diff
changeset
|
26 |
from django.utils.translation import ugettext |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
27 |
|
1396
2238f2af7428
Clean the e-mail field
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1343
diff
changeset
|
28 |
from soc.logic import cleaning |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
29 |
from soc.logic import dicts |
1526
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
30 |
from soc.views import out_of_band |
551
2ee7ad5266a8
Define a default for rights['public'] in views/models/base.py. Alter rights
Todd Larsen <tlarsen@google.com>
parents:
544
diff
changeset
|
31 |
from soc.views.helper import access |
1583 | 32 |
from soc.views.helper import decorators |
1100
db177bcdfe29
Added a 'create new document' link to site
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1053
diff
changeset
|
33 |
from soc.views.helper import redirects |
1581
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
34 |
from soc.views.helper import responses |
1240
a94c9bcfa05d
Always return a site singleton and fix Edit Site Settings
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1144
diff
changeset
|
35 |
from soc.views.helper import widgets |
706
19f55eb5f194
Add site scoped documents to the Site menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
702
diff
changeset
|
36 |
from soc.views.models import document as document_view |
1053
3b9552cf748a
Rename the confusing Tossed Model class to PresenceWithToS.
Todd Larsen <tlarsen@google.com>
parents:
1051
diff
changeset
|
37 |
from soc.views.models import presence_with_tos |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
38 |
|
534
c31cfbf1a20f
Replace HomeSettings with Presence Model class. Replace SiteSettings with
Todd Larsen <tlarsen@google.com>
parents:
513
diff
changeset
|
39 |
import soc.models.site |
c31cfbf1a20f
Replace HomeSettings with Presence Model class. Replace SiteSettings with
Todd Larsen <tlarsen@google.com>
parents:
513
diff
changeset
|
40 |
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
|
41 |
import soc.logic.dicts |
1789
6f112b2ebd1f
Return a HttpResponse in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1635
diff
changeset
|
42 |
import soc.logic.system |
446
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 |
|
1053
3b9552cf748a
Rename the confusing Tossed Model class to PresenceWithToS.
Todd Larsen <tlarsen@google.com>
parents:
1051
diff
changeset
|
45 |
class View(presence_with_tos.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
|
46 |
"""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
|
47 |
""" |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
48 |
|
1581
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
49 |
DEF_DOWN_FOR_MAINTENANCE_MSG = ugettext("Down for maintenance") |
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
50 |
DEF_NOT_IN_MAINTENANCE_MSG = ugettext( |
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
51 |
"The site is currently not in maintenance mode.") |
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
52 |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
624
diff
changeset
|
53 |
def __init__(self, params=None): |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
54 |
"""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
|
55 |
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
|
56 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
57 |
Params: |
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
624
diff
changeset
|
58 |
params: a dict with params for this View |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
59 |
""" |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
60 |
|
1007
3b66772d21a5
Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
973
diff
changeset
|
61 |
rights = access.Checker(params) |
3b66772d21a5
Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
973
diff
changeset
|
62 |
rights['unspecified'] = ['checkIsDeveloper'] |
3b66772d21a5
Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
973
diff
changeset
|
63 |
rights['any_access'] = ['allow'] |
1109
a83d8c5e6650
Edited the access check for show in site settings.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1102
diff
changeset
|
64 |
rights['show'] = ['checkIsDeveloper'] |
708
89f1a8c2ea59
Some cleanups in role.py and site.py and create()
Sverre Rabbelier <srabbelier@gmail.com>
parents:
706
diff
changeset
|
65 |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
624
diff
changeset
|
66 |
new_params = {} |
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
624
diff
changeset
|
67 |
new_params['logic'] = soc.logic.models.site.logic |
708
89f1a8c2ea59
Some cleanups in role.py and site.py and create()
Sverre Rabbelier <srabbelier@gmail.com>
parents:
706
diff
changeset
|
68 |
new_params['rights'] = rights |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
69 |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
624
diff
changeset
|
70 |
new_params['name'] = "Site Settings" |
903
7110fc489fd0
Rename "site/settings" to "site"
Sverre Rabbelier <srabbelier@gmail.com>
parents:
901
diff
changeset
|
71 |
new_params['name_plural'] = new_params['name'] |
1303
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1247
diff
changeset
|
72 |
new_params['document_prefix'] = 'site' |
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
624
diff
changeset
|
73 |
new_params['name_short'] = "Site" |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
74 |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
624
diff
changeset
|
75 |
new_params['sidebar_defaults'] = [('/%s/edit', 'Edit %(name)s', 'edit')] |
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
624
diff
changeset
|
76 |
new_params['sidebar_heading'] = new_params['name_short'] |
542
7cc99461b64d
Remove redundant dicts for URL patterns and sidebar menu text, and use the
Todd Larsen <tlarsen@google.com>
parents:
537
diff
changeset
|
77 |
|
1049
cc6aedbde28d
Fixed the edit site view having a delete button
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1017
diff
changeset
|
78 |
new_params['edit_template'] = 'soc/site/edit.html' |
921
e499cc2641f6
Create a new 'home' view for Presences
Sverre Rabbelier <srabbelier@gmail.com>
parents:
904
diff
changeset
|
79 |
new_params['home_template'] = 'soc/site/home.html' |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
80 |
|
1430
ff8cc6b15e6a
Rename dynafields to dynaproperties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1396
diff
changeset
|
81 |
new_params['create_extra_dynaproperties'] = { |
904
a6397daf4006
Hide the 'link_id' field for site
Sverre Rabbelier <srabbelier@gmail.com>
parents:
903
diff
changeset
|
82 |
'link_id': forms.CharField(widget=forms.HiddenInput, required=True), |
1396
2238f2af7428
Clean the e-mail field
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1343
diff
changeset
|
83 |
'clean_noreply_email': cleaning.clean_empty_field('noreply_email'), |
904
a6397daf4006
Hide the 'link_id' field for site
Sverre Rabbelier <srabbelier@gmail.com>
parents:
903
diff
changeset
|
84 |
} |
1430
ff8cc6b15e6a
Rename dynafields to dynaproperties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1396
diff
changeset
|
85 |
new_params['edit_extra_dynaproperties'] = { |
1240
a94c9bcfa05d
Always return a site singleton and fix Edit Site Settings
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1144
diff
changeset
|
86 |
'link_id': forms.CharField(widget=forms.HiddenInput, required=True), |
a94c9bcfa05d
Always return a site singleton and fix Edit Site Settings
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1144
diff
changeset
|
87 |
'home_link_id': widgets.ReferenceField( |
1303
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1247
diff
changeset
|
88 |
reference_url='document', required=False, |
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1247
diff
changeset
|
89 |
filter_fields={'prefix': new_params['document_prefix']}, |
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1247
diff
changeset
|
90 |
label=ugettext('Home page Document link ID'), |
1240
a94c9bcfa05d
Always return a site singleton and fix Edit Site Settings
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1144
diff
changeset
|
91 |
help_text=soc.models.work.Work.link_id.help_text), |
a94c9bcfa05d
Always return a site singleton and fix Edit Site Settings
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1144
diff
changeset
|
92 |
'tos_link_id': widgets.ReferenceField( |
1303
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1247
diff
changeset
|
93 |
reference_url='document', required=False, |
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1247
diff
changeset
|
94 |
filter_fields={'prefix': new_params['document_prefix']}, |
08433090cff8
Add prefix filtering and refactored program field generation
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1247
diff
changeset
|
95 |
label=ugettext('Terms of Service Document link ID'), |
1240
a94c9bcfa05d
Always return a site singleton and fix Edit Site Settings
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1144
diff
changeset
|
96 |
help_text=soc.models.work.Work.link_id.help_text), |
a94c9bcfa05d
Always return a site singleton and fix Edit Site Settings
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1144
diff
changeset
|
97 |
} |
904
a6397daf4006
Hide the 'link_id' field for site
Sverre Rabbelier <srabbelier@gmail.com>
parents:
903
diff
changeset
|
98 |
|
660
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
656
diff
changeset
|
99 |
patterns = [] |
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
656
diff
changeset
|
100 |
|
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
656
diff
changeset
|
101 |
page_name = "Home Page" |
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
656
diff
changeset
|
102 |
patterns += [(r'^$', 'soc.views.models.%(module_name)s.main_public', |
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
656
diff
changeset
|
103 |
page_name)] |
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
656
diff
changeset
|
104 |
|
1581
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
105 |
page_name = "Maintenance" |
1635
b7e2d494aa11
Remove unused imports and fix too long lines in soc.views.models.site module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1584
diff
changeset
|
106 |
patterns += [(r'^maintenance$', |
b7e2d494aa11
Remove unused imports and fix too long lines in soc.views.models.site module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1584
diff
changeset
|
107 |
'soc.views.models.%(module_name)s.maintenance', page_name)] |
1581
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
108 |
|
702
e3b91b6955ff
Remove bogus scope from Site
Sverre Rabbelier <srabbelier@gmail.com>
parents:
660
diff
changeset
|
109 |
page_name = "Edit Site" |
710
edb5dbb1dea7
Add explicit access_types from the url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
708
diff
changeset
|
110 |
patterns += [(r'^%(url_name)s/(?P<access_type>edit)$', |
660
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
656
diff
changeset
|
111 |
'soc.views.models.%(module_name)s.main_edit', |
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
656
diff
changeset
|
112 |
page_name)] |
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
656
diff
changeset
|
113 |
|
1789
6f112b2ebd1f
Return a HttpResponse in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1635
diff
changeset
|
114 |
if soc.logic.system.isDebug(): |
6f112b2ebd1f
Return a HttpResponse in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1635
diff
changeset
|
115 |
patterns += [('^seed_db$', 'soc.models.seed_db.seed', "Seed DB"), |
6f112b2ebd1f
Return a HttpResponse in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1635
diff
changeset
|
116 |
('^clear_db$', 'soc.models.seed_db.clear', "Clear DB"), |
6f112b2ebd1f
Return a HttpResponse in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1635
diff
changeset
|
117 |
('^reseed_db$', 'soc.models.seed_db.reseed', "Reseed DB")] |
6f112b2ebd1f
Return a HttpResponse in seed_db
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1635
diff
changeset
|
118 |
|
660
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
656
diff
changeset
|
119 |
new_params['extra_django_patterns'] = patterns |
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
656
diff
changeset
|
120 |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
624
diff
changeset
|
121 |
params = dicts.merge(params, new_params) |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
122 |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
624
diff
changeset
|
123 |
super(View, self).__init__(params=params) |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
124 |
|
1017
6ad4fdb48840
Cache access checks and disable sidebar caching
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1007
diff
changeset
|
125 |
def getSidebarMenus(self, id, user, params=None): |
706
19f55eb5f194
Add site scoped documents to the Site menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
702
diff
changeset
|
126 |
"""See base.View.getSidebarMenus. |
19f55eb5f194
Add site scoped documents to the Site menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
702
diff
changeset
|
127 |
|
19f55eb5f194
Add site scoped documents to the Site menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
702
diff
changeset
|
128 |
Returns a custom sidebar entry for the 'site' singleton. |
19f55eb5f194
Add site scoped documents to the Site menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
702
diff
changeset
|
129 |
""" |
19f55eb5f194
Add site scoped documents to the Site menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
702
diff
changeset
|
130 |
|
1017
6ad4fdb48840
Cache access checks and disable sidebar caching
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1007
diff
changeset
|
131 |
entity = self._logic.getSingleton() |
706
19f55eb5f194
Add site scoped documents to the Site menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
702
diff
changeset
|
132 |
|
19f55eb5f194
Add site scoped documents to the Site menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
702
diff
changeset
|
133 |
submenus = [] |
19f55eb5f194
Add site scoped documents to the Site menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
702
diff
changeset
|
134 |
|
19f55eb5f194
Add site scoped documents to the Site menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
702
diff
changeset
|
135 |
if entity: |
1100
db177bcdfe29
Added a 'create new document' link to site
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1053
diff
changeset
|
136 |
submenus += document_view.view.getMenusForScope(entity, self._params) |
1526
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
137 |
|
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
138 |
try: |
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
139 |
rights = self._params['rights'] |
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
140 |
rights.setCurrentUser(id, user) |
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
141 |
rights.checkIsHost() |
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
142 |
is_host = True |
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
143 |
except out_of_band.Error: |
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
144 |
is_host = False |
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
145 |
|
5c31184594a5
Convert everything to use the new access methods
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
146 |
if is_host: |
1102
8765079db045
Brown paper bag fix
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1100
diff
changeset
|
147 |
submenus += [(redirects.getCreateDocumentRedirect(entity, 'site'), |
1144
f89bbc9b20a6
Rename 'Create a new document' links to 'Create a New Document', also rename 'Create a new Program' to 'Create a New Program' in soc.views.models modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1115
diff
changeset
|
148 |
"Create a New Document", 'any_access')] |
706
19f55eb5f194
Add site scoped documents to the Site menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
702
diff
changeset
|
149 |
|
1317
fad74cf4e5da
Add a 'list documents' link everywhere
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
150 |
submenus += [(redirects.getListDocumentsRedirect(entity, 'site'), |
fad74cf4e5da
Add a 'list documents' link everywhere
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
151 |
"List Documents", 'any_access')] |
fad74cf4e5da
Add a 'list documents' link everywhere
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
152 |
|
706
19f55eb5f194
Add site scoped documents to the Site menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
702
diff
changeset
|
153 |
new_params = {} |
19f55eb5f194
Add site scoped documents to the Site menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
702
diff
changeset
|
154 |
new_params['sidebar_additional'] = submenus |
19f55eb5f194
Add site scoped documents to the Site menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
702
diff
changeset
|
155 |
|
19f55eb5f194
Add site scoped documents to the Site menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
702
diff
changeset
|
156 |
params = dicts.merge(params, new_params) |
1017
6ad4fdb48840
Cache access checks and disable sidebar caching
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1007
diff
changeset
|
157 |
return super(View, self).getSidebarMenus(id, user, params=params) |
706
19f55eb5f194
Add site scoped documents to the Site menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
702
diff
changeset
|
158 |
|
1581
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
159 |
def maintenance(self, request, page_name): |
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
160 |
"""Returns a 'down for maintenance' view. |
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
161 |
""" |
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
162 |
|
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
163 |
context = responses.getUniversalContext(request) |
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
164 |
context['page_name'] = page_name |
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
165 |
|
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
166 |
notice = context.pop('site_notice') |
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
167 |
|
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
168 |
if not notice: |
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
169 |
context['body_content'] = self.DEF_NOT_IN_MAINTENANCE_MSG |
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
170 |
else: |
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
171 |
context['body_content'] = notice |
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
172 |
context['header_title'] = self.DEF_DOWN_FOR_MAINTENANCE_MSG |
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
173 |
context['sidebar_menu_items'] = [ |
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
174 |
{'heading': self.DEF_DOWN_FOR_MAINTENANCE_MSG, |
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
175 |
'group': ''}, |
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
176 |
] |
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
177 |
|
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
178 |
template = 'soc/base.html' |
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
179 |
|
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
180 |
return responses.respond(request, template, context=context) |
4484186d7427
Added a maintenance page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1526
diff
changeset
|
181 |
|
559
44e50e92621e
Fix names of methods in soc.views.model.site.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
554
diff
changeset
|
182 |
def mainPublic(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
|
183 |
"""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
|
184 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
185 |
Args: |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
186 |
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
|
187 |
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
|
188 |
kwargs: not used |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
189 |
""" |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
190 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
191 |
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
|
192 |
|
f2bd9c465a6d
Fix getKeyValues() method footprint mismatches in soc.logic.models.site.Logic
Todd Larsen <tlarsen@google.com>
parents:
536
diff
changeset
|
193 |
# 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
|
194 |
# Site singleton, so pass in None to match parent method footprint. |
1115
0a723ff3d27c
Cleanups in base.Logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1109
diff
changeset
|
195 |
values = self._logic.getKeyValuesFromEntity(None) |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
196 |
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
|
197 |
|
921
e499cc2641f6
Create a new 'home' view for Presences
Sverre Rabbelier <srabbelier@gmail.com>
parents:
904
diff
changeset
|
198 |
return self.home(request, "home", page_name=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
|
199 |
|
559
44e50e92621e
Fix names of methods in soc.views.model.site.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
554
diff
changeset
|
200 |
def mainEdit(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
|
201 |
"""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
|
202 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
203 |
Args: |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
204 |
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
|
205 |
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
|
206 |
kwargs: not used |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
207 |
""" |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
208 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
209 |
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
|
210 |
|
f2bd9c465a6d
Fix getKeyValues() method footprint mismatches in soc.logic.models.site.Logic
Todd Larsen <tlarsen@google.com>
parents:
536
diff
changeset
|
211 |
# 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
|
212 |
# Site singleton, so pass in None to match parent method footprint. |
1115
0a723ff3d27c
Cleanups in base.Logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1109
diff
changeset
|
213 |
values = self._logic.getKeyValuesFromEntity(None) |
446
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
214 |
key_values = dicts.zip(keys, values) |
921
e499cc2641f6
Create a new 'home' view for Presences
Sverre Rabbelier <srabbelier@gmail.com>
parents:
904
diff
changeset
|
215 |
|
717
f3f43ba566ef
Fixed missing header in site settings.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
710
diff
changeset
|
216 |
return self.edit(request, "edit", 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
|
217 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
218 |
|
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
219 |
view = View() |
0b479d573a4c
Refactoring of {site/home}_settings to make them use base.View
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
220 |
|
1584
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
221 |
admin = decorators.view(view.admin) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
222 |
create = decorators.view(view.create) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
223 |
edit = decorators.view(view.edit) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
224 |
delete = decorators.view(view.delete) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
225 |
list = decorators.view(view.list) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
226 |
public = decorators.view(view.public) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
227 |
export = decorators.view(view.export) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
228 |
main_public = decorators.view(view.mainPublic) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
229 |
main_edit = decorators.view(view.mainEdit) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
230 |
maintenance = decorators.view(view.maintenance) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
231 |
home = decorators.view(view.home) |