Added manage view for Club Admins, Club Members and Hosts.
Patch by: Lennard de Rijk
Reviewed by: to-be-reviewed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/club_admin/manage.html Thu Jan 29 18:13:21 2009 +0000
@@ -0,0 +1,28 @@
+{% extends "soc/club_admin/public.html" %}
+{% comment %}
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+{% endcomment %}
+
+{% block header_title %}
+{{ page_name }} {{ entity.link_id }} for {{ entity.scope_path }}
+{% endblock %}
+
+{% block manage %}
+<tr>
+ <td>
+ Please select the appropriate action:</br>
+ <input type="button" onclick="location.href='/{{ url_name }}/manage/{{ entity.scope_path }}/{{ entity.link_id }}?resign=true'" value="Resign"/>
+ <input type="button" onclick="location.href='{{ cancel_redirect }}'" value="Cancel"/>
+ </td>
+</tr>
+{% endblock %}
--- a/app/soc/templates/soc/club_admin/public.html Thu Jan 29 18:11:11 2009 +0000
+++ b/app/soc/templates/soc/club_admin/public.html Thu Jan 29 18:13:21 2009 +0000
@@ -27,4 +27,5 @@
{% readonly_field_as_table_row entity.fields.res_country.label entity.res_country %}
</table>
</p>
+{% block manage %} {% endblock %}
{% endblock %}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/club_member/manage.html Thu Jan 29 18:13:21 2009 +0000
@@ -0,0 +1,28 @@
+{% extends "soc/club_member/public.html" %}
+{% comment %}
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+{% endcomment %}
+
+{% block header_title %}
+{{ page_name }} {{ entity.link_id }} for {{ entity.scope_path }}
+{% endblock %}
+
+{% block manage %}
+<tr>
+ <td>
+ Please select the appropriate action:</br>
+ <input type="button" onclick="location.href='/{{ url_name }}/manage/{{ entity.scope_path }}/{{ entity.link_id }}?resign=true'" value="Resign"/>
+ <input type="button" onclick="location.href='{{ cancel_redirect }}'" value="Cancel"/>
+ </td>
+</tr>
+{% endblock %}
--- a/app/soc/templates/soc/club_member/public.html Thu Jan 29 18:11:11 2009 +0000
+++ b/app/soc/templates/soc/club_member/public.html Thu Jan 29 18:13:21 2009 +0000
@@ -26,5 +26,6 @@
{% readonly_field_as_table_row entity.fields.im_handle.label entity.im_handle %}
{% readonly_field_as_table_row entity.fields.res_country.label entity.res_country %}
</table>
-</p>
+</p>`
+{% block manage %} {% endblock %}
{% endblock %}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/host/manage.html Thu Jan 29 18:13:21 2009 +0000
@@ -0,0 +1,28 @@
+{% extends "soc/host/public.html" %}
+{% comment %}
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+{% endcomment %}
+
+{% block header_title %}
+{{ page_name }} {{ entity.link_id }} for {{ entity.scope_path }}
+{% endblock %}
+
+{% block manage %}
+<tr>
+ <td>
+ Please select the appropriate action:</br>
+ <input type="button" onclick="location.href='/{{ url_name }}/manage/{{ entity.scope_path }}/{{ entity.link_id }}?resign=true'" value="Resign"/>
+ <input type="button" onclick="location.href='{{ cancel_redirect }}'" value="Cancel"/>
+ </td>
+</tr>
+{% endblock %}
--- a/app/soc/templates/soc/host/public.html Thu Jan 29 18:11:11 2009 +0000
+++ b/app/soc/templates/soc/host/public.html Thu Jan 29 18:13:21 2009 +0000
@@ -27,4 +27,5 @@
<!-- TODO(pawel.solyga) make this generic -->
</table>
</p>
+{% block manage %} {% endblock %}
{% endblock %}
--- a/app/soc/views/models/club_admin.py Thu Jan 29 18:11:11 2009 +0000
+++ b/app/soc/views/models/club_admin.py Thu Jan 29 18:13:21 2009 +0000
@@ -57,6 +57,9 @@
rights['accept_invite'] = [('checkCanCreateFromRequest', 'club_admin')]
rights['process_request'] = ['checkIsClubAdminForClub',
('checkCanProcessRequest', 'club_admin')]
+ rights['manage'] = [
+ ('checkIsAllowedToManageRole', [soc.logic.models.club_admin,
+ soc.logic.models.club_admin])]
new_params = {}
new_params['logic'] = soc.logic.models.club_admin.logic
@@ -126,6 +129,7 @@
edit = view.edit
invite = view.invite
list = view.list
+manage = view.manage
process_request = view.processRequest
public = view.public
export = view.export
--- a/app/soc/views/models/club_member.py Thu Jan 29 18:11:11 2009 +0000
+++ b/app/soc/views/models/club_member.py Thu Jan 29 18:13:21 2009 +0000
@@ -34,6 +34,7 @@
from soc.views.models import role
import soc.logic.models.club_member
+import soc.logic.models.club_admin
class View(role.View):
@@ -58,6 +59,9 @@
('checkCanMakeRequestToGroup', club_logic)]
rights['process_request'] = ['checkIsClubAdminForClub',
('checkCanProcessRequest','club_member')]
+ rights['manage'] = [
+ ('checkIsAllowedToManageRole', [soc.logic.models.club_member,
+ soc.logic.models.club_admin])]
new_params = {}
new_params['logic'] = soc.logic.models.club_member.logic
@@ -128,6 +132,7 @@
edit = view.edit
invite = view.invite
list = view.list
+manage = view.manage
process_request = view.processRequest
request = view.request
public = view.public
--- a/app/soc/views/models/host.py Thu Jan 29 18:11:11 2009 +0000
+++ b/app/soc/views/models/host.py Thu Jan 29 18:13:21 2009 +0000
@@ -63,6 +63,9 @@
rights['accept_invite'] = [('checkCanCreateFromRequest','host')]
rights['process_request'] = ['checkIsHost',
('checkCanProcessRequest','host')]
+ rights['manage'] = [
+ ('checkIsAllowedToManageRole', [soc.logic.models.host,
+ soc.logic.models.host])]
new_params = {}
new_params['rights'] = rights
@@ -135,6 +138,7 @@
edit = view.edit
invite = view.invite
list = view.list
+manage = view.manage
process_request = view.processRequest
public = view.public
export = view.export
--- a/app/soc/views/models/role.py Thu Jan 29 18:11:11 2009 +0000
+++ b/app/soc/views/models/role.py Thu Jan 29 18:13:21 2009 +0000
@@ -92,6 +92,11 @@
'soc.views.models.%(module_name)s.process_request',
'Process request for %(name)s')]
+ # add manage pattern
+ patterns += [(r'^%(url_name)s/(?P<access_type>manage)/%(scope)s/%(lnp)s$',
+ 'soc.views.models.%(module_name)s.manage',
+ 'Manage a %(name)s'),]
+
new_params['extra_django_patterns'] = patterns
new_params['scope_redirect'] = redirects.getInviteRedirect
@@ -99,6 +104,9 @@
super(View, self).__init__(params=params)
+ # add manage template
+ params['manage_template'] = 'soc/%(module_name)s/manage.html' % params
+
@decorators.merge_params
@decorators.check_access
def invite(self, request, access_type,
@@ -325,9 +333,62 @@
@decorators.merge_params
@decorators.check_access
+ def manage(self, request, access_type,
+ page_name=None, params=None, **kwargs):
+ """Handles the request concerning the view that let's
+ you manage a role's state.
+
+ Args:
+ request: the standard Django HTTP request object
+ page_name: the page name displayed in templates as page and header title
+ params: a dict with params for this View
+ kwargs: the Key Fields for the specified entity
+ """
+
+ # get the context for this webpage
+ context = responses.getUniversalContext(request)
+ context['page_name'] = page_name
+
+ logic = params['logic']
+
+ # get the entity for the given fields in kwargs
+ fields = {'scope_path': kwargs['scope_path'],
+ 'link_id': kwargs['link_id']}
+ role_entity = logic.getForFields(kwargs, unique=True)
+
+ # get the redirect for the cancel button or when the resignation is done
+ redirect = redirects.getListRolesRedirect(role_entity.scope,
+ params['group_view'].getParams())
+
+ # check to see if resign is true
+ get_dict = request.GET
+ resign = get_dict.get('resign')
+
+ if resign == 'true':
+ # change the state of this role_entity to invalid
+ fields = {'state': 'invalid'}
+ logic.updateEntityProperties(role_entity, fields)
+
+ # redirect to the roles listing
+ return http.HttpResponseRedirect(redirect)
+
+ # set the appropriate context
+ context['entity'] = role_entity
+ context['url_name'] = params['url_name']
+ context['cancel_redirect'] = redirect
+
+ # get the manage template
+ template = params['manage_template']
+
+ # return a proper response
+ return responses.respond(request, template, context=context)
+
+
+ @decorators.merge_params
+ @decorators.check_access
def request(self, request, access_type,
page_name=None, params=None, **kwargs):
- """Handles the GET request concerning the view that creates a request
+ """Handles the request concerning the view that creates a request
for attaining a certain Role.
Args: