# HG changeset patch # User Lennard de Rijk # Date 1234532011 0 # Node ID 359987b7027d0d3d338e0219a055ede5da976024 # Parent d5ea34c4fc43e3ce5f4cba3b47f91976539f69ac Added bulk_accept view which returns a JSON object. This is going to be used to bulk accept org applications. Also added a new unfinished template so Merio can test his JS. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed diff -r d5ea34c4fc43 -r 359987b7027d app/soc/templates/soc/org_app/review_overview.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/soc/templates/soc/org_app/review_overview.html Fri Feb 13 13:33:31 2009 +0000 @@ -0,0 +1,18 @@ +{% extends "soc/models/list.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 body %} +If you want to accept all pre-accepted organizations please click < here >. +{{ block.super}} +{% endblock %} \ No newline at end of file diff -r d5ea34c4fc43 -r 359987b7027d app/soc/views/models/org_app.py --- a/app/soc/views/models/org_app.py Fri Feb 13 11:46:06 2009 +0000 +++ b/app/soc/views/models/org_app.py Fri Feb 13 13:33:31 2009 +0000 @@ -23,6 +23,7 @@ from django import forms +from django.utils import simplejson from soc.logic import cleaning from soc.logic import dicts @@ -32,6 +33,7 @@ from soc.views.helper import access from soc.views.helper import decorators from soc.views.helper import redirects +from soc.views.helper import responses from soc.views.helper import widgets from soc.views.models import group_app from soc.views.models import program as program_view @@ -66,6 +68,7 @@ rights['review'] = ['checkIsHostForProgramInScope', ('checkCanReviewGroupApp', [org_app_logic.logic])] rights['review_overview'] = ['checkIsHostForProgramInScope'] + rights['bulk_accept'] = ['checkIsHostForProgramInScope'] rights['apply'] = ['checkIsUser', ('checkCanCreateOrgApp', ['org_signup'])] @@ -81,7 +84,10 @@ patterns = [(r'^%(url_name)s/(?Papply)/%(scope)s$', 'soc.views.models.%(module_name)s.create', - 'Create an %(name_plural)s'),] + 'Create an %(name_plural)s'), + (r'^%(url_name)s/(?Pbulk_accept)/%(scope)s$', + 'soc.views.models.%(module_name)s.bulk_accept', + 'Bulk Acceptation of %(name_plural)s'),] new_params['extra_django_patterns'] = patterns new_params['extra_key_order'] = ['admin_agreement', @@ -118,6 +124,15 @@ super(View, self).__init__(params=params) + @ decorators.merge_params + def reviewOverview(self, request, access_type, + page_name=None, params=None, **kwargs): + + params['list_template'] = 'soc/org_app/review_overview.html' + + return super(View, self).reviewOverview(request, access_type, + page_name=page_name, params=params, **kwargs) + def _editContext(self, request, context): """See base.View._editContext. """ @@ -145,8 +160,43 @@ form.fields['admin_agreement'].widget.text = content + @decorators.merge_params + @decorators.check_access + def bulkAccept(self, request, access_type, + page_name=None, params=None, **kwargs): + """Returns a HTTP Response containing JSON information needed + to bulk-accept orgs. + """ + + program_entity = program_logic.logic.getFromKeyName(kwargs['scope_path']) + + # get all pre-accepted org applications for the given program + filter = {'scope' : program_entity, + 'status' : 'pre-accepted'} + org_app_entities = org_app_logic.logic.getForFields(filter=filter) + + # convert each application into a dictionary containing only the fields + # given by the dict_filter + dict_filter = ['link_id', 'name'] + org_apps = [dicts.filter(i.toDict(), dict_filter) for i in org_app_entities] + + to_json = { + 'program' : program_entity.name, + 'applications': org_apps, + } + + json = simplejson.dumps(to_json) + + # use the standard JSON template to return our response + context = {'json': json} + template = 'soc/json.html' + + return responses.respond(request, template, context) + + view = View() +bulk_accept = view.bulkAccept create = view.create delete = view.delete edit = view.edit