Style fixes and removal of unused imports in soc.views.models.
[Melange.git] / app / soc / views / models / club_app.py
blob50e569be76430bc43b6fdca091c3190f92d13843
1 #!/usr/bin/python2.5
3 # Copyright 2009 the Melange authors.
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 """Views for Club App profiles.
18 """
20 __authors__ = [
21 '"Sverre Rabbelier" <sverre@rabbelier.nl>',
22 '"Lennard de Rijk" <ljvderijk@gmail.com>',
26 from django import forms
28 from soc.logic import cleaning
29 from soc.logic import dicts
30 from soc.logic import models as model_logic
31 from soc.logic.models import host as host_logic
32 from soc.logic.models import club_app as club_app_logic
33 from soc.views.helper import access
34 from soc.views.helper import decorators
35 from soc.views.models import group_app
38 class View(group_app.View):
39 """View methods for the Club Application model.
40 """
42 def __init__(self, params=None):
43 """Defines the fields and methods required for the base View class
44 to provide the user with list, public, create, edit and delete views.
46 Params:
47 params: a dict with params for this View
48 """
50 rights = access.Checker(params)
51 rights['create'] = ['checkIsUser']
52 rights['delete'] = ['checkIsDeveloper']
53 rights['edit'] = [('checkCanEditGroupApp',
54 [club_app_logic.logic])]
55 rights['list'] = ['checkIsDeveloper']
56 rights['list_self'] = ['checkIsUser']
57 rights['show'] = [('checkCanEditGroupApp',
58 [club_app_logic.logic])]
59 # TODO(ljvderijk) make sure host role check is fixed
60 rights['review'] = [('checkHasActiveRoleForScope', host_logic.logic),
61 ('checkCanReviewGroupApp', [club_app_logic.logic])]
62 rights['review_overview'] = [('checkHasActiveRoleForScope',
63 host_logic.logic)]
65 new_params = {}
67 new_params['rights'] = rights
68 new_params['logic'] = club_app_logic.logic
70 new_params['sidebar_grouping'] = 'Clubs'
72 new_params['create_dynafields'] = [
73 {'name': 'link_id',
74 'base': forms.fields.CharField,
75 'label': 'Club Link ID',
79 new_params['create_extra_dynaproperties'] = {
80 'clean': cleaning.validate_new_group('link_id', 'scope_path',
81 model_logic.club, club_app_logic)}
83 # get rid of the clean method
84 new_params['edit_extra_dynaproperties'] = {
85 'clean': (lambda x: x.cleaned_data)}
87 new_params['name'] = "Club Application"
88 new_params['name_plural'] = "Club Applications"
89 new_params['name_short'] = "Club App"
90 new_params['url_name'] = "club_app"
91 new_params['group_name'] = "Club"
92 new_params['group_url_name'] = 'club'
94 new_params['review_template'] = 'soc/club_app/review.html'
96 new_params['sidebar_additional'] = [
97 ('/%(url_name)s/list_self/' % new_params,
98 'List all my %(name_plural)s' % new_params, 'list_self'),
99 ('/%(url_name)s/review_overview/' % new_params,
100 'Review %(name_plural)s' % new_params, 'review_overview')]
102 params = dicts.merge(params, new_params)
104 super(View, self).__init__(params=params)
107 view = View()
109 admin = decorators.view(view.admin)
110 create = decorators.view(view.create)
111 delete = decorators.view(view.delete)
112 edit = decorators.view(view.edit)
113 list = decorators.view(view.list)
114 list_self = decorators.view(view.listSelf)
115 public = decorators.view(view.public)
116 export = decorators.view(view.export)
117 review = decorators.view(view.review)
118 review_overview = decorators.view(view.reviewOverview)