Changed label and help_text for public review button on studentproposal review page.
[Melange.git] / app / soc / views / models / club_admin.py
blobbd160b808aa0ea3f49bf8c5871609bbe0f6cde44
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 Admins.
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 dicts
29 from soc.logic.models import club as club_logic
30 from soc.logic.models import club_admin as club_admin_logic
31 from soc.views.helper import access
32 from soc.views.helper import decorators
33 from soc.views.helper import dynaform
34 from soc.views.helper import widgets
35 from soc.views.models import club as club_view
36 from soc.views.models import role
38 import soc.logic.models.club_admin
41 class View(role.View):
42 """View methods for the Club Admin model.
43 """
45 def __init__(self, params=None):
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.
49 Params:
50 params: a dict with params for this View
51 """
53 rights = access.Checker(params)
54 rights['create'] = ['checkIsDeveloper']
55 rights['edit'] = [('checkHasActiveRoleForScope', club_admin_logic.logic),
56 ('checkIsMyEntity', [club_admin_logic.logic, 'user', True])]
57 rights['delete'] = ['checkIsDeveloper']
58 rights['invite'] = [('checkHasActiveRoleForScope', club_admin_logic.logic)]
59 rights['accept_invite'] = [('checkCanCreateFromRequest', 'club_admin')]
60 rights['process_request'] = [('checkHasActiveRoleForScope',
61 club_admin_logic.logic),
62 ('checkCanProcessRequest', 'club_admin')]
63 rights['manage'] = [('checkIsAllowedToManageRole',
64 [club_admin_logic.logic,
65 club_admin_logic.logic])]
67 new_params = {}
68 new_params['logic'] = soc.logic.models.club_admin.logic
69 new_params['group_logic'] = club_logic.logic
70 new_params['group_view'] = club_view.view
71 new_params['rights'] = rights
73 new_params['scope_view'] = club_view
75 new_params['name'] = "Club Admin"
76 new_params['sidebar_grouping'] = 'Clubs'
78 new_params['extra_dynaexclude'] = ['agreed_to_tos']
80 new_params['allow_invites'] = True
81 new_params['show_in_roles_overview'] = False
83 params = dicts.merge(params, new_params)
85 super(View, self).__init__(params=params)
87 # register the role with the group_view
88 params['group_view'].registerRole(params['module_name'], self)
90 # create and store the special form for invited users
91 updated_fields = {
92 'link_id': forms.CharField(widget=widgets.ReadOnlyInput(),
93 required=False)}
95 invited_create_form = dynaform.extendDynaForm(
96 dynaform = self._params['create_form'],
97 dynaproperties = updated_fields)
99 params['invited_create_form'] = invited_create_form
101 def _editPost(self, request, entity, fields):
102 """See base.View._editPost().
104 if not entity:
105 fields['user'] = fields['link_id']
106 fields['link_id'] = fields['user'].link_id
108 super(View, self)._editPost(request, entity, fields)
110 def _acceptInvitePost(self, fields, request, context, params, **kwargs):
111 """Fills in the fields that were missing in the invited_created_form.
113 For params see base.View._acceptInvitePost()
115 # fill in the appropriate fields that were missing in the form
116 fields['user'] = fields['link_id']
117 fields['link_id'] = fields['user'].link_id
120 view = View()
122 accept_invite = decorators.view(view.acceptInvite)
123 admin = decorators.view(view.admin)
124 create = decorators.view(view.create)
125 delete = decorators.view(view.delete)
126 edit = decorators.view(view.edit)
127 invite = decorators.view(view.invite)
128 list = decorators.view(view.list)
129 manage = decorators.view(view.manage)
130 process_request = decorators.view(view.processRequest)
131 public = decorators.view(view.public)
132 export = decorators.view(view.export)