当前位置: 首页>>代码示例>>Python>>正文


Python models.Course类代码示例

本文整理汇总了Python中enroll.models.Course的典型用法代码示例。如果您正苦于以下问题:Python Course类的具体用法?Python Course怎么用?Python Course使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Course类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: makecopy_students

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')
开发者ID:,项目名称:,代码行数:59,代码来源:

示例2: transfer_students

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')
开发者ID:,项目名称:,代码行数:50,代码来源:

示例3: import_school

def import_school(request,file_id):

    f = FileBlob.get_by_id(int(file_id))

    if f is None:
        raise Http404

    d = cStringIO.StringIO(f.data)
    r = UnicodeReader(d,encoding='utf8', delimiter=',', quotechar='"')
   
    form = None
    course = None 
    
    season = None
    cskey = request.session.get('course_season_key',None)
    if not cskey is None:
        season =  Season.get(str(cskey))
    folder = None
    cfkey = request.session.get('course_folder_key',None)
    if not cfkey is None:
        folder =  Folder.get(str(cfkey))    
    
    logging.info('cfkey %s cskey %s'%(cskey,cfkey))
    logging.info('folder: %s'%folder)
    logging.info('season: %s'%season)
    if folder and season:
        cc = Course.get_COURSE_FILTER_CHOICES(str(season.key()),str(folder.key()))
    else:
        cc = Course.get_COURSE_CHOICES()
    
    
    logging.info('cc:%s'%cc)
    
    if request.method == 'POST':
        logging.info('meth post, filling form')
        form = TargetPickForm2(request.POST,courses = cc)
        if form.is_valid():
            course = Course.get(form.cleaned_data['course_key'])
            if course is None:
                raise Http404
          
    else:
        logging.info('meth get, blank form')
        form = TargetPickForm2(courses = cc)

    selected = None
    info = []
    
    return render_to_response('admin/import_school.html', RequestContext(request, {  'info': info, 'form':form, 'course':course, 'season':season, 'folder':folder}))
开发者ID:prcek,项目名称:TSReg,代码行数:49,代码来源:import_views.py

示例4: show

def show(request,ref_code):
    student = Student.get_by_ref_key(ref_code)
    if student:
        course = Course.get(student.course_key) 
    else:
        course = None
    return render_to_response('enroll/show.html', RequestContext(request, { 'course': course, 'student':student, 'ref_code':ref_code }))
开发者ID:,项目名称:,代码行数:7,代码来源:

示例5: confirm

def confirm(request,confirm_code):
    student = Student.get_by_confirm_key(confirm_code)
    if student:
        course = Course.get(student.course_key) 
    else:
        course = None

    if (student is None) or (course is None):
        status = False
    else:
        status = True

    if status:
        if student.status == 'n':
            if course.can_enroll():
                student.status = 'e'
                student.init_enroll()
                student.save()
                plan_send_student_email('ENROLL_OK_PAY_REQUEST',student)
            else:
                student.status = 's'
                student.save()
                plan_send_student_email('ENROLL_OK_SPARE',student)
               
            plan_send_enroll_form(student) 
            plan_update_course(course)

        elif not student.status in ['e','s']:
            status = False

    return render_to_response('enroll/confirm.html', RequestContext(request, { 'course': course, 'student':student, 'confirm_code':confirm_code, 'status':status }))
开发者ID:,项目名称:,代码行数:31,代码来源:

示例6: confirm_pair

def confirm_pair(request,confirm_code1,confirm_code2):
    student1 = Student.get_by_confirm_key(confirm_code1)
    if student1:
        course = Course.get(student1.course_key) 
    else:
        course = None

    student2 = Student.get_by_confirm_key(confirm_code2)

    if (student1 is None) or (student2 is None) or (course is None):
        status = False
    else:
        status = True

    if status:
        if student1.status == 'n':
            if course.can_enroll():
                student1.status = 'e'
                student1.init_enroll()
                student1.save()
                plan_send_student_email('ENROLL_OK_PAY_REQUEST',student1)
            else:
                student1.status = 's'
                student1.save()
                plan_send_student_email('ENROLL_OK_SPARE',student1)
               
            plan_send_enroll_form(student1) 
            status1 = True
        
        elif not student1.status in ['e','s']:
            status1 = False
        else:
            status1 = True
            
        if student2.status == 'n':
            if course.can_enroll():
                student2.status = 'e'
                student2.init_enroll()
                student2.save()
                plan_send_student_email('ENROLL_OK_PAY_REQUEST',student2)
            else:
                student2.status = 's'
                student2.save()
                plan_send_student_email('ENROLL_OK_SPARE',student2)
               
            plan_send_enroll_form(student2) 

            status2 = True
        elif not student2.status in ['e','s']:
            status2 = False
        else:
            status2 = True
 

            
        status = status1 or status2            
        if status:
            plan_update_course(course)

    return render_to_response('enroll/confirm_pair.html', RequestContext(request, { 'course': course, 'student1':student1, 'student2':student2, 'confirm_code1':confirm_code1, 'confirm_code2':confirm_code2 , 'status':status }))
开发者ID:,项目名称:,代码行数:60,代码来源:

示例7: get_offer_list

