本文整理汇总了Python中enroll.models.Course.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Course.get_by_id方法的具体用法?Python Course.get_by_id怎么用?Python Course.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类enroll.models.Course
的用法示例。
在下文中一共展示了Course.get_by_id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makecopy_students
# 需要导入模块: from enroll.models import Course [as 别名]
# 或者: from enroll.models.Course import get_by_id [as 别名]
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')
示例2: transfer_students
# 需要导入模块: from enroll.models import Course [as 别名]
# 或者: from enroll.models.Course import get_by_id [as 别名]
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')
示例3: index_course
# 需要导入模块: from enroll.models import Course [as 别名]
# 或者: from enroll.models.Course import get_by_id [as 别名]
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}))
示例4: recount
# 需要导入模块: from enroll.models import Course [as 别名]
# 或者: from enroll.models.Course import get_by_id [as 别名]
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("../..")
示例5: plan_fullsync
# 需要导入模块: from enroll.models import Course [as 别名]
# 或者: from enroll.models.Course import get_by_id [as 别名]
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('../..')
示例6: attend_force_single
# 需要导入模块: from enroll.models import Course [as 别名]
# 或者: from enroll.models.Course import get_by_id [as 别名]
def attend_force_single(request,course_id):
if not config.getConfigBool('ENROLL_ENROLL_ON',False):
raise Http404
course = Course.get_by_id(int(course_id))
if course is None:
raise Http404
if not course.is_open():
raise Http404
return attend_single(request,course)
示例7: delete
# 需要导入模块: from enroll.models import Course [as 别名]
# 或者: from enroll.models.Course import get_by_id [as 别名]
def delete(request, course_id):
course = Course.get_by_id(int(course_id))
if course is None:
raise Http404
taskqueue.add(url="/task/hide_course_students/", params={"course_id": course.key().id()})
course.hidden = True
course.mark_as_modify()
course.save()
return redirect("../..")
示例8: course_fullsync
# 需要导入模块: from enroll.models import Course [as 别名]
# 或者: from enroll.models.Course import get_by_id [as 别名]
def course_fullsync(request):
logging.info(request.POST)
course_id = request.POST['course_id']
course = Course.get_by_id(int(course_id))
if course is None:
raise Http404
cdbsync.plan_cdb_put(course)
logging.info('course=%s'%course)
students = Student.list_for_course(course.key())
for s in students:
logging.info("student %s" % s.key())
cdbsync.plan_cdb_put(s)
logging.info("all done")
return HttpResponse('ok')
示例9: course_backup
# 需要导入模块: from enroll.models import Course [as 别名]
# 或者: from enroll.models.Course import get_by_id [as 别名]
def course_backup(request):
logging.info(request.POST)
course_id = request.POST['course_id']
course = Course.get_by_id(int(course_id))
if course is None:
raise Http404
logging.info('course=%s'%course)
student_list_to_enroll=Student.list_for_course_to_enroll(course.key())
student_list_enrolled=Student.list_for_course_enrolled(course.key())
if course.group_mode == 'Single':
student_list_to_enroll = sort_students_spare_single(student_list_to_enroll)
student_list_enrolled = sort_students_single(student_list_enrolled)
elif course.group_mode == 'School':
student_list_to_enroll = sort_students_spare_school(student_list_to_enroll)
student_list_enrolled = sort_students_school(student_list_enrolled)
elif course.group_mode == 'Pair':
student_list_to_enroll = sort_students_spare_pair(student_list_to_enroll)
student_list_enrolled = sort_students_pair(student_list_enrolled)
students = []
students.extend(student_list_enrolled)
students.extend(student_list_to_enroll)
data = [ ['#zaloha kurz',course.code,course.folder_name(),course.season_name()]]
for s in students:
if not s.x_pair_empty_slot:
data.append(s.as_csv_row())
out = cStringIO.StringIO()
dump_to_csv(data,out)
# logging.info(out)
cb = CourseBackup()
cb.init(out.getvalue(),course=course)
cb.save()
course.mark_as_backup()
course.save()
if cfg.getConfigBool('BACKUP_EMAIL_ON',False):
taskqueue.add(url='/task/send_backup/', params={'coursebackup_id':cb.key().id()})
logging.info('send task plan ok, cbid=%s'%(cb.key().id()))
else:
logging.info('BACKUP_EMAIL_ON is OFF!')
return HttpResponse('ok')
示例10: get_backup
# 需要导入模块: from enroll.models import Course [as 别名]
# 或者: from enroll.models.Course import get_by_id [as 别名]
def get_backup(request, course_id, course_backup_id):
course = Course.get_by_id(int(course_id))
if course is None:
raise Http404
course_backup = CourseBackup.get_by_id(int(course_backup_id))
if course_backup is None:
raise Http404
r = HttpResponse(course_backup.data,mimetype='application/vnd.ms-excel')
file_name = urllib.quote(course_backup.filename)
logging.info(file_name)
r['Content-Disposition'] = "attachment; filename*=UTF-8''%s"%file_name
return r
示例11: update_all_students_for_course
# 需要导入模块: from enroll.models import Course [as 别名]
# 或者: from enroll.models.Course import get_by_id [as 别名]
def update_all_students_for_course(request):
logging.info(request.POST)
course_id = request.POST['course_id']
course = Course.get_by_id(int(course_id))
if course is None:
raise Http404
logging.info('course=%s'%course)
cdbsync.plan_cdb_put(course)
students = Student.list_for_course(course.key())
for s in students:
logging.info("student %s" % s.key())
taskqueue.add(url='/task/update_all_students_do_one/', params={'student_key':s.key()})
logging.info("all done")
return HttpResponse('ok')
示例12: recount_capacity
# 需要导入模块: from enroll.models import Course [as 别名]
# 或者: from enroll.models.Course import get_by_id [as 别名]
def recount_capacity(request):
logging.info(request.POST)
course_id = request.POST['course_id']
course = Course.get_by_id(int(course_id))
if course is None:
raise Http404
recount_course_capacity(course)
course.save()
logging.info(course)
cdbsync.plan_cdb_put(course)
return HttpResponse('ok')
示例13: attend
# 需要导入模块: from enroll.models import Course [as 别名]
# 或者: from enroll.models.Course import get_by_id [as 别名]
def attend(request,course_id):
if not config.getConfigBool('ENROLL_ENROLL_ON',False):
raise Http404
course = Course.get_by_id(int(course_id))
if course is None:
raise Http404
if not course.is_open():
raise Http404
if course.only_pair_enroll():
return attend_pair(request,course)
else:
return attend_single(request,course)
示例14: import_students_do
# 需要导入模块: from enroll.models import Course [as 别名]
# 或者: from enroll.models.Course import get_by_id [as 别名]
def import_students_do(request,file_id, start_line, end_line, course_id):
course = Course.get_by_id(int(course_id))
if course is None:
raise Http404
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='"')
start_line = int(start_line)
end_line = int(end_line)
line = 0
st_list=[]
for row in r:
if (line>=end_line):
break
if (line>=start_line):
st = import_student(course,row)
st_list.append(st)
line+=1
if course.group_mode == 'Pair':
pd = dict()
for s in st_list:
if not s.x_import_no_2 is None:
p = pd.pop(s.x_import_no_2,None)
if p is None:
pd[s.x_import_no_2] = s
else:
s.partner_ref_code = p.ref_key
p.partner_ref_code = s.ref_key
s.save()
p.save()
###
taskqueue.add(url='/task/recount_capacity/', params={'course_id':course.key().id()})
return HttpResponseRedirect('../../../../../')
示例15: hide_course_students
# 需要导入模块: from enroll.models import Course [as 别名]
# 或者: from enroll.models.Course import get_by_id [as 别名]
def hide_course_students(request):
logging.info(request.POST)
course_id = request.POST['course_id']
course = Course.get_by_id(int(course_id))
if course is None:
raise Http404
list = Student.list_for_course(course.key())
for s in list:
s.hidden = True
s.save()
cdbsync.plan_cdb_put(s)
course.mark_as_modify()
course.save()
cdbsync.plan_cdb_put(course)
return HttpResponse('ok')