author | Pawel Solyga <Pawel.Solyga@gmail.com> |
Thu, 16 Oct 2008 17:34:10 +0000 | |
changeset 361 | 465e4df617de |
parent 360 | 5ad9cabb5892 |
child 365 | 74dec172944e |
permissions | -rw-r--r-- |
259
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
2 |
# |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
4 |
# |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
8 |
# |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
10 |
# |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
16 |
|
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
17 |
"""Developer views for editing and examining Sponsor profiles. |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
18 |
""" |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
19 |
|
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
21 |
'"Pawel Solyga" <pawel.solyga@gmail.com>', |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
22 |
] |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
23 |
|
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
24 |
|
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
25 |
from google.appengine.api import users |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
26 |
|
324
05e21c089be6
Add missing import in soc/views/site/sponsor/list.py which caused exception when app was deployed and first site you visited was "List Site Sponsors". Update files according to recent django update and django backwards incompatibility (for example newforms is changed to forms).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
321
diff
changeset
|
27 |
from django import forms |
259
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
28 |
from django import http |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
29 |
|
316
9efdc7bc3565
Add missing blank lines between imports and sort all of the imports.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
313
diff
changeset
|
30 |
from soc.logic import models |
9efdc7bc3565
Add missing blank lines between imports and sort all of the imports.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
313
diff
changeset
|
31 |
from soc.logic import out_of_band |
259
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
32 |
from soc.logic import validate |
316
9efdc7bc3565
Add missing blank lines between imports and sort all of the imports.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
313
diff
changeset
|
33 |
from soc.logic.models import sponsor |
259
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
34 |
from soc.logic.site import id_user |
316
9efdc7bc3565
Add missing blank lines between imports and sort all of the imports.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
313
diff
changeset
|
35 |
from soc.views import helper |
9efdc7bc3565
Add missing blank lines between imports and sort all of the imports.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
313
diff
changeset
|
36 |
from soc.views import simple |
9efdc7bc3565
Add missing blank lines between imports and sort all of the imports.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
313
diff
changeset
|
37 |
from soc.views.helper import access |
9efdc7bc3565
Add missing blank lines between imports and sort all of the imports.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
313
diff
changeset
|
38 |
from soc.views.user import profile |
9efdc7bc3565
Add missing blank lines between imports and sort all of the imports.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
313
diff
changeset
|
39 |
|
9efdc7bc3565
Add missing blank lines between imports and sort all of the imports.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
313
diff
changeset
|
40 |
import soc.logic |
344
d135c8c09967
Change verbose_name of founder property in Group model from "Created by" to "Founded by". Add GROUP_TYPE_SHORT and GROUP_TYPE_PLURAL for all models that inherit from Group and use that values in templates and contexts. Assume that group_type, group_type_short and group_type_plural are defined in context and remove not needed ifs in templates. Rename "Linkname" to "Link name" in list/group_heading.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
337
diff
changeset
|
41 |
import soc.models.sponsor as sponsor_model |
274
56e1c1721299
Move helpers/forms_helpers.py to helper/forms.py.
Todd Larsen <tlarsen@google.com>
parents:
272
diff
changeset
|
42 |
import soc.views.helper.forms |
269
0f1acc4c3e1e
Move helpers/request.py to helper/requests.py to avoid conflict with common
Todd Larsen <tlarsen@google.com>
parents:
267
diff
changeset
|
43 |
import soc.views.helper.requests |
272
00cea07656c0
Move helpers/response_helpers.py to helper/responses.py.
Todd Larsen <tlarsen@google.com>
parents:
271
diff
changeset
|
44 |
import soc.views.helper.responses |
271
01e90bb21b7e
Replace helpers/custom_widgets.py with helper/widgets.py.
Todd Larsen <tlarsen@google.com>
parents:
269
diff
changeset
|
45 |
import soc.views.helper.widgets |
303
4f1bb54ddae5
Moved soc/logic/helper/access to soc/views/helper/access
Sverre Rabbelier <srabbelier@gmail.com>
parents:
302
diff
changeset
|
46 |
import soc.views.out_of_band |
259
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
47 |
|
316
9efdc7bc3565
Add missing blank lines between imports and sort all of the imports.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
313
diff
changeset
|
48 |
|
274
56e1c1721299
Move helpers/forms_helpers.py to helper/forms.py.
Todd Larsen <tlarsen@google.com>
parents:
272
diff
changeset
|
49 |
class CreateForm(helper.forms.DbModelForm): |
259
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
50 |
"""Django form displayed when creating a Sponsor. |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
51 |
""" |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
52 |
class Meta: |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
53 |
"""Inner Meta class that defines some behavior for the form. |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
54 |
""" |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
55 |
#: db.Model subclass for which the form will gather information |
344
d135c8c09967
Change verbose_name of founder property in Group model from "Created by" to "Founded by". Add GROUP_TYPE_SHORT and GROUP_TYPE_PLURAL for all models that inherit from Group and use that values in templates and contexts. Assume that group_type, group_type_short and group_type_plural are defined in context and remove not needed ifs in templates. Rename "Linkname" to "Link name" in list/group_heading.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
337
diff
changeset
|
56 |
model = sponsor_model.Sponsor |
259
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
57 |
|
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
58 |
#: list of model fields which will *not* be gathered by the form |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
59 |
exclude = ['founder', 'inheritance_line'] |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
60 |
|
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
61 |
# TODO(pawel.solyga): write validation functions for other fields |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
62 |
def clean_link_name(self): |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
63 |
link_name = self.cleaned_data.get('link_name') |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
64 |
if not validate.isLinkNameFormatValid(link_name): |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
65 |
raise forms.ValidationError("This link name is in wrong format.") |
309
7190b224c701
Made the existing code use the new soc.logic.models
Sverre Rabbelier <srabbelier@gmail.com>
parents:
303
diff
changeset
|
66 |
if models.sponsor.logic.getFromFields(link_name=link_name): |
259
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
67 |
raise forms.ValidationError("This link name is already in use.") |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
68 |
return link_name |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
69 |
|
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
70 |
|
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
71 |
class EditForm(CreateForm): |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
72 |
"""Django form displayed when editing a Sponsor. |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
73 |
""" |
271
01e90bb21b7e
Replace helpers/custom_widgets.py with helper/widgets.py.
Todd Larsen <tlarsen@google.com>
parents:
269
diff
changeset
|
74 |
link_name = forms.CharField(widget=helper.widgets.ReadOnlyInput()) |
344
d135c8c09967
Change verbose_name of founder property in Group model from "Created by" to "Founded by". Add GROUP_TYPE_SHORT and GROUP_TYPE_PLURAL for all models that inherit from Group and use that values in templates and contexts. Assume that group_type, group_type_short and group_type_plural are defined in context and remove not needed ifs in templates. Rename "Linkname" to "Link name" in list/group_heading.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
337
diff
changeset
|
75 |
founded_by = forms.CharField(widget=helper.widgets.ReadOnlyInput(), |
337
cb7d22b1e7d8
Show "Created by" read-only field in Sponsor Edit view. Fix function keyword arguments in sponsor/list.py to follow our PythonStyleGuide. Sponsor founder property is not updated anymore when editing Sponsor profile, it's just saved once when creating Sponsor profile.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
324
diff
changeset
|
76 |
required=False) |
259
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
77 |
|
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
78 |
def clean_link_name(self): |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
79 |
link_name = self.cleaned_data.get('link_name') |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
80 |
if not validate.isLinkNameFormatValid(link_name): |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
81 |
raise forms.ValidationError("This link name is in wrong format.") |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
82 |
return link_name |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
83 |
|
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
84 |
|
292
1cece5192e26
Enable recently commited delete Sponsor request handler (added to map.py) and Delete button in Sponsor edit view. Still missing "Are you sure ?" question box.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
290
diff
changeset
|
85 |
DEF_SITE_SPONSOR_PROFILE_EDIT_TMPL = 'soc/site/sponsor/profile/edit.html' |
259
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
86 |
DEF_SPONSOR_NO_LINKNAME_CHANGE_MSG = 'Sponsor link name cannot be changed.' |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
87 |
DEF_CREATE_NEW_SPONSOR_MSG = ' You can create a new sponsor by visiting' \ |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
88 |
' <a href="/site/sponsor/profile">Create ' \ |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
89 |
'a New Sponsor</a> page.' |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
90 |
|
358
843d83b87282
Add page=None parameter to all views. Information from page argument (which is soc.logic.site.page.Page object) is going to be used later in views code and for some context values. Fix some indentions in __doc__ strings. Add proper __doc__ string for all() function in sponsor/list.py module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
344
diff
changeset
|
91 |
def edit(request, page=None, link_name=None, template=DEF_SITE_SPONSOR_PROFILE_EDIT_TMPL): |
259
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
92 |
"""View for a Developer to modify the properties of a Sponsor Model entity. |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
93 |
|
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
94 |
Args: |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
95 |
request: the standard django request object |
358
843d83b87282
Add page=None parameter to all views. Information from page argument (which is soc.logic.site.page.Page object) is going to be used later in views code and for some context values. Fix some indentions in __doc__ strings. Add proper __doc__ string for all() function in sponsor/list.py module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
344
diff
changeset
|
96 |
page: a soc.logic.site.page.Page object which is abstraction that combines |
843d83b87282
Add page=None parameter to all views. Information from page argument (which is soc.logic.site.page.Page object) is going to be used later in views code and for some context values. Fix some indentions in __doc__ strings. Add proper __doc__ string for all() function in sponsor/list.py module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
344
diff
changeset
|
97 |
a Django view with sidebar menu info |
298
c76a366c7ab4
Replace almost all occurences of linkname with link_name
Sverre Rabbelier <srabbelier@gmail.com>
parents:
294
diff
changeset
|
98 |
link_name: the Sponsor's site-unique "link_name" extracted from the URL |
259
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
99 |
template: the "sibling" template (or a search list of such templates) |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
100 |
from which to construct the public.html template name (or names) |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
101 |
|
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
102 |
Returns: |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
103 |
A subclass of django.http.HttpResponse which either contains the form to |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
104 |
be filled out, or a redirect to the correct view in the interface. |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
105 |
""" |
294
1fdaab4a6ef2
Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
292
diff
changeset
|
106 |
|
1fdaab4a6ef2
Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
292
diff
changeset
|
107 |
try: |
1fdaab4a6ef2
Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
292
diff
changeset
|
108 |
access.checkIsDeveloper(request) |
303
4f1bb54ddae5
Moved soc/logic/helper/access to soc/views/helper/access
Sverre Rabbelier <srabbelier@gmail.com>
parents:
302
diff
changeset
|
109 |
except soc.views.out_of_band.AccessViolationResponse, alt_response: |
294
1fdaab4a6ef2
Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
292
diff
changeset
|
110 |
return alt_response.response() |
1fdaab4a6ef2
Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
292
diff
changeset
|
111 |
|
259
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
112 |
# create default template context for use with any templates |
272
00cea07656c0
Move helpers/response_helpers.py to helper/responses.py.
Todd Larsen <tlarsen@google.com>
parents:
271
diff
changeset
|
113 |
context = helper.responses.getUniversalContext(request) |
259
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
114 |
|
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
115 |
logged_in_id = users.get_current_user() |
321
f17ecd21ca33
Some indentations fixes. Changed all the email=id function arguments to email=id.email().
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
316
diff
changeset
|
116 |
user = models.user.logic.getFromFields(email=logged_in_id.email()) |
259
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
117 |
sponsor_form = None |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
118 |
existing_sponsor = None |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
119 |
|
298
c76a366c7ab4
Replace almost all occurences of linkname with link_name
Sverre Rabbelier <srabbelier@gmail.com>
parents:
294
diff
changeset
|
120 |
# try to fetch Sponsor entity corresponding to link_name if one exists |
259
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
121 |
try: |
313
c25b1b680ba7
Bugfixes to the latest revision
Sverre Rabbelier <srabbelier@gmail.com>
parents:
309
diff
changeset
|
122 |
existing_sponsor = sponsor.logic.getIfFields(link_name=link_name) |
259
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
123 |
except out_of_band.ErrorResponse, error: |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
124 |
# show custom 404 page when link name doesn't exist in Datastore |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
125 |
error.message = error.message + DEF_CREATE_NEW_SPONSOR_MSG |
361
465e4df617de
Make page argument required for errorResponse and requestLogin functions in simple.py and update affected files. Some keyword argument changes to in user/profile.py. All the changes are based on comments to r817.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
360
diff
changeset
|
126 |
return simple.errorResponse(request, page, error, template, context) |
259
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
127 |
|
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
128 |
if request.method == 'POST': |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
129 |
if existing_sponsor: |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
130 |
sponsor_form = EditForm(request.POST) |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
131 |
else: |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
132 |
sponsor_form = CreateForm(request.POST) |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
133 |
|
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
134 |
if sponsor_form.is_valid(): |
298
c76a366c7ab4
Replace almost all occurences of linkname with link_name
Sverre Rabbelier <srabbelier@gmail.com>
parents:
294
diff
changeset
|
135 |
if link_name: |
c76a366c7ab4
Replace almost all occurences of linkname with link_name
Sverre Rabbelier <srabbelier@gmail.com>
parents:
294
diff
changeset
|
136 |
# Form doesn't allow to change link_name but somebody might want to |
c76a366c7ab4
Replace almost all occurences of linkname with link_name
Sverre Rabbelier <srabbelier@gmail.com>
parents:
294
diff
changeset
|
137 |
# abuse that manually, so we check if form link_name is the same as |
c76a366c7ab4
Replace almost all occurences of linkname with link_name
Sverre Rabbelier <srabbelier@gmail.com>
parents:
294
diff
changeset
|
138 |
# url link_name |
c76a366c7ab4
Replace almost all occurences of linkname with link_name
Sverre Rabbelier <srabbelier@gmail.com>
parents:
294
diff
changeset
|
139 |
if sponsor_form.cleaned_data.get('link_name') != link_name: |
259
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
140 |
msg = DEF_SPONSOR_NO_LINKNAME_CHANGE_MSG |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
141 |
error = out_of_band.ErrorResponse(msg) |
361
465e4df617de
Make page argument required for errorResponse and requestLogin functions in simple.py and update affected files. Some keyword argument changes to in user/profile.py. All the changes are based on comments to r817.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
360
diff
changeset
|
142 |
return simple.errorResponse(request, page, error, template, context) |
259
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
143 |
|
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
144 |
fields = {} |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
145 |
|
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
146 |
# Ask for all the fields and pull them out |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
147 |
for field in sponsor_form.cleaned_data: |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
148 |
value = sponsor_form.cleaned_data.get(field) |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
149 |
fields[field] = value |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
150 |
|
337
cb7d22b1e7d8
Show "Created by" read-only field in Sponsor Edit view. Fix function keyword arguments in sponsor/list.py to follow our PythonStyleGuide. Sponsor founder property is not updated anymore when editing Sponsor profile, it's just saved once when creating Sponsor profile.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
324
diff
changeset
|
151 |
if not existing_sponsor: |
cb7d22b1e7d8
Show "Created by" read-only field in Sponsor Edit view. Fix function keyword arguments in sponsor/list.py to follow our PythonStyleGuide. Sponsor founder property is not updated anymore when editing Sponsor profile, it's just saved once when creating Sponsor profile.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
324
diff
changeset
|
152 |
fields['founder'] = user |
259
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
153 |
|
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
154 |
form_ln = fields['link_name'] |
309
7190b224c701
Made the existing code use the new soc.logic.models
Sverre Rabbelier <srabbelier@gmail.com>
parents:
303
diff
changeset
|
155 |
form_sponsor = models.sponsor.logic.updateOrCreateFromFields(fields, link_name=form_ln) |
259
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
156 |
|
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
157 |
if not form_sponsor: |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
158 |
return http.HttpResponseRedirect('/') |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
159 |
|
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
160 |
# redirect to new /site/sponsor/profile/form_link_name?s=0 |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
161 |
# (causes 'Profile saved' message to be displayed) |
272
00cea07656c0
Move helpers/response_helpers.py to helper/responses.py.
Todd Larsen <tlarsen@google.com>
parents:
271
diff
changeset
|
162 |
return helper.responses.redirectToChangedSuffix( |
259
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
163 |
request, None, form_ln, |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
164 |
params=profile.SUBMIT_PROFILE_SAVED_PARAMS) |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
165 |
|
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
166 |
else: # request.method == 'GET' |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
167 |
if existing_sponsor: |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
168 |
# is 'Profile saved' parameter present, but referrer was not ourself? |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
169 |
# (e.g. someone bookmarked the GET that followed the POST submit) |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
170 |
if (request.GET.get(profile.SUBMIT_MSG_PARAM_NAME) |
298
c76a366c7ab4
Replace almost all occurences of linkname with link_name
Sverre Rabbelier <srabbelier@gmail.com>
parents:
294
diff
changeset
|
171 |
and (not helper.requests.isReferrerSelf(request, suffix=link_name))): |
259
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
172 |
# redirect to aggressively remove 'Profile saved' query parameter |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
173 |
return http.HttpResponseRedirect(request.path) |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
174 |
|
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
175 |
# referrer was us, so select which submit message to display |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
176 |
# (may display no message if ?s=0 parameter is not present) |
290
2a92b866ed40
Create a submit_buttons block in group edit profile template so that submit buttons can be customized. Replace submit_message usage with new notice block (still work in progress in Lookup User views). Add customized edit profile template for Sponsor with delete button (not used yet, upcoming commit). Add delete Sponsor request handler.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
278
diff
changeset
|
177 |
context['notice'] = ( |
269
0f1acc4c3e1e
Move helpers/request.py to helper/requests.py to avoid conflict with common
Todd Larsen <tlarsen@google.com>
parents:
267
diff
changeset
|
178 |
helper.requests.getSingleIndexedParamValue( |
259
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
179 |
request, profile.SUBMIT_MSG_PARAM_NAME, |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
180 |
values=profile.SUBMIT_MESSAGES)) |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
181 |
|
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
182 |
# populate form with the existing Sponsor entity |
337
cb7d22b1e7d8
Show "Created by" read-only field in Sponsor Edit view. Fix function keyword arguments in sponsor/list.py to follow our PythonStyleGuide. Sponsor founder property is not updated anymore when editing Sponsor profile, it's just saved once when creating Sponsor profile.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
324
diff
changeset
|
183 |
founder_link_name = existing_sponsor.founder.link_name |
cb7d22b1e7d8
Show "Created by" read-only field in Sponsor Edit view. Fix function keyword arguments in sponsor/list.py to follow our PythonStyleGuide. Sponsor founder property is not updated anymore when editing Sponsor profile, it's just saved once when creating Sponsor profile.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
324
diff
changeset
|
184 |
sponsor_form = EditForm(instance=existing_sponsor, |
344
d135c8c09967
Change verbose_name of founder property in Group model from "Created by" to "Founded by". Add GROUP_TYPE_SHORT and GROUP_TYPE_PLURAL for all models that inherit from Group and use that values in templates and contexts. Assume that group_type, group_type_short and group_type_plural are defined in context and remove not needed ifs in templates. Rename "Linkname" to "Link name" in list/group_heading.html template.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
337
diff
changeset
|
185 |
initial={'founded_by': founder_link_name}) |
259
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
186 |
else: |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
187 |
if request.GET.get(profile.SUBMIT_MSG_PARAM_NAME): |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
188 |
# redirect to aggressively remove 'Profile saved' query parameter |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
189 |
return http.HttpResponseRedirect(request.path) |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
190 |
|
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
191 |
# no Sponsor entity exists for this link name, so show a blank form |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
192 |
sponsor_form = CreateForm() |
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
193 |
|
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
194 |
context.update({'form': sponsor_form, |
360
5ad9cabb5892
Rename 'group' to 'entity' in the Django templates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
358
diff
changeset
|
195 |
'entity': existing_sponsor, |
5ad9cabb5892
Rename 'group' to 'entity' in the Django templates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
358
diff
changeset
|
196 |
'entity_type': 'Sponsor', |
5ad9cabb5892
Rename 'group' to 'entity' in the Django templates
Sverre Rabbelier <srabbelier@gmail.com>
parents:
358
diff
changeset
|
197 |
'entity_type_short': sponsor_model.Sponsor.GROUP_TYPE_SHORT}) |
259
74eb6b01c82c
Add basic Sponsors List, Create New Sponsor, Sponsor Public Profile views. Change all properties in Group model as required for now. Remaining TODO: write validation functions for Sponsor edit and create form fields that need additional validation (like address, phone number format).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
198 |
|
278
b0e2d509b5c3
Add create() wrapper views that simply call the existing edit() views, to
Todd Larsen <tlarsen@google.com>
parents:
274
diff
changeset
|
199 |
return helper.responses.respond(request, template, context) |
b0e2d509b5c3
Add create() wrapper views that simply call the existing edit() views, to
Todd Larsen <tlarsen@google.com>
parents:
274
diff
changeset
|
200 |
|
b0e2d509b5c3
Add create() wrapper views that simply call the existing edit() views, to
Todd Larsen <tlarsen@google.com>
parents:
274
diff
changeset
|
201 |
|
292
1cece5192e26
Enable recently commited delete Sponsor request handler (added to map.py) and Delete button in Sponsor edit view. Still missing "Are you sure ?" question box.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
290
diff
changeset
|
202 |
DEF_SITE_SPONSOR_PROFILE_CREATE_TMPL = 'soc/group/profile/edit.html' |
1cece5192e26
Enable recently commited delete Sponsor request handler (added to map.py) and Delete button in Sponsor edit view. Still missing "Are you sure ?" question box.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
290
diff
changeset
|
203 |
|
358
843d83b87282
Add page=None parameter to all views. Information from page argument (which is soc.logic.site.page.Page object) is going to be used later in views code and for some context values. Fix some indentions in __doc__ strings. Add proper __doc__ string for all() function in sponsor/list.py module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
344
diff
changeset
|
204 |
def create(request, page=None, template=DEF_SITE_SPONSOR_PROFILE_CREATE_TMPL): |
298
c76a366c7ab4
Replace almost all occurences of linkname with link_name
Sverre Rabbelier <srabbelier@gmail.com>
parents:
294
diff
changeset
|
205 |
"""create() view is same as edit() view, but with no link_name supplied. |
278
b0e2d509b5c3
Add create() wrapper views that simply call the existing edit() views, to
Todd Larsen <tlarsen@google.com>
parents:
274
diff
changeset
|
206 |
""" |
358
843d83b87282
Add page=None parameter to all views. Information from page argument (which is soc.logic.site.page.Page object) is going to be used later in views code and for some context values. Fix some indentions in __doc__ strings. Add proper __doc__ string for all() function in sponsor/list.py module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
344
diff
changeset
|
207 |
return edit(request, page, link_name=None, template=template) |
290
2a92b866ed40
Create a submit_buttons block in group edit profile template so that submit buttons can be customized. Replace submit_message usage with new notice block (still work in progress in Lookup User views). Add customized edit profile template for Sponsor with delete button (not used yet, upcoming commit). Add delete Sponsor request handler.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
278
diff
changeset
|
208 |
|
2a92b866ed40
Create a submit_buttons block in group edit profile template so that submit buttons can be customized. Replace submit_message usage with new notice block (still work in progress in Lookup User views). Add customized edit profile template for Sponsor with delete button (not used yet, upcoming commit). Add delete Sponsor request handler.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
278
diff
changeset
|
209 |
|
358
843d83b87282
Add page=None parameter to all views. Information from page argument (which is soc.logic.site.page.Page object) is going to be used later in views code and for some context values. Fix some indentions in __doc__ strings. Add proper __doc__ string for all() function in sponsor/list.py module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
344
diff
changeset
|
210 |
def delete(request, page=None, link_name=None, template=DEF_SITE_SPONSOR_PROFILE_EDIT_TMPL): |
290
2a92b866ed40
Create a submit_buttons block in group edit profile template so that submit buttons can be customized. Replace submit_message usage with new notice block (still work in progress in Lookup User views). Add customized edit profile template for Sponsor with delete button (not used yet, upcoming commit). Add delete Sponsor request handler.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
278
diff
changeset
|
211 |
"""Request handler for a Developer to delete Sponsor Model entity. |
2a92b866ed40
Create a submit_buttons block in group edit profile template so that submit buttons can be customized. Replace submit_message usage with new notice block (still work in progress in Lookup User views). Add customized edit profile template for Sponsor with delete button (not used yet, upcoming commit). Add delete Sponsor request handler.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
278
diff
changeset
|
212 |
|
2a92b866ed40
Create a submit_buttons block in group edit profile template so that submit buttons can be customized. Replace submit_message usage with new notice block (still work in progress in Lookup User views). Add customized edit profile template for Sponsor with delete button (not used yet, upcoming commit). Add delete Sponsor request handler.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
278
diff
changeset
|
213 |
Args: |
2a92b866ed40
Create a submit_buttons block in group edit profile template so that submit buttons can be customized. Replace submit_message usage with new notice block (still work in progress in Lookup User views). Add customized edit profile template for Sponsor with delete button (not used yet, upcoming commit). Add delete Sponsor request handler.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
278
diff
changeset
|
214 |
request: the standard django request object |
358
843d83b87282
Add page=None parameter to all views. Information from page argument (which is soc.logic.site.page.Page object) is going to be used later in views code and for some context values. Fix some indentions in __doc__ strings. Add proper __doc__ string for all() function in sponsor/list.py module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
344
diff
changeset
|
215 |
page: a soc.logic.site.page.Page object which is abstraction that combines |
843d83b87282
Add page=None parameter to all views. Information from page argument (which is soc.logic.site.page.Page object) is going to be used later in views code and for some context values. Fix some indentions in __doc__ strings. Add proper __doc__ string for all() function in sponsor/list.py module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
344
diff
changeset
|
216 |
a Django view with sidebar menu info |
298
c76a366c7ab4
Replace almost all occurences of linkname with link_name
Sverre Rabbelier <srabbelier@gmail.com>
parents:
294
diff
changeset
|
217 |
link_name: the Sponsor's site-unique "link_name" extracted from the URL |
290
2a92b866ed40
Create a submit_buttons block in group edit profile template so that submit buttons can be customized. Replace submit_message usage with new notice block (still work in progress in Lookup User views). Add customized edit profile template for Sponsor with delete button (not used yet, upcoming commit). Add delete Sponsor request handler.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
278
diff
changeset
|
218 |
template: the "sibling" template (or a search list of such templates) |
2a92b866ed40
Create a submit_buttons block in group edit profile template so that submit buttons can be customized. Replace submit_message usage with new notice block (still work in progress in Lookup User views). Add customized edit profile template for Sponsor with delete button (not used yet, upcoming commit). Add delete Sponsor request handler.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
278
diff
changeset
|
219 |
from which to construct the public.html template name (or names) |
2a92b866ed40
Create a submit_buttons block in group edit profile template so that submit buttons can be customized. Replace submit_message usage with new notice block (still work in progress in Lookup User views). Add customized edit profile template for Sponsor with delete button (not used yet, upcoming commit). Add delete Sponsor request handler.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
278
diff
changeset
|
220 |
|
2a92b866ed40
Create a submit_buttons block in group edit profile template so that submit buttons can be customized. Replace submit_message usage with new notice block (still work in progress in Lookup User views). Add customized edit profile template for Sponsor with delete button (not used yet, upcoming commit). Add delete Sponsor request handler.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
278
diff
changeset
|
221 |
Returns: |
2a92b866ed40
Create a submit_buttons block in group edit profile template so that submit buttons can be customized. Replace submit_message usage with new notice block (still work in progress in Lookup User views). Add customized edit profile template for Sponsor with delete button (not used yet, upcoming commit). Add delete Sponsor request handler.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
278
diff
changeset
|
222 |
A subclass of django.http.HttpResponse which redirects |
2a92b866ed40
Create a submit_buttons block in group edit profile template so that submit buttons can be customized. Replace submit_message usage with new notice block (still work in progress in Lookup User views). Add customized edit profile template for Sponsor with delete button (not used yet, upcoming commit). Add delete Sponsor request handler.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
278
diff
changeset
|
223 |
to /site/sponsor/list. |
2a92b866ed40
Create a submit_buttons block in group edit profile template so that submit buttons can be customized. Replace submit_message usage with new notice block (still work in progress in Lookup User views). Add customized edit profile template for Sponsor with delete button (not used yet, upcoming commit). Add delete Sponsor request handler.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
278
diff
changeset
|
224 |
""" |
294
1fdaab4a6ef2
Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
292
diff
changeset
|
225 |
|
1fdaab4a6ef2
Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
292
diff
changeset
|
226 |
try: |
1fdaab4a6ef2
Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
292
diff
changeset
|
227 |
access.checkIsDeveloper(request) |
303
4f1bb54ddae5
Moved soc/logic/helper/access to soc/views/helper/access
Sverre Rabbelier <srabbelier@gmail.com>
parents:
302
diff
changeset
|
228 |
except soc.views.out_of_band.AccessViolationResponse, alt_response: |
294
1fdaab4a6ef2
Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
292
diff
changeset
|
229 |
return alt_response.response() |
1fdaab4a6ef2
Refactor existing code to use the new access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
292
diff
changeset
|
230 |
|
290
2a92b866ed40
Create a submit_buttons block in group edit profile template so that submit buttons can be customized. Replace submit_message usage with new notice block (still work in progress in Lookup User views). Add customized edit profile template for Sponsor with delete button (not used yet, upcoming commit). Add delete Sponsor request handler.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
278
diff
changeset
|
231 |
# create default template context for use with any templates |
2a92b866ed40
Create a submit_buttons block in group edit profile template so that submit buttons can be customized. Replace submit_message usage with new notice block (still work in progress in Lookup User views). Add customized edit profile template for Sponsor with delete button (not used yet, upcoming commit). Add delete Sponsor request handler.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
278
diff
changeset
|
232 |
context = helper.responses.getUniversalContext(request) |
2a92b866ed40
Create a submit_buttons block in group edit profile template so that submit buttons can be customized. Replace submit_message usage with new notice block (still work in progress in Lookup User views). Add customized edit profile template for Sponsor with delete button (not used yet, upcoming commit). Add delete Sponsor request handler.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
278
diff
changeset
|
233 |
|
2a92b866ed40
Create a submit_buttons block in group edit profile template so that submit buttons can be customized. Replace submit_message usage with new notice block (still work in progress in Lookup User views). Add customized edit profile template for Sponsor with delete button (not used yet, upcoming commit). Add delete Sponsor request handler.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
278
diff
changeset
|
234 |
existing_sponsor = None |
2a92b866ed40
Create a submit_buttons block in group edit profile template so that submit buttons can be customized. Replace submit_message usage with new notice block (still work in progress in Lookup User views). Add customized edit profile template for Sponsor with delete button (not used yet, upcoming commit). Add delete Sponsor request handler.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
278
diff
changeset
|
235 |
|
298
c76a366c7ab4
Replace almost all occurences of linkname with link_name
Sverre Rabbelier <srabbelier@gmail.com>
parents:
294
diff
changeset
|
236 |
# try to fetch Sponsor entity corresponding to link_name if one exists |
290
2a92b866ed40
Create a submit_buttons block in group edit profile template so that submit buttons can be customized. Replace submit_message usage with new notice block (still work in progress in Lookup User views). Add customized edit profile template for Sponsor with delete button (not used yet, upcoming commit). Add delete Sponsor request handler.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
278
diff
changeset
|
237 |
try: |
309
7190b224c701
Made the existing code use the new soc.logic.models
Sverre Rabbelier <srabbelier@gmail.com>
parents:
303
diff
changeset
|
238 |
existing_sponsor = models.sponsor.logic.getIfFields(link_name=link_name) |
290
2a92b866ed40
Create a submit_buttons block in group edit profile template so that submit buttons can be customized. Replace submit_message usage with new notice block (still work in progress in Lookup User views). Add customized edit profile template for Sponsor with delete button (not used yet, upcoming commit). Add delete Sponsor request handler.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
278
diff
changeset
|
239 |
except out_of_band.ErrorResponse, error: |
2a92b866ed40
Create a submit_buttons block in group edit profile template so that submit buttons can be customized. Replace submit_message usage with new notice block (still work in progress in Lookup User views). Add customized edit profile template for Sponsor with delete button (not used yet, upcoming commit). Add delete Sponsor request handler.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
278
diff
changeset
|
240 |
# show custom 404 page when link name doesn't exist in Datastore |
2a92b866ed40
Create a submit_buttons block in group edit profile template so that submit buttons can be customized. Replace submit_message usage with new notice block (still work in progress in Lookup User views). Add customized edit profile template for Sponsor with delete button (not used yet, upcoming commit). Add delete Sponsor request handler.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
278
diff
changeset
|
241 |
error.message = error.message + DEF_CREATE_NEW_SPONSOR_MSG |
361
465e4df617de
Make page argument required for errorResponse and requestLogin functions in simple.py and update affected files. Some keyword argument changes to in user/profile.py. All the changes are based on comments to r817.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
360
diff
changeset
|
242 |
return simple.errorResponse(request, page, error, template, context) |
290
2a92b866ed40
Create a submit_buttons block in group edit profile template so that submit buttons can be customized. Replace submit_message usage with new notice block (still work in progress in Lookup User views). Add customized edit profile template for Sponsor with delete button (not used yet, upcoming commit). Add delete Sponsor request handler.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
278
diff
changeset
|
243 |
|
2a92b866ed40
Create a submit_buttons block in group edit profile template so that submit buttons can be customized. Replace submit_message usage with new notice block (still work in progress in Lookup User views). Add customized edit profile template for Sponsor with delete button (not used yet, upcoming commit). Add delete Sponsor request handler.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
278
diff
changeset
|
244 |
if existing_sponsor: |
302
3b9c52170f46
Fix not working delete Sponsor functionality after recent commit. Add delete() method to Base class. Make soc.views.site.sponsor.delete() request handler use this method.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
299
diff
changeset
|
245 |
# TODO(pawel.solyga): Create specific delete method for Sponsor model |
3b9c52170f46
Fix not working delete Sponsor functionality after recent commit. Add delete() method to Base class. Make soc.views.site.sponsor.delete() request handler use this method.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
299
diff
changeset
|
246 |
# Check if Sponsor can be deleted (has no Hosts and Programs) |
309
7190b224c701
Made the existing code use the new soc.logic.models
Sverre Rabbelier <srabbelier@gmail.com>
parents:
303
diff
changeset
|
247 |
models.sponsor.logic.delete(existing_sponsor) |
290
2a92b866ed40
Create a submit_buttons block in group edit profile template so that submit buttons can be customized. Replace submit_message usage with new notice block (still work in progress in Lookup User views). Add customized edit profile template for Sponsor with delete button (not used yet, upcoming commit). Add delete Sponsor request handler.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
278
diff
changeset
|
248 |
|
2a92b866ed40
Create a submit_buttons block in group edit profile template so that submit buttons can be customized. Replace submit_message usage with new notice block (still work in progress in Lookup User views). Add customized edit profile template for Sponsor with delete button (not used yet, upcoming commit). Add delete Sponsor request handler.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
278
diff
changeset
|
249 |
return http.HttpResponseRedirect('/site/sponsor/list') |