def get_offer_list(folder_id = None):

    if folder_id is None:
        folders_query=Folder.list()
    else:
        folders_query = []
        f = Folder.get_by_id(int(folder_id))
        if f:
            folders_query.append(f)
    
    courses_query=Course.list_for_enroll()  

    folders= set([])
    courses = []
    result = []
    for course in courses_query:
        folders.add(course.folder_key)
        courses.append(course)

    logging.info(folders)
    logging.info(courses)

    for folder in folders_query:
        fk = str(folder.key())
        logging.info('fk:%s'%fk)
        if fk in folders:
            logging.info('in')
            sub_list = [c for c in courses if fk==c.folder_key] 
            result.append({'folder':folder, 'courses':sub_list })
            pass
    return result
开发者ID:,项目名称:,代码行数:31,代码来源:

示例8: index

def index(request):

    season = None
    if request.method == 'POST':
        filter_form = SeasonFilterForm(request.POST)
        if filter_form.is_valid():
            season = Season.get(str(filter_form.cleaned_data['season_key']))
            if not season is None:
                request.session['backup_season_key']=str(season.key())
    else:
        bskey = request.session.get('backup_season_key',None)
        if not bskey is None:
            season =  Season.get(str(bskey))
        if season is None:
            filter_form = SeasonFilterForm()
        else:
            filter_form = SeasonFilterForm({'season_key':str(season.key())})



    if season is None:
        course_list = None
    else:
        course_list = Course.list_season(str(season.key())) 

    return render_to_response('admin/backup_index.html', RequestContext(request, { 'filter_form':filter_form, 'course_list': course_list}))
开发者ID:prcek,项目名称:TSReg,代码行数:26,代码来源:backup_views.py

示例9: plan_update_all_courses

def plan_update_all_courses(request):
    logging.info("update_all_courses")
    courses = Course.list()
    for c in courses:
        logging.info("course %s"%c.key())
        cdbsync.plan_cdb_put(c)
    return HttpResponse('ok')
开发者ID:prcek,项目名称:TSReg,代码行数:7,代码来源:test_views.py

示例10: create

def create(request):

    course = Course()
    season = None
    folder = None
    cskey = request.session.get("course_season_key", None)
    if not cskey is None:
        season = Season.get(str(cskey))
    cfkey = request.session.get("course_folder_key", None)
    if not cfkey is None:
        folder = Folder.get(str(cfkey))

    if not ((folder is None) or (Season is None)):
        course.folder_key = cfkey
        course.season_key = cskey

    if request.method == "POST":
        form = CourseForm(request.POST, instance=course)
        if form.is_valid():
            logging.info("edit course before %s" % course)
            form.save(commit=False)
            logging.info("edit course after %s" % course)
            course.mark_as_modify()
            course.save()
            cdbsync.plan_cdb_put(course)
            return HttpResponseRedirect("..")
    else:
        form = CourseForm(instance=course)
    return render_to_response("admin/courses_create.html", RequestContext(request, {"form": form}))
开发者ID:prcek,项目名称:TSReg,代码行数:29,代码来源:course_views.py

示例11: recount

def recount(request, course_id):

    course = Course.get_by_id(int(course_id))
    if course is None:
        raise Http404

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

    return HttpResponseRedirect("../..")
开发者ID:prcek,项目名称:TSReg,代码行数:9,代码来源:course_views.py

示例12: index_course

def index_course(request, course_id):
    course = Course.get_by_id(int(course_id))
    if course is None:
        raise Http404

    logging.info('course: %s'%course)
    backup_list = CourseBackup.list_for_course(str(course.key()))
    
    return render_to_response('admin/backup_list.html', RequestContext(request, { 'backup_list': backup_list, 'course':course}))
开发者ID:prcek,项目名称:TSReg,代码行数:9,代码来源:backup_views.py

示例13: show_pair

def show_pair(request,ref_code1, ref_code2):
    student1 = Student.get_by_ref_key(ref_code1)
    if student1:
        course = Course.get(student1.course_key) 
    else:
        course = None
    student2 = Student.get_by_ref_key(ref_code2)
 
    
    return render_to_response('enroll/show_pair.html', RequestContext(request, { 'course': course, 'student1':student1, 'ref_code1':ref_code1, 'student2':student2, 'ref_code2':ref_code2 }))
开发者ID:,项目名称:,代码行数:10,代码来源:

示例14: plan_fullsync

def plan_fullsync(request,course_id):

    course = Course.get_by_id(int(course_id))
    if course is None:
        raise Http404

    logging.info('course: %s'%course)
    taskqueue.add(url='/task/course_fullsync/', params={'course_id':course.key().id()})

    return HttpResponseRedirect('../..')
开发者ID:prcek,项目名称:TSReg,代码行数:10,代码来源:backup_views.py

示例15: plan_course_backup

def plan_course_backup(request):
    if not cfg.getConfigBool('BACKUP_ON',False):
        logging.info('BACKUP_ON is OFF!')
        return HttpResponse('ok')
 
    course_list = Course.list_for_backup().fetch(100)
    for c in course_list:
        logging.info('course: %s'%c)
        taskqueue.add(url='/task/course_backup/', params={'course_id':c.key().id()})
 
    return HttpResponse('ok')
开发者ID:prcek,项目名称:TSReg,代码行数:11,代码来源:cron_jobs.py


注:本文中的enroll.models.Course类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。