author | Sverre Rabbelier <srabbelier@gmail.com> |
Sun, 07 Dec 2008 13:49:22 +0000 | |
changeset 697 | 190b65431579 |
parent 681 | 48983ecf4665 |
child 700 | 8baf8367340d |
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 |
681
48983ecf4665
Cleanups in group and program
Sverre Rabbelier <srabbelier@gmail.com>
parents:
680
diff
changeset
|
57 |
new_params['scope_redirect'] = redirects.getCreateRedirect |
662
0e89b027b140
Make use of the new generic key_name by lookup up scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
660
diff
changeset
|
58 |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
653
diff
changeset
|
59 |
new_params['name'] = "Program" |
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
653
diff
changeset
|
60 |
new_params['name_short'] = "Program" |
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
653
diff
changeset
|
61 |
new_params['name_plural'] = "Programs" |
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
653
diff
changeset
|
62 |
new_params['url_name'] = "program" |
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
653
diff
changeset
|
63 |
new_params['module_name'] = "program" |
643 | 64 |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
653
diff
changeset
|
65 |
new_params['extra_dynaexclude'] = ['home'] |
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
653
diff
changeset
|
66 |
new_params['create_extra_dynafields'] = { |
649 | 67 |
'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
|
68 |
attrs={'rows':10, 'cols':40})), |
77f9a6ea6e67
Some style and typo fixes in different modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
666
diff
changeset
|
69 |
'scope_path': forms.CharField(widget=forms.HiddenInput, required=True), |
649 | 70 |
'clean_link_id': cleaning.clean_link_id, |
643 | 71 |
} |
72 |
||
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
653
diff
changeset
|
73 |
params = dicts.merge(params, new_params) |
643 | 74 |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
653
diff
changeset
|
75 |
super(View, self).__init__(params=params) |
643 | 76 |
|
647
355ac73823a1
Swap order of merged params to fix sponsor select view
Sverre Rabbelier <srabbelier@gmail.com>
parents:
643
diff
changeset
|
77 |
|
643 | 78 |
view = View() |
79 |
||
80 |
create = view.create |
|
81 |
delete = view.delete |
|
82 |
edit = view.edit |
|
83 |
list = view.list |
|
84 |
public = view.public |