app/soc/views/models/program.py
changeset 2076 1cd180cc56c9
parent 2064 031406b4789d
child 2080 6c4cf7ae18d8
equal deleted inserted replaced
2075:c6bdfd560d91 2076:1cd180cc56c9
    25 
    25 
    26 import os
    26 import os
    27 
    27 
    28 from django import forms
    28 from django import forms
    29 from django import http
    29 from django import http
    30 from django.utils import simplejson
       
    31 from django.utils.translation import ugettext
    30 from django.utils.translation import ugettext
    32 
    31 
    33 from soc.logic import allocations
    32 from soc.logic import allocations
    34 from soc.logic import cleaning
    33 from soc.logic import cleaning
    35 from soc.logic import dicts
    34 from soc.logic import dicts
    40 from soc.logic.models import org_admin as org_admin_logic
    39 from soc.logic.models import org_admin as org_admin_logic
    41 from soc.logic.models import org_app as org_app_logic
    40 from soc.logic.models import org_app as org_app_logic
    42 from soc.logic.models import student_proposal as student_proposal_logic
    41 from soc.logic.models import student_proposal as student_proposal_logic
    43 from soc.logic.models import program as program_logic
    42 from soc.logic.models import program as program_logic
    44 from soc.logic.models import student as student_logic
    43 from soc.logic.models import student as student_logic
    45 from soc.logic.models.document import logic as document_logic
       
    46 from soc.views import helper
    44 from soc.views import helper
    47 from soc.views import out_of_band
    45 from soc.views import out_of_band
    48 from soc.views.helper import access
    46 from soc.views.helper import access
    49 from soc.views.helper import decorators
    47 from soc.views.helper import decorators
    50 from soc.views.helper import lists
    48 from soc.views.helper import lists
   263       request: the standard Django HTTP request object
   261       request: the standard Django HTTP request object
   264       access_type : the name of the access type which should be checked
   262       access_type : the name of the access type which should be checked
   265       page_name: the page name displayed in templates as page and header title
   263       page_name: the page name displayed in templates as page and header title
   266       params: a dict with params for this View, not used
   264       params: a dict with params for this View, not used
   267     """
   265     """
       
   266     
       
   267     from django.utils import simplejson
   268 
   268 
   269     program = program_logic.logic.getFromKeyFieldsOr404(kwargs)
   269     program = program_logic.logic.getFromKeyFieldsOr404(kwargs)
   270     slots = program.slots
   270     program_slots = program.slots
   271 
   271 
   272     filter = {
   272     filter = {
   273           'scope': program,
   273           'scope': program,
   274           'status': 'active',
   274           'status': 'active',
   275           }
   275           }
   306     max_slots_per_org = 40
   306     max_slots_per_org = 40
   307     min_slots_per_org = 2
   307     min_slots_per_org = 2
   308     iterative = False
   308     iterative = False
   309 
   309 
   310     allocator = allocations.Allocator(orgs.keys(), applications, mentors,
   310     allocator = allocations.Allocator(orgs.keys(), applications, mentors,
   311                                       slots, max_slots_per_org,
   311                                       program_slots, max_slots_per_org,
   312                                       min_slots_per_org, iterative)
   312                                       min_slots_per_org, iterative)
   313 
   313 
   314     result = allocator.allocate(locked_slots, adjusted_slots)
   314     result = allocator.allocate(locked_slots, adjusted_slots)
   315 
   315 
   316     data = []
   316     data = []
   367 
   367 
   368   @decorators.merge_params
   368   @decorators.merge_params
   369   @decorators.check_access
   369   @decorators.check_access
   370   def showDuplicates(self, request, access_type, page_name=None,
   370   def showDuplicates(self, request, access_type, page_name=None,
   371                      params=None, **kwargs):
   371                      params=None, **kwargs):
   372     """View in which a host can see which students have been assigned multiple slots.
   372     """View in which a host can see which students have been assigned 
       
   373        multiple slots.
   373 
   374 
   374     For params see base.view.Public().
   375     For params see base.view.Public().
   375     """
   376     """
   376 
   377 
   377     from django.utils import simplejson
   378     from django.utils import simplejson
   460 
   461 
   461     fields = {'scope': program_entity,
   462     fields = {'scope': program_entity,
   462               'slots >': 0,
   463               'slots >': 0,
   463               'status': 'active'}
   464               'status': 'active'}
   464 
   465 
   465     org_entities = org_logic.logic.getForFields(fields, limit=limit, offset=offset)
   466     org_entities = org_logic.logic.getForFields(fields, 
       
   467         limit=limit, offset=offset)
   466 
   468 
   467     orgs_data = {}
   469     orgs_data = {}
   468     proposals_data = []
   470     proposals_data = []
   469 
   471 
   470     # for each org get the proposals who will be assigned a slot
   472     # for each org get the proposals who will be assigned a slot
   642       # add the organization signup link
   644       # add the organization signup link
   643       items += [
   645       items += [
   644           (redirects.getApplyRedirect(program_entity, {'url_name': 'org_app'}),
   646           (redirects.getApplyRedirect(program_entity, {'url_name': 'org_app'}),
   645           "Apply to become an Organization", 'any_access')]
   647           "Apply to become an Organization", 'any_access')]
   646 
   648 
   647     if user and timeline_helper.isAfterEvent(timeline_entity, 'org_signup_start'):
   649     if user and timeline_helper.isAfterEvent(timeline_entity, 
       
   650         'org_signup_start'):
   648       filter = {
   651       filter = {
   649           'applicant': user,
   652           'applicant': user,
   650           'scope': program_entity,
   653           'scope': program_entity,
   651           }
   654           }
   652 
   655