app/soc/views/models/program.py
changeset 2004 4d9e41c947fd
parent 1996 ae53f21abb9b
child 2055 b4375ec63de5
equal deleted inserted replaced
2003:ed24a0bd19d9 2004:4d9e41c947fd
   378 
   378 
   379     program_entity = program_logic.logic.getFromKeyFieldsOr404(kwargs)
   379     program_entity = program_logic.logic.getFromKeyFieldsOr404(kwargs)
   380 
   380 
   381     context = helper.responses.getUniversalContext(request)
   381     context = helper.responses.getUniversalContext(request)
   382     helper.responses.useJavaScript(context, params['js_uses_all'])
   382     helper.responses.useJavaScript(context, params['js_uses_all'])
       
   383     context['uses_duplicates'] = True
       
   384     context['uses_json'] = True
   383     context['page_name'] = page_name
   385     context['page_name'] = page_name
   384 
   386 
   385     # get all orgs for this program who are active and have slots assigned
   387     # get all orgs for this program who are active and have slots assigned
   386     fields = {'scope': program_entity,
   388     fields = {'scope': program_entity,
   387               'slots >': 0,
   389               'slots >': 0,
   395     json = simplejson.dumps(to_json)
   397     json = simplejson.dumps(to_json)
   396     context['info'] = json
   398     context['info'] = json
   397 
   399 
   398     # TODO(ljvderijk) cache the result of the duplicate calculation
   400     # TODO(ljvderijk) cache the result of the duplicate calculation
   399     context['duplicate_cache_content'] = simplejson.dumps({})
   401     context['duplicate_cache_content'] = simplejson.dumps({})
       
   402     context['offset_length'] = 10
   400 
   403 
   401     template = 'soc/program/show_duplicates.html'
   404     template = 'soc/program/show_duplicates.html'
   402 
   405 
   403     return helper.responses.respond(request, template=template, context=context)
   406     return helper.responses.respond(request, template=template, context=context)
   404 
   407 
   458       # check if there are already slots taken by this org
   461       # check if there are already slots taken by this org
   459       fields = {'org': org,
   462       fields = {'org': org,
   460                 'status': 'accepted'}
   463                 'status': 'accepted'}
   461 
   464 
   462       query = student_proposal_logic.logic.getQueryForFields(fields)
   465       query = student_proposal_logic.logic.getQueryForFields(fields)
   463       test = query.count()
       
   464 
   466 
   465       slots_left_to_assign = max(0, org.slots - query.count())
   467       slots_left_to_assign = max(0, org.slots - query.count())
   466 
   468 
   467       if slots_left_to_assign == 0:
   469       if slots_left_to_assign == 0:
   468         # no slots left so next org
   470         # no slots left so next org