author | Sverre Rabbelier <srabbelier@gmail.com> |
Sat, 06 Dec 2008 11:53:26 +0000 | |
changeset 675 | 14958011dceb |
parent 671 | 2c02178037ff |
child 680 | 7f047b2a2d3a |
permissions | -rw-r--r-- |
643 | 1 |
#!/usr/bin/python2.5 |
2 |
# |
|
3 |
# Copyright 2008 the Melange authors. |
|
4 |
# |
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
|
6 |
# you may not use this file except in compliance with the License. |
|
7 |
# You may obtain a copy of the License at |
|
8 |
# |
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
|
10 |
# |
|
11 |
# Unless required by applicable law or agreed to in writing, software |
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 |
# See the License for the specific language governing permissions and |
|
15 |
# limitations under the License. |
|
16 |
||
17 |
"""Views for Programs. |
|
18 |
""" |
|
19 |
||
20 |
__authors__ = [ |
|
21 |
'"Sverre Rabbelier" <sverre@rabbelier.nl>', |
|
22 |
] |
|
23 |
||
24 |
||
25 |
from google.appengine.api import users |
|
26 |
||
27 |
from django import forms |
|
28 |
from django.utils.translation import ugettext_lazy |
|
29 |
||
666
b9b0506efe8d
Fix import sorting and docstring typos in soc.views.models.program module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
663
diff
changeset
|
30 |
from soc.logic import cleaning |
643 | 31 |
from soc.logic import dicts |
32 |
from soc.logic.models import sponsor as sponsor_logic |
|
666
b9b0506efe8d
Fix import sorting and docstring typos in soc.views.models.program module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
663
diff
changeset
|
33 |
from soc.views import helper |
643 | 34 |
from soc.views.helper import redirects |
35 |
from soc.views.models import base |
|
36 |
from soc.views.models import sponsor as sponsor_view |
|
37 |
||
38 |
import soc.logic.models.program |
|
39 |
||
40 |
||
41 |
class View(base.View): |
|
666
b9b0506efe8d
Fix import sorting and docstring typos in soc.views.models.program module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
663
diff
changeset
|
42 |
"""View methods for the Program model. |
643 | 43 |
""" |
44 |
||
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
653
diff
changeset
|
45 |
def __init__(self, params=None): |
643 | 46 |
"""Defines the fields and methods required for the base View class |
47 |
to provide the user with list, public, create, edit and delete views. |
|
48 |
||
49 |
Params: |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
653
diff
changeset
|
50 |
params: a dict with params for this View |
643 | 51 |
""" |
52 |
||
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
653
diff
changeset
|
53 |
new_params = {} |
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
653
diff
changeset
|
54 |
new_params['logic'] = soc.logic.models.program.logic |
643 | 55 |
|
662
0e89b027b140
Make use of the new generic key_name by lookup up scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
660
diff
changeset
|
56 |
new_params['scope_view'] = sponsor_view |
0e89b027b140
Make use of the new generic key_name by lookup up scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
660
diff
changeset
|
57 |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
653
diff
changeset
|
58 |
new_params['name'] = "Program" |
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
653
diff
changeset
|
59 |
new_params['name_short'] = "Program" |
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
653
diff
changeset
|
60 |
new_params['name_plural'] = "Programs" |
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
653
diff
changeset
|
61 |
new_params['url_name'] = "program" |
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
653
diff
changeset
|
62 |
new_params['module_name'] = "program" |
643 | 63 |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
653
diff
changeset
|
64 |
new_params['extra_dynaexclude'] = ['home'] |
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
653
diff
changeset
|
65 |
new_params['create_extra_dynafields'] = { |
649 | 66 |
'description': forms.fields.CharField(widget=helper.widgets.TinyMCE( |
668
77f9a6ea6e67
Some style and typo fixes in different modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
666
diff
changeset
|
67 |
attrs={'rows':10, 'cols':40})), |
77f9a6ea6e67
Some style and typo fixes in different modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
666
diff
changeset
|
68 |
'scope_path': forms.CharField(widget=forms.HiddenInput, required=True), |
649 | 69 |
'clean_link_id': cleaning.clean_link_id, |
643 | 70 |
} |
71 |
||
660
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
659
diff
changeset
|
72 |
new_params['extra_django_patterns'] = [ |
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
659
diff
changeset
|
73 |
(r'^%(url_name)s/create/(?P<scope_path>%(ulnp)s)$', |
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
659
diff
changeset
|
74 |
'soc.views.models.%(module_name)s.create', 'Create %(name_short)s')] |
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
659
diff
changeset
|
75 |
|
663
c2dcae606699
Make base.View.create lookup the scope if appropriate
Sverre Rabbelier <srabbelier@gmail.com>
parents:
662
diff
changeset
|
76 |
new_params['scope_redirect'] = redirects.getCreateRedirect |
c2dcae606699
Make base.View.create lookup the scope if appropriate
Sverre Rabbelier <srabbelier@gmail.com>
parents:
662
diff
changeset
|
77 |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
653
diff
changeset
|
78 |
params = dicts.merge(params, new_params) |
643 | 79 |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
653
diff
changeset
|
80 |
super(View, self).__init__(params=params) |
643 | 81 |
|
647
355ac73823a1
Swap order of merged params to fix sponsor select view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
643
diff
changeset
|
82 |
|
643 | 83 |
view = View() |
84 |
||
85 |
create = view.create |
|
86 |
delete = view.delete |
|
87 |
edit = view.edit |
|
88 |
list = view.list |
|
89 |
public = view.public |