Exemple #1
0
def index(request):
    now = datetime.datetime.utcnow()

    jobs = Job.list_active()
    e_jobs = Job.list_error()

    return render_to_response('admin/jobs_index.html', RequestContext(request, { 'now': now, 'jobs':jobs, 'e_jobs':e_jobs }))
Exemple #2
0
def prepare_invitations(request):
    logging.info(request.POST)
    job_id = request.POST['job_id']
    job = Job.get_by_id(int(job_id))

    job.start()
    job.save()


    student_ids = request.POST.getlist('student_ids')
    owner = request.POST['owner']
    mode = request.POST['mode']
    addressing_parents = request.POST['addressing_parents']
    addressing_p = request.POST['addressing_p']
    addressing_s = request.POST['addressing_s']
    addressing_d = request.POST['addressing_d']


    inflector.init_dicts()
    

    logging.info('student list %s'%student_ids) 
    for student_id in student_ids:
        try:
            prepare_invitation(owner, student_id, mode,addressing_parents, addressing_p, addressing_s, addressing_d)        
        except:
            logging.info("can't prepare invitation")


    job.finish()
    job.save()

    return HttpResponse('ok')
Exemple #3
0
def prepare_cardout(request):
    logging.info(request.POST)
    job_id = request.POST['job_id']
    job = Job.get_by_id(int(job_id))

    job.start()
    job.save()


    student_ids = request.POST.getlist('student_ids')
    owner = request.POST['owner']

    logging.info('student list %s'%student_ids) 
    for student_id in student_ids:
        try:
            mark_cardout(owner, student_id)        
        except:
            logging.info("can't prepare card")
    


    job.finish()
    job.save()

    return HttpResponse('ok')
Exemple #4
0
def prepare_cards(request):
    logging.info(request.POST)
    job_id = request.POST['job_id']
    job = Job.get_by_id(int(job_id))

    job.start()
    job.save()


    student_ids = request.POST.getlist('student_ids')
    owner = request.POST['owner']
    season_name = request.POST['season_name']
    course_code = request.POST['course_code']
    info_line_1 = request.POST['info_line_1']
    info_line_2 = request.POST['info_line_2']


    logging.info('student list %s'%student_ids) 
    for student_id in student_ids:
        try:
            prepare_card(owner, student_id, season_name, course_code, info_line_1, info_line_2)        
        except:
            logging.info("can't prepare card")
    


    job.finish()
    job.save()

    return HttpResponse('ok')
Exemple #5
0
def makecopy_students(request):
    logging.info(request.POST)
    job_id = request.POST['job_id']
    job = Job.get_by_id(int(job_id))

    job.start()
    job.save()



    student_ids = request.POST.getlist('student_ids')
    target_course_id = request.POST['target_course_id']
    source_course_id = request.POST['source_course_id']



    target_course = Course.get_by_id(int(target_course_id))
    if target_course is None:
        logging.info('missing target course')
        job.finish(error=True)
        job.save()
        return HttpResponse('error')

    source_course = Course.get_by_id(int(source_course_id))
    if source_course is None:
        logging.info('missing source course')
        job.finish(error=True)
        job.save()
        return HttpResponse('error')



    logging.info('student list %s'%student_ids) 
    pr = dict()
    for student_id in student_ids:
        (old_refkey,new) = makecopy_student(int(student_id), target_course) 
        pr[old_refkey]=new

    logging.info('stage 2 done')
    for n in pr.values():
        np = pr.get(n.partner_ref_code,None)
        if not np is None:
            logging.info('update partner_ref_code %s -> %s'%(n.partner_ref_code,np.ref_key))
            n.partner_ref_code=np.ref_key
            n.save()
            cdbsync.plan_cdb_put(n)

            
    
    
 

    taskqueue.add(url='/task/recount_capacity/', params={'course_id':target_course.key().id()})


    job.finish()
    job.save()

    return HttpResponse('ok')
Exemple #6
0
def plan_job_card_for_students(owner,student_ids,course_code, season_name, info_line_1, info_line_2):
    logging.info('prepare cards for %s, code=%s, season=%s, line1=%s, line2=%s'%(student_ids,course_code, season_name, info_line_1, info_line_2))

    job = Job()
    job.init("prepare cards",target='../../', owner=owner)
    job.save()
 
    taskqueue.add(url='/task/prepare_cards/', params={'job_id':job.key().id(), 'owner':owner, 'student_ids':student_ids, 'course_code': course_code, 'season_name':season_name, 'info_line_1':info_line_1, 'info_line_2': info_line_2})

    logging.info('job_id %d'%(job.key().id())) 

    return job.key().id()
Exemple #7
0
def plan_job_makecopy_students(owner,student_ids,source_course, target_course):
    logging.info('makecopy %s from course %d to course %d'%(student_ids,source_course.key().id(), target_course.key().id()))    

    job = Job()
    job.init("makecopy_students",target='../../', owner=owner)
    job.save()
 
    taskqueue.add(url='/task/makecopy_students/', params={'job_id':job.key().id(), 'owner':owner, 'student_ids':student_ids, 'source_course_id': source_course.key().id(), 'target_course_id':target_course.key().id()})

    logging.info('job_id %d'%(job.key().id())) 

    return job.key().id()
