author | Lennard de Rijk <ljvderijk@gmail.com> |
Sat, 07 Feb 2009 21:43:27 +0000 | |
changeset 1244 | 20494064bc3f |
parent 1227 | 38afecddfbed |
child 1267 | 157c12589f79 |
permissions | -rw-r--r-- |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
2 |
# |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
4 |
# |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
8 |
# |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
10 |
# |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
16 |
|
639
1f92bd41b914
Some docstring fixes in few modules (soc.views.helper soc.views.models.base).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
616
diff
changeset
|
17 |
"""Params related methods. |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
18 |
""" |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
19 |
|
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
21 |
'"Sverre Rabbelier" <sverre@rabbelier.nl>', |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
22 |
] |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
23 |
|
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
24 |
|
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
25 |
from django import forms |
970
8b5611d5b053
Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents:
934
diff
changeset
|
26 |
from django.utils.translation import ugettext |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
27 |
|
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
28 |
from soc.logic import cleaning |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
29 |
from soc.logic import dicts |
613
4880ffa9f3ba
Moved getDjangoURLPatterns to sitemap.sitemap
Sverre Rabbelier <srabbelier@gmail.com>
parents:
611
diff
changeset
|
30 |
from soc.models import linkable |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
31 |
from soc.views import helper |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
32 |
from soc.views.helper import access |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
33 |
from soc.views.helper import dynaform |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
34 |
from soc.views.helper import redirects |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
35 |
|
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
36 |
|
970
8b5611d5b053
Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents:
934
diff
changeset
|
37 |
DEF_LIST_DESCRIPTION_FMT = ugettext( |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
38 |
'List of %(name_plural)s in Google Open Source Programs.') |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
39 |
|
970
8b5611d5b053
Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents:
934
diff
changeset
|
40 |
DEF_CREATE_INSTRUCTION_MSG_FMT = ugettext( |
652
02323664d532
Cleanups in preparation of general selector view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
642
diff
changeset
|
41 |
'Please use this form to select a %(name).') |
02323664d532
Cleanups in preparation of general selector view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
642
diff
changeset
|
42 |
|
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
43 |
DEF_SUBMIT_MSG_PARAM_NAME = 's' |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
44 |
DEF_SUBMIT_MSG_PROFILE_SAVED = 0 |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
45 |
|
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
46 |
|
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
47 |
def constructParams(params): |
689
46db8c4bbffc
Add missing dots in docstrings in modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
680
diff
changeset
|
48 |
"""Constructs a new params dictionary based on params. |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
49 |
|
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
50 |
Params usage: |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
51 |
The params dictionary is passed to getCreateForm and getEditForm, |
639
1f92bd41b914
Some docstring fixes in few modules (soc.views.helper soc.views.models.base).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
616
diff
changeset
|
52 |
see their docstring on how they use it. |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
53 |
|
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
54 |
rights: The rights value is merged with a default rights |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
55 |
dictionary and then used as rights value. |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
56 |
url_name: The url_name value is used in constructing several |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
57 |
redirects as the first part of the url. |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
58 |
module_name: The module_name value is used in constructing the |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
59 |
location of several templates. It is expected that it matches |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
60 |
the part after "/templates/soc/" for this View. |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
61 |
name_plural: The name_plural argument is provided to the |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
62 |
LIST_DESCRIPTION when constructing the list_description field. |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
63 |
extra_dynainclude: The extra_dynainclude value is used when |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
64 |
constructing the create_dynainclude value. |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
65 |
extra_dynaexclude: The extra_dynaexclude value is used when |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
66 |
constructing the create_dynaexclude value. |
867
f4ea0da41915
Edited the method used to clean link_id in params.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
859
diff
changeset
|
67 |
logic: The logic value is used as argument to save the scope_logic |
f4ea0da41915
Edited the method used to clean link_id in params.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
859
diff
changeset
|
68 |
and create a create form. |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
69 |
""" |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
70 |
|
778
bc13cd968946
Added support for mutliple edit forms based on entity type
Sverre Rabbelier <srabbelier@gmail.com>
parents:
761
diff
changeset
|
71 |
logic = params['logic'] |
bc13cd968946
Added support for mutliple edit forms based on entity type
Sverre Rabbelier <srabbelier@gmail.com>
parents:
761
diff
changeset
|
72 |
|
1007
3b66772d21a5
Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
73 |
rights = access.Checker(params) |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
74 |
rights['unspecified'] = [] |
1007
3b66772d21a5
Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
75 |
rights['any_access'] = ['checkIsLoggedIn'] |
1012
73f0b61f2d9d
Fold checkAgreesToSiteToS into checkIsUser
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1007
diff
changeset
|
76 |
rights['show'] = ['checkIsUser'] |
1007
3b66772d21a5
Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
77 |
rights['create'] = ['checkIsDeveloper'] |
3b66772d21a5
Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
78 |
rights['edit'] = ['checkIsDeveloper'] |
3b66772d21a5
Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
79 |
rights['delete'] = ['checkIsDeveloper'] |
3b66772d21a5
Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
80 |
rights['list'] = ['checkIsDeveloper'] |
1227
38afecddfbed
Make picker work generically
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1101
diff
changeset
|
81 |
rights['pick'] = ['checkIsUser'] # TODO(SRabbelier): proper check |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
82 |
|
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
83 |
new_params = {} |
778
bc13cd968946
Added support for mutliple edit forms based on entity type
Sverre Rabbelier <srabbelier@gmail.com>
parents:
761
diff
changeset
|
84 |
new_params['scope_logic'] = logic.getScopeLogic() |
671
2c02178037ff
Apply DI on the scope logic
Sverre Rabbelier <srabbelier@gmail.com>
parents:
668
diff
changeset
|
85 |
|
799
30a912906a57
Construct names automatically from base name.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
778
diff
changeset
|
86 |
if 'name_short' not in params: |
30a912906a57
Construct names automatically from base name.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
778
diff
changeset
|
87 |
params['name_short'] = params['name'] |
30a912906a57
Construct names automatically from base name.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
778
diff
changeset
|
88 |
|
30a912906a57
Construct names automatically from base name.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
778
diff
changeset
|
89 |
if 'name_plural' not in params: |
30a912906a57
Construct names automatically from base name.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
778
diff
changeset
|
90 |
params['name_plural'] = params['name'] + 's' |
30a912906a57
Construct names automatically from base name.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
778
diff
changeset
|
91 |
|
30a912906a57
Construct names automatically from base name.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
778
diff
changeset
|
92 |
if 'module_name' not in params: |
30a912906a57
Construct names automatically from base name.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
778
diff
changeset
|
93 |
params['module_name'] = params['name_short'].replace(' ', '_').lower() |
30a912906a57
Construct names automatically from base name.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
778
diff
changeset
|
94 |
|
30a912906a57
Construct names automatically from base name.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
778
diff
changeset
|
95 |
if 'url_name' not in params: |
30a912906a57
Construct names automatically from base name.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
778
diff
changeset
|
96 |
params['url_name'] = params['module_name'] |
30a912906a57
Construct names automatically from base name.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
778
diff
changeset
|
97 |
|
1101
6c0f9b73b053
Made presence document retrievel specify prefix
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1094
diff
changeset
|
98 |
if 'document_prefix' not in params: |
6c0f9b73b053
Made presence document retrievel specify prefix
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1094
diff
changeset
|
99 |
params['document_prefix'] = params['name_short'].lower() |
6c0f9b73b053
Made presence document retrievel specify prefix
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1094
diff
changeset
|
100 |
|
735
28225172af06
Make it possible to redirect anywhere after editPost
Sverre Rabbelier <srabbelier@gmail.com>
parents:
710
diff
changeset
|
101 |
# Do not expand edit_redirect to allow it to be overriden without suffix |
28225172af06
Make it possible to redirect anywhere after editPost
Sverre Rabbelier <srabbelier@gmail.com>
parents:
710
diff
changeset
|
102 |
new_params['edit_redirect'] = '/%(url_name)s/edit/%(suffix)s' |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
103 |
new_params['missing_redirect'] = '/%(url_name)s/create' % params |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
104 |
new_params['delete_redirect'] = '/%(url_name)s/list' % params |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
105 |
new_params['invite_redirect'] = '/request/list' |
1035
04229d710ce9
Allow for setting a edit_cancel_redirect
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1024
diff
changeset
|
106 |
new_params['edit_cancel_redirect'] = '/%(url_name)s/list' % params |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
107 |
|
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
108 |
new_params['sidebar'] = None |
1024
2a0ae6483825
Group dynamically generated menu items
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1012
diff
changeset
|
109 |
new_params['sidebar_grouping'] = 'main' |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
110 |
new_params['sidebar_defaults'] = [ |
642
671dc971c3d1
Allow for extra dynamic fields for the create form
Sverre Rabbelier <srabbelier@gmail.com>
parents:
639
diff
changeset
|
111 |
('/%s/create', 'New %(name)s', 'create'), |
671dc971c3d1
Allow for extra dynamic fields for the create form
Sverre Rabbelier <srabbelier@gmail.com>
parents:
639
diff
changeset
|
112 |
('/%s/list', 'List %(name_plural)s', 'list'), |
671dc971c3d1
Allow for extra dynamic fields for the create form
Sverre Rabbelier <srabbelier@gmail.com>
parents:
639
diff
changeset
|
113 |
] |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
114 |
new_params['sidebar_additional'] = [] |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
115 |
|
616
580b1c21b808
Fixed requests not working anymore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
613
diff
changeset
|
116 |
new_params['link_id_arg_pattern'] = linkable.LINK_ID_ARG_PATTERN |
580b1c21b808
Fixed requests not working anymore
Sverre Rabbelier <srabbelier@gmail.com>
parents:
613
diff
changeset
|
117 |
new_params['link_id_pattern_core'] = linkable.LINK_ID_PATTERN_CORE |
680
7f047b2a2d3a
Added a new create regexp in urls for just scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
679
diff
changeset
|
118 |
new_params['scope_path_pattern'] = getScopePattern(params) |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
119 |
|
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
120 |
new_params['django_patterns'] = None |
660
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
652
diff
changeset
|
121 |
new_params['extra_django_patterns'] = [] |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
122 |
new_params['django_patterns_defaults'] = [ |
710
edb5dbb1dea7
Add explicit access_types from the url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
689
diff
changeset
|
123 |
(r'^%(url_name)s/(?P<access_type>show)/%(key_fields)s$', |
660
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
652
diff
changeset
|
124 |
'soc.views.models.%(module_name)s.public', 'Show %(name_short)s'), |
858
e79e7a22326f
Add an export() view, and implement it as text/text for Document.
Todd Larsen <tlarsen@google.com>
parents:
837
diff
changeset
|
125 |
(r'^%(url_name)s/(?P<access_type>export)/%(key_fields)s$', |
859
b93fad44b70a
Change "Show" to "Export" missed in r1446 commit.
Todd Larsen <tlarsen@google.com>
parents:
858
diff
changeset
|
126 |
'soc.views.models.%(module_name)s.export', 'Export %(name_short)s'), |
710
edb5dbb1dea7
Add explicit access_types from the url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
689
diff
changeset
|
127 |
(r'^%(url_name)s/(?P<access_type>create)$', |
660
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
652
diff
changeset
|
128 |
'soc.views.models.%(module_name)s.create', 'Create %(name_short)s'), |
710
edb5dbb1dea7
Add explicit access_types from the url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
689
diff
changeset
|
129 |
(r'^%(url_name)s/(?P<access_type>delete)/%(key_fields)s$', |
660
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
652
diff
changeset
|
130 |
'soc.views.models.%(module_name)s.delete', 'Delete %(name_short)s'), |
710
edb5dbb1dea7
Add explicit access_types from the url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
689
diff
changeset
|
131 |
(r'^%(url_name)s/(?P<access_type>edit)/%(key_fields)s$', |
660
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
652
diff
changeset
|
132 |
'soc.views.models.%(module_name)s.edit', 'Edit %(name_short)s'), |
710
edb5dbb1dea7
Add explicit access_types from the url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
689
diff
changeset
|
133 |
(r'^%(url_name)s/(?P<access_type>list)$', |
660
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
652
diff
changeset
|
134 |
'soc.views.models.%(module_name)s.list', 'List %(name_plural)s'), |
934
9fcc08971efe
Add a 'pick' view to the appropriate views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
890
diff
changeset
|
135 |
(r'^%(url_name)s/(?P<access_type>pick)$', |
9fcc08971efe
Add a 'pick' view to the appropriate views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
890
diff
changeset
|
136 |
'soc.views.models.%(module_name)s.pick', 'Pick %(name_short)s'), |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
137 |
] |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
138 |
|
1093
05ac761edb27
Made the /create/<scope> url conditional
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1092
diff
changeset
|
139 |
if not params.get('no_create_with_scope'): |
05ac761edb27
Made the /create/<scope> url conditional
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1092
diff
changeset
|
140 |
new_params['django_patterns_defaults'] += [ |
05ac761edb27
Made the /create/<scope> url conditional
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1092
diff
changeset
|
141 |
(r'^%(url_name)s/(?P<access_type>create)/%(scope)s$', |
05ac761edb27
Made the /create/<scope> url conditional
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1092
diff
changeset
|
142 |
'soc.views.models.%(module_name)s.create', 'Create %(name_short)s')] |
05ac761edb27
Made the /create/<scope> url conditional
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1092
diff
changeset
|
143 |
|
761
da4d499a9598
Allow disabling of the create url with key_fields
Sverre Rabbelier <srabbelier@gmail.com>
parents:
735
diff
changeset
|
144 |
if not params.get('no_create_with_key_fields'): |
da4d499a9598
Allow disabling of the create url with key_fields
Sverre Rabbelier <srabbelier@gmail.com>
parents:
735
diff
changeset
|
145 |
new_params['django_patterns_defaults'] += [ |
da4d499a9598
Allow disabling of the create url with key_fields
Sverre Rabbelier <srabbelier@gmail.com>
parents:
735
diff
changeset
|
146 |
(r'^%(url_name)s/(?P<access_type>create)/%(key_fields)s$', |
da4d499a9598
Allow disabling of the create url with key_fields
Sverre Rabbelier <srabbelier@gmail.com>
parents:
735
diff
changeset
|
147 |
'soc.views.models.%(module_name)s.create', 'Create %(name_short)s')] |
da4d499a9598
Allow disabling of the create url with key_fields
Sverre Rabbelier <srabbelier@gmail.com>
parents:
735
diff
changeset
|
148 |
|
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
149 |
new_params['public_template'] = 'soc/%(module_name)s/public.html' % params |
858
e79e7a22326f
Add an export() view, and implement it as text/text for Document.
Todd Larsen <tlarsen@google.com>
parents:
837
diff
changeset
|
150 |
new_params['export_template'] = 'soc/%(module_name)s/export.html' % params |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
151 |
new_params['create_template'] = 'soc/models/edit.html' |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
152 |
new_params['edit_template'] = 'soc/models/edit.html' |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
153 |
new_params['list_template'] = 'soc/models/list.html' |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
154 |
new_params['invite_template'] = 'soc/models/invite.html' |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
155 |
|
858
e79e7a22326f
Add an export() view, and implement it as text/text for Document.
Todd Larsen <tlarsen@google.com>
parents:
837
diff
changeset
|
156 |
new_params['export_content_type'] = None |
e79e7a22326f
Add an export() view, and implement it as text/text for Document.
Todd Larsen <tlarsen@google.com>
parents:
837
diff
changeset
|
157 |
|
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
158 |
new_params['error_public'] = 'soc/%(module_name)s/error.html' % params |
858
e79e7a22326f
Add an export() view, and implement it as text/text for Document.
Todd Larsen <tlarsen@google.com>
parents:
837
diff
changeset
|
159 |
new_params['error_export'] = new_params['error_public'] |
e79e7a22326f
Add an export() view, and implement it as text/text for Document.
Todd Larsen <tlarsen@google.com>
parents:
837
diff
changeset
|
160 |
new_params['error_edit'] = new_params['error_public'] |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
161 |
|
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
162 |
new_params['list_main'] = 'soc/list/main.html' |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
163 |
new_params['list_pagination'] = 'soc/list/pagination.html' |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
164 |
new_params['list_row'] = 'soc/%(module_name)s/list/row.html' % params |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
165 |
new_params['list_heading'] = 'soc/%(module_name)s/list/heading.html' % params |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
166 |
|
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
167 |
new_params['list_action'] = (redirects.getEditRedirect, params) |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
168 |
new_params['list_params'] = { |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
169 |
'list_action': 'action', |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
170 |
'list_description': 'description', |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
171 |
'list_main': 'main', |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
172 |
'list_pagination': 'pagination', |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
173 |
'list_row': 'row', |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
174 |
'list_heading': 'heading', |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
175 |
} |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
176 |
|
652
02323664d532
Cleanups in preparation of general selector view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
642
diff
changeset
|
177 |
new_params['list_description'] = DEF_LIST_DESCRIPTION_FMT % params |
1087
c6a7f5957b30
Fix the notification bar messages that show up when you click 'Save Changes' button. It only works on Edit views right now.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1079
diff
changeset
|
178 |
new_params['save_message'] = [ugettext('%(name)s saved.' % params)] |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
179 |
new_params['submit_msg_param_name'] = DEF_SUBMIT_MSG_PARAM_NAME |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
180 |
new_params['edit_params'] = { |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
181 |
DEF_SUBMIT_MSG_PARAM_NAME: DEF_SUBMIT_MSG_PROFILE_SAVED, |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
182 |
} |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
183 |
|
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
184 |
new_params['dynabase'] = helper.forms.BaseForm |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
185 |
|
642
671dc971c3d1
Allow for extra dynamic fields for the create form
Sverre Rabbelier <srabbelier@gmail.com>
parents:
639
diff
changeset
|
186 |
create_dynafields = { |
1079
be1aacb33b0f
Changed clean_link_id to be in a wrapper form as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1035
diff
changeset
|
187 |
'clean_link_id': cleaning.clean_link_id('link_id'), |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
188 |
'clean_feed_url': cleaning.clean_feed_url, |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
189 |
} |
642
671dc971c3d1
Allow for extra dynamic fields for the create form
Sverre Rabbelier <srabbelier@gmail.com>
parents:
639
diff
changeset
|
190 |
create_dynafields.update(params.get('create_extra_dynafields', {})) |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
191 |
|
642
671dc971c3d1
Allow for extra dynamic fields for the create form
Sverre Rabbelier <srabbelier@gmail.com>
parents:
639
diff
changeset
|
192 |
new_params['create_dynainclude'] = [] + params.get('extra_dynainclude', []) |
671dc971c3d1
Allow for extra dynamic fields for the create form
Sverre Rabbelier <srabbelier@gmail.com>
parents:
639
diff
changeset
|
193 |
new_params['create_dynaexclude'] = ['scope', 'scope_path'] + \ |
671dc971c3d1
Allow for extra dynamic fields for the create form
Sverre Rabbelier <srabbelier@gmail.com>
parents:
639
diff
changeset
|
194 |
params.get('extra_dynaexclude', []) |
671dc971c3d1
Allow for extra dynamic fields for the create form
Sverre Rabbelier <srabbelier@gmail.com>
parents:
639
diff
changeset
|
195 |
new_params['create_dynafields'] = create_dynafields |
671dc971c3d1
Allow for extra dynamic fields for the create form
Sverre Rabbelier <srabbelier@gmail.com>
parents:
639
diff
changeset
|
196 |
|
671dc971c3d1
Allow for extra dynamic fields for the create form
Sverre Rabbelier <srabbelier@gmail.com>
parents:
639
diff
changeset
|
197 |
edit_dynafields = { |
1079
be1aacb33b0f
Changed clean_link_id to be in a wrapper form as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1035
diff
changeset
|
198 |
'clean_link_id': cleaning.clean_link_id('link_id'), |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
199 |
'link_id': forms.CharField(widget=helper.widgets.ReadOnlyInput()), |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
200 |
} |
642
671dc971c3d1
Allow for extra dynamic fields for the create form
Sverre Rabbelier <srabbelier@gmail.com>
parents:
639
diff
changeset
|
201 |
edit_dynafields.update(params.get('edit_extra_dynafields', {})) |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
202 |
|
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
203 |
new_params['edit_dynainclude'] = None |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
204 |
new_params['edit_dynaexclude'] = None |
642
671dc971c3d1
Allow for extra dynamic fields for the create form
Sverre Rabbelier <srabbelier@gmail.com>
parents:
639
diff
changeset
|
205 |
new_params['edit_dynafields'] = edit_dynafields |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
206 |
|
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
207 |
params = dicts.merge(params, new_params) |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
208 |
|
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
209 |
# These need to be constructed separately, because they require |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
210 |
# parameters that can be defined either in params, or new_params. |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
211 |
if not 'create_form' in params: |
778
bc13cd968946
Added support for mutliple edit forms based on entity type
Sverre Rabbelier <srabbelier@gmail.com>
parents:
761
diff
changeset
|
212 |
params['create_form'] = getCreateForm(params, logic.getModel()) |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
213 |
|
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
214 |
if not 'edit_form' in params: |
778
bc13cd968946
Added support for mutliple edit forms based on entity type
Sverre Rabbelier <srabbelier@gmail.com>
parents:
761
diff
changeset
|
215 |
params['edit_form'] = getEditForm(params, params['create_form']) |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
216 |
|
613
4880ffa9f3ba
Moved getDjangoURLPatterns to sitemap.sitemap
Sverre Rabbelier <srabbelier@gmail.com>
parents:
611
diff
changeset
|
217 |
if not 'key_fields_pattern' in params: |
4880ffa9f3ba
Moved getDjangoURLPatterns to sitemap.sitemap
Sverre Rabbelier <srabbelier@gmail.com>
parents:
611
diff
changeset
|
218 |
params['key_fields_pattern'] = getKeyFieldsPattern(params) |
4880ffa9f3ba
Moved getDjangoURLPatterns to sitemap.sitemap
Sverre Rabbelier <srabbelier@gmail.com>
parents:
611
diff
changeset
|
219 |
|
1007
3b66772d21a5
Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
220 |
# merge already done by access.Checker |
3b66772d21a5
Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
221 |
params['rights'] = rights |
3b66772d21a5
Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
970
diff
changeset
|
222 |
|
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
223 |
return params |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
224 |
|
668
77f9a6ea6e67
Some style and typo fixes in different modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
660
diff
changeset
|
225 |
|
778
bc13cd968946
Added support for mutliple edit forms based on entity type
Sverre Rabbelier <srabbelier@gmail.com>
parents:
761
diff
changeset
|
226 |
def getCreateForm(params, model): |
639
1f92bd41b914
Some docstring fixes in few modules (soc.views.helper soc.views.models.base).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
616
diff
changeset
|
227 |
"""Constructs a new CreateForm using params. |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
228 |
|
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
229 |
Params usage: |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
230 |
dynabase: The dynabase value is used as the base argument to |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
231 |
dynaform.newDynaForm. |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
232 |
logic: The logic value is used to get the model argument to newDynaForm. |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
233 |
create_dynainclude: same as dynabase, but as dynainclude argument |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
234 |
create_dynaexclude: same as dynabase, but as dynaexclude argument |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
235 |
create_dynafields: same as dynabase, but as dynafields argument |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
236 |
""" |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
237 |
|
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
238 |
create_form = dynaform.newDynaForm( |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
239 |
dynabase = params['dynabase'], |
778
bc13cd968946
Added support for mutliple edit forms based on entity type
Sverre Rabbelier <srabbelier@gmail.com>
parents:
761
diff
changeset
|
240 |
dynamodel = model, |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
241 |
dynainclude = params['create_dynainclude'], |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
242 |
dynaexclude = params['create_dynaexclude'], |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
243 |
dynafields = params['create_dynafields'], |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
244 |
) |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
245 |
|
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
246 |
return create_form |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
247 |
|
668
77f9a6ea6e67
Some style and typo fixes in different modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
660
diff
changeset
|
248 |
|
778
bc13cd968946
Added support for mutliple edit forms based on entity type
Sverre Rabbelier <srabbelier@gmail.com>
parents:
761
diff
changeset
|
249 |
def getEditForm(params, base_form): |
639
1f92bd41b914
Some docstring fixes in few modules (soc.views.helper soc.views.models.base).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
616
diff
changeset
|
250 |
"""Constructs a new EditForm using params. |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
251 |
|
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
252 |
Params usage: |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
253 |
create_form: The dynabase value is used as the dynaform argument |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
254 |
to dyanform.extendDynaForm. |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
255 |
edit_dynainclude: same as create_form, but as dynainclude argument |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
256 |
edit_dynaexclude: same as create_form, but as dynaexclude argument |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
257 |
edit_dynafields: same as create_form, but as dynafields argument |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
258 |
""" |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
259 |
|
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
260 |
edit_form = dynaform.extendDynaForm( |
778
bc13cd968946
Added support for mutliple edit forms based on entity type
Sverre Rabbelier <srabbelier@gmail.com>
parents:
761
diff
changeset
|
261 |
dynaform = base_form, |
611
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
262 |
dynainclude = params['edit_dynainclude'], |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
263 |
dynaexclude = params['edit_dynaexclude'], |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
264 |
dynafields = params['edit_dynafields'], |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
265 |
) |
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
266 |
|
2ec30182e5f1
Move parameter construction into a seperate module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
267 |
return edit_form |
613
4880ffa9f3ba
Moved getDjangoURLPatterns to sitemap.sitemap
Sverre Rabbelier <srabbelier@gmail.com>
parents:
611
diff
changeset
|
268 |
|
668
77f9a6ea6e67
Some style and typo fixes in different modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
660
diff
changeset
|
269 |
|
613
4880ffa9f3ba
Moved getDjangoURLPatterns to sitemap.sitemap
Sverre Rabbelier <srabbelier@gmail.com>
parents:
611
diff
changeset
|
270 |
def getKeyFieldsPattern(params): |
639
1f92bd41b914
Some docstring fixes in few modules (soc.views.helper soc.views.models.base).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
616
diff
changeset
|
271 |
"""Returns the Django pattern for this View's entity. |
613
4880ffa9f3ba
Moved getDjangoURLPatterns to sitemap.sitemap
Sverre Rabbelier <srabbelier@gmail.com>
parents:
611
diff
changeset
|
272 |
""" |
4880ffa9f3ba
Moved getDjangoURLPatterns to sitemap.sitemap
Sverre Rabbelier <srabbelier@gmail.com>
parents:
611
diff
changeset
|
273 |
|
673 | 274 |
names = params['logic'].getKeyFieldNames() |
1094
e143974a6e27
Factor out the getPattern logic from params
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1093
diff
changeset
|
275 |
scope_path_pattern = params['scope_path_pattern'] |
e143974a6e27
Factor out the getPattern logic from params
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1093
diff
changeset
|
276 |
|
e143974a6e27
Factor out the getPattern logic from params
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1093
diff
changeset
|
277 |
return getPattern(names, scope_path_pattern) |
e143974a6e27
Factor out the getPattern logic from params
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1093
diff
changeset
|
278 |
|
e143974a6e27
Factor out the getPattern logic from params
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1093
diff
changeset
|
279 |
|
e143974a6e27
Factor out the getPattern logic from params
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1093
diff
changeset
|
280 |
def getPattern(names, scope_path_pattern): |
e143974a6e27
Factor out the getPattern logic from params
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1093
diff
changeset
|
281 |
"""Returns the Django patterns for the specified names. |
e143974a6e27
Factor out the getPattern logic from params
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1093
diff
changeset
|
282 |
|
e143974a6e27
Factor out the getPattern logic from params
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1093
diff
changeset
|
283 |
Args: |
e143974a6e27
Factor out the getPattern logic from params
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1093
diff
changeset
|
284 |
names: the field names that should be included in the pattern |
e143974a6e27
Factor out the getPattern logic from params
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1093
diff
changeset
|
285 |
scope_path_pattern: the pattern to use if the name is 'scope_path' |
e143974a6e27
Factor out the getPattern logic from params
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1093
diff
changeset
|
286 |
""" |
e143974a6e27
Factor out the getPattern logic from params
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1093
diff
changeset
|
287 |
|
1092
b03895bba47a
Removed unused key_fields_prefix variable
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1087
diff
changeset
|
288 |
patterns = [] |
613
4880ffa9f3ba
Moved getDjangoURLPatterns to sitemap.sitemap
Sverre Rabbelier <srabbelier@gmail.com>
parents:
611
diff
changeset
|
289 |
|
4880ffa9f3ba
Moved getDjangoURLPatterns to sitemap.sitemap
Sverre Rabbelier <srabbelier@gmail.com>
parents:
611
diff
changeset
|
290 |
for name in names: |
679
77a286ff6667
Introduce dynamic scope_path regexps
Sverre Rabbelier <srabbelier@gmail.com>
parents:
673
diff
changeset
|
291 |
if name == 'scope_path': |
1094
e143974a6e27
Factor out the getPattern logic from params
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1093
diff
changeset
|
292 |
pattern = scope_path_pattern |
679
77a286ff6667
Introduce dynamic scope_path regexps
Sverre Rabbelier <srabbelier@gmail.com>
parents:
673
diff
changeset
|
293 |
else: |
77a286ff6667
Introduce dynamic scope_path regexps
Sverre Rabbelier <srabbelier@gmail.com>
parents:
673
diff
changeset
|
294 |
pattern = r'(?P<%s>%s)' % (name, linkable.LINK_ID_PATTERN_CORE) |
613
4880ffa9f3ba
Moved getDjangoURLPatterns to sitemap.sitemap
Sverre Rabbelier <srabbelier@gmail.com>
parents:
611
diff
changeset
|
295 |
patterns.append(pattern) |
4880ffa9f3ba
Moved getDjangoURLPatterns to sitemap.sitemap
Sverre Rabbelier <srabbelier@gmail.com>
parents:
611
diff
changeset
|
296 |
|
4880ffa9f3ba
Moved getDjangoURLPatterns to sitemap.sitemap
Sverre Rabbelier <srabbelier@gmail.com>
parents:
611
diff
changeset
|
297 |
result = '/'.join(patterns) |
4880ffa9f3ba
Moved getDjangoURLPatterns to sitemap.sitemap
Sverre Rabbelier <srabbelier@gmail.com>
parents:
611
diff
changeset
|
298 |
return result |
679
77a286ff6667
Introduce dynamic scope_path regexps
Sverre Rabbelier <srabbelier@gmail.com>
parents:
673
diff
changeset
|
299 |
|
837
bc1c951bf3a0
Add missing blank line in soc.views.helper.params module. Fix docstring typo in soc.views.models.role module. Add missing dots at the end of sentences in soc.logic.cleaning and soc.view.models.user_self modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
799
diff
changeset
|
300 |
|
679
77a286ff6667
Introduce dynamic scope_path regexps
Sverre Rabbelier <srabbelier@gmail.com>
parents:
673
diff
changeset
|
301 |
def getScopePattern(params): |
689
46db8c4bbffc
Add missing dots in docstrings in modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
680
diff
changeset
|
302 |
"""Returns the Scope pattern for this entity. |
679
77a286ff6667
Introduce dynamic scope_path regexps
Sverre Rabbelier <srabbelier@gmail.com>
parents:
673
diff
changeset
|
303 |
""" |
77a286ff6667
Introduce dynamic scope_path regexps
Sverre Rabbelier <srabbelier@gmail.com>
parents:
673
diff
changeset
|
304 |
|
77a286ff6667
Introduce dynamic scope_path regexps
Sverre Rabbelier <srabbelier@gmail.com>
parents:
673
diff
changeset
|
305 |
logic = params['logic'] |
77a286ff6667
Introduce dynamic scope_path regexps
Sverre Rabbelier <srabbelier@gmail.com>
parents:
673
diff
changeset
|
306 |
depth = logic.getScopeDepth() |
77a286ff6667
Introduce dynamic scope_path regexps
Sverre Rabbelier <srabbelier@gmail.com>
parents:
673
diff
changeset
|
307 |
if depth is None: |
77a286ff6667
Introduce dynamic scope_path regexps
Sverre Rabbelier <srabbelier@gmail.com>
parents:
673
diff
changeset
|
308 |
return linkable.SCOPE_PATH_ARG_PATTERN |
77a286ff6667
Introduce dynamic scope_path regexps
Sverre Rabbelier <srabbelier@gmail.com>
parents:
673
diff
changeset
|
309 |
|
77a286ff6667
Introduce dynamic scope_path regexps
Sverre Rabbelier <srabbelier@gmail.com>
parents:
673
diff
changeset
|
310 |
regexps = [linkable.LINK_ID_PATTERN_CORE for i in range(depth)] |
77a286ff6667
Introduce dynamic scope_path regexps
Sverre Rabbelier <srabbelier@gmail.com>
parents:
673
diff
changeset
|
311 |
regexp = '/'.join(regexps) |
77a286ff6667
Introduce dynamic scope_path regexps
Sverre Rabbelier <srabbelier@gmail.com>
parents:
673
diff
changeset
|
312 |
return r'(?P<scope_path>%s)' % regexp |