author | Sverre Rabbelier <srabbelier@gmail.com> |
Sun, 19 Oct 2008 00:34:33 +0000 | |
changeset 387 | c55195361cb6 |
parent 363 | d35ffa6ca643 |
child 389 | 9b873166d7d5 |
permissions | -rw-r--r-- |
363
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
2 |
# |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
4 |
# |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
8 |
# |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
10 |
# |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
16 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
17 |
"""Views for Sponsor profiles. |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
18 |
""" |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
19 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
21 |
'"Sverre Rabbelier" <sverer@rabbelier.nl>', |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
22 |
'"Pawel Solyga" <pawel.solyga@gmail.com>', |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
23 |
] |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
24 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
25 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
26 |
from google.appengine.api import users |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
27 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
28 |
from django import forms |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
29 |
from django.utils.translation import ugettext_lazy |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
30 |
|
387
c55195361cb6
Addressed comments by Todd on r822
Sverre Rabbelier <srabbelier@gmail.com>
parents:
363
diff
changeset
|
31 |
from soc.logic import dicts |
363
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
32 |
from soc.logic import validate |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
33 |
from soc.views import helper |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
34 |
from soc.views.helper import widgets |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
35 |
from soc.views.models import base |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
36 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
37 |
import soc.models.sponsor |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
38 |
import soc.logic.models.sponsor |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
39 |
import soc.logic.dicts |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
40 |
import soc.views.helper |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
41 |
import soc.views.helper.widgets |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
42 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
43 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
44 |
class CreateForm(helper.forms.DbModelForm): |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
45 |
"""Django form displayed when creating a Sponsor. |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
46 |
""" |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
47 |
class Meta: |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
48 |
"""Inner Meta class that defines some behavior for the form. |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
49 |
""" |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
50 |
#: db.Model subclass for which the form will gather information |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
51 |
model = soc.models.sponsor.Sponsor |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
52 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
53 |
#: list of model fields which will *not* be gathered by the form |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
54 |
exclude = ['founder', 'inheritance_line'] |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
55 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
56 |
# TODO(pawel.solyga): write validation functions for other fields |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
57 |
def clean_link_name(self): |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
58 |
link_name = self.cleaned_data.get('link_name') |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
59 |
if not validate.isLinkNameFormatValid(link_name): |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
60 |
raise forms.ValidationError("This link name is in wrong format.") |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
61 |
if models.sponsor.logic.getFromFields(link_name=link_name): |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
62 |
raise forms.ValidationError("This link name is already in use.") |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
63 |
return link_name |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
64 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
65 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
66 |
class EditForm(CreateForm): |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
67 |
"""Django form displayed when editing a Sponsor. |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
68 |
""" |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
69 |
link_name = forms.CharField(widget=helper.widgets.ReadOnlyInput()) |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
70 |
founded_by = forms.CharField(widget=helper.widgets.ReadOnlyInput(), |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
71 |
required=False) |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
72 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
73 |
def clean_link_name(self): |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
74 |
link_name = self.cleaned_data.get('link_name') |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
75 |
if not validate.isLinkNameFormatValid(link_name): |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
76 |
raise forms.ValidationError("This link name is in wrong format.") |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
77 |
return link_name |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
78 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
79 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
80 |
class View(base.View): |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
81 |
"""View methods for the Sponsor model |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
82 |
""" |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
83 |
|
387
c55195361cb6
Addressed comments by Todd on r822
Sverre Rabbelier <srabbelier@gmail.com>
parents:
363
diff
changeset
|
84 |
SUBMIT_MSG_PROFILE_SAVED = 0 |
c55195361cb6
Addressed comments by Todd on r822
Sverre Rabbelier <srabbelier@gmail.com>
parents:
363
diff
changeset
|
85 |
|
363
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
86 |
def __init__(self, original_params=None, original_rights=None): |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
87 |
"""Defines the fields and methods required for the base View class |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
88 |
to provide the user with list, public, create, edit and delete views. |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
89 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
90 |
Params: |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
91 |
original_params: a dict with params for this View |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
92 |
original_rights: a dict with right definitions for this View |
387
c55195361cb6
Addressed comments by Todd on r822
Sverre Rabbelier <srabbelier@gmail.com>
parents:
363
diff
changeset
|
93 |
""" |
363
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
94 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
95 |
self._logic = soc.logic.models.sponsor.logic |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
96 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
97 |
params = {} |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
98 |
rights = {} |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
99 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
100 |
params['name'] = "Sponsor" |
387
c55195361cb6
Addressed comments by Todd on r822
Sverre Rabbelier <srabbelier@gmail.com>
parents:
363
diff
changeset
|
101 |
params['name_short'] = "Sponsor" |
363
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
102 |
params['name_plural'] = "Sponsors" |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
103 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
104 |
params['edit_form'] = EditForm |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
105 |
params['create_form'] = CreateForm |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
106 |
|
387
c55195361cb6
Addressed comments by Todd on r822
Sverre Rabbelier <srabbelier@gmail.com>
parents:
363
diff
changeset
|
107 |
# TODO(tlarsen) Add support for Django style template lookup |
c55195361cb6
Addressed comments by Todd on r822
Sverre Rabbelier <srabbelier@gmail.com>
parents:
363
diff
changeset
|
108 |
params['edit_template'] = 'soc/site/sponsor/profile/edit.html' |
363
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
109 |
params['public_template'] = 'soc/group/profile/public.html' |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
110 |
params['list_template'] = 'soc/group/list/all.html' |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
111 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
112 |
params['lists_template'] = { |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
113 |
'list_main': 'soc/list/list_main.html', |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
114 |
'list_pagination': 'soc/list/list_pagination.html', |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
115 |
'list_row': 'soc/group/list/group_row.html', |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
116 |
'list_heading': 'soc/group/list/group_heading.html', |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
117 |
} |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
118 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
119 |
params['delete_redirect'] = '/site/sponsor/list' |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
120 |
params['create_redirect'] = '/site/sponsor/profile' |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
121 |
|
387
c55195361cb6
Addressed comments by Todd on r822
Sverre Rabbelier <srabbelier@gmail.com>
parents:
363
diff
changeset
|
122 |
params['save_message'] = [ugettext_lazy('Profile saved.')] |
363
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
123 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
124 |
params['edit_params'] = { |
387
c55195361cb6
Addressed comments by Todd on r822
Sverre Rabbelier <srabbelier@gmail.com>
parents:
363
diff
changeset
|
125 |
DEF_SUBMIT_MSG_PARAM_NAME: SUBMIT_MSG_PROFILE_SAVED, |
363
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
126 |
} |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
127 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
128 |
rights['list'] = [helper.access.checkIsDeveloper] |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
129 |
rights['delete'] = [helper.access.checkIsDeveloper] |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
130 |
|
387
c55195361cb6
Addressed comments by Todd on r822
Sverre Rabbelier <srabbelier@gmail.com>
parents:
363
diff
changeset
|
131 |
params = dicts.merge(original_params, params) |
c55195361cb6
Addressed comments by Todd on r822
Sverre Rabbelier <srabbelier@gmail.com>
parents:
363
diff
changeset
|
132 |
rights = dicts.merge(original_rights, rights) |
363
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
133 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
134 |
base.View.__init__(self, rights=rights, params=params) |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
135 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
136 |
def _editPost(self, request, entity, fields): |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
137 |
""" |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
138 |
""" |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
139 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
140 |
id = users.get_current_user() |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
141 |
user = soc.logic.models.user.logic.getFromFields(email=id.email()) |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
142 |
fields['founder'] = user |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
143 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
144 |
|
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
145 |
view = View() |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
146 |
public = view.public |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
147 |
list = view.list |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
148 |
delete = view.delete |
d35ffa6ca643
Add a framework for generic views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
149 |
edit = view.edit |