Exemple #8
0
def plan_job_hide_students(owner,student_ids,course):
    logging.info('hide students %s'%(student_ids))

    job = Job()
    job.init("delete students",target='../../', owner=owner)
    job.save()
 
    taskqueue.add(url='/task/hide_students/', params={'job_id':job.key().id(), 'owner':owner, 'student_ids':student_ids, 'course_id': course.key().id()})

    logging.info('job_id %d'%(job.key().id())) 

    return job.key().id()
Exemple #9
0
def plan_job_cardout_for_students(owner,student_ids):
    logging.info('prepare cardout for %s'%(student_ids))

    job = Job()
    job.init("prepare cardout",target='../../', owner=owner)
    job.save()
 
    taskqueue.add(url='/task/prepare_cardout/', params={'job_id':job.key().id(), 'owner':owner, 'student_ids':student_ids})

    logging.info('job_id %d'%(job.key().id())) 

    return job.key().id()
Exemple #10
0
def plan_job_invitation_for_students(owner,student_ids,mode, addressing_parents, addressing_p,addressing_s,addressing_d):
    logging.info('prepare invitations for %s, mode=%s, addressing_parents=%s'%(student_ids,mode,addressing_parents))

    job = Job()
    job.init("prepare invitations",target='../../', owner=owner)
    job.save()
 
    taskqueue.add(url='/task/prepare_invitations/', params={'job_id':job.key().id(), 'owner':owner, 'student_ids':student_ids, 'mode': mode, 'addressing_parents':addressing_parents,
    'addressing_p':addressing_p,'addressing_s':addressing_s,'addressing_d':addressing_d})

    logging.info('job_id %d'%(job.key().id())) 

    return job.key().id()
Exemple #11
0
def wait(request,job_id):
    now = datetime.datetime.utcnow()
    job = Job.get_by_id(int(job_id))

    if job is None:
        raise Http404

    if not job.active:
        return HttpResponseRedirect(job.finish_target)

    return render_to_response('admin/jobs_wait.html', RequestContext(request, { 'now': now, 'job':job }))
Exemple #12
0
def delete(request,job_id):
    job = Job.get_by_id(int(job_id))

    if job is None:
        raise Http404


    job.active=False
    job.save()


    return HttpResponseRedirect('../..')
Exemple #13
0
def transfer_students(request):
    logging.info(request.POST)
    job_id = request.POST['job_id']
    job = Job.get_by_id(int(job_id))

    job.start()
    job.save()



    student_ids = request.POST.getlist('student_ids')
    target_course_id = request.POST['target_course_id']
    source_course_id = request.POST['source_course_id']



    target_course = Course.get_by_id(int(target_course_id))
    if target_course is None:
        logging.info('missing target course')
        job.finish(error=True)
        job.save()
        return HttpResponse('error')

    source_course = Course.get_by_id(int(source_course_id))
    if source_course is None:
        logging.info('missing source course')
        job.finish(error=True)
        job.save()
        return HttpResponse('error')



    logging.info('student list %s'%student_ids) 
    for student_id in student_ids:
        transfer_student(int(student_id), target_course) 
    
    recount_course_capacity(source_course)
    source_course.save()
    logging.info(source_course)
    cdbsync.plan_cdb_put(source_course)

 

    taskqueue.add(url='/task/recount_capacity/', params={'course_id':target_course.key().id()})


    job.finish()
    job.save()

    return HttpResponse('ok')
Exemple #14
0
def prepare_qcards(request):
    logging.info(request.POST)
    job_id = request.POST['job_id']
    job = Job.get_by_id(int(job_id))

    job.start()
    job.save()


    student_ids = request.POST.getlist('student_ids')
    owner = request.POST['owner']


    logging.info('student list %s'%student_ids) 
    for student_id in student_ids:
        try:
            prepare_qcard(owner, student_id)        
        except Exception,e:
            logging.info(e)
            logging.info("can't prepare qcard %s" %x)
Exemple #15
0
def hide_students(request):
    logging.info(request.POST)
    job_id = request.POST['job_id']
    job = Job.get_by_id(int(job_id))

    job.start()
    job.save()


    student_ids = request.POST.getlist('student_ids')
    owner = request.POST['owner']
    course_id = request.POST['course_id']

    course = Course.get_by_id(int(course_id))
    if course is None:
        logging.info('missing course')
        job.finish(error=True)
        job.save()
        return HttpResponse('error')


    logging.info('student list %s'%student_ids) 
    for student_id in student_ids:
        try:
            hide_student(owner, student_id)        
        except:
            logging.info("can't hide student")
    
    recount_course_capacity(course)
    course.save()
    logging.info(course)
    cdbsync.plan_cdb_put(course)

 

    job.finish()
    job.save()

    return HttpResponse('ok')