本文整理汇总了Python中enroll.models.Course.get_COURSE_CHOICES方法的典型用法代码示例。如果您正苦于以下问题:Python Course.get_COURSE_CHOICES方法的具体用法?Python Course.get_COURSE_CHOICES怎么用?Python Course.get_COURSE_CHOICES使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类enroll.models.Course
的用法示例。
在下文中一共展示了Course.get_COURSE_CHOICES方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: import_school
# 需要导入模块: from enroll.models import Course [as 别名]
# 或者: from enroll.models.Course import get_COURSE_CHOICES [as 别名]
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}))
示例2: import_students
# 需要导入模块: from enroll.models import Course [as 别名]
# 或者: from enroll.models.Course import get_COURSE_CHOICES [as 别名]
def import_students(request,file_id, seq_id=None):
f = FileBlob.get_by_id(int(file_id))
if f is None:
raise Http404
d = cStringIO.StringIO(f.data)
r = UnicodeReader(d)
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':
form = TargetPickForm(request.POST,courses = cc)
info = []
seq = 0
curr = None
line = 0
for row in r:
if len(row)>6 and (row[0].startswith('#export kurz') or row[0].startswith('#zaloha kurz')):
logging.info(row)
if not curr is None:
curr["end_line"]=line
info.append(curr)
curr = dict()
curr["seq"]=seq
seq+=1
curr["start_line"]=line+1
curr["code"]=row[1]
curr["folder"]=row[2]
curr["season"]=row[3]
curr["students"]=0
curr["info"]=row[6]
elif len(row)>19 and not row[0].startswith('#'):
curr["students"]+=1
line+=1
if not curr is None:
curr["end_line"]=line
info.append(curr)
else:
### no header detected.
curr = dict()
curr["seq"]=0
curr["start_line"]=0
curr["end_line"]=line
info.append(curr)
selected = None
if not seq_id is None:
for c in info:
if c["seq"]==int(seq_id):
selected = c
break
if selected is None:
raise Http404
if form is None:
form = TargetPickForm(courses = cc, initial={'start_line':selected['start_line'], 'end_line':selected['end_line']})
else:
if form.is_valid():
course = Course.get(form.cleaned_data['course_key'])
if course is None:
raise Http404
return render_to_response('admin/import_students.html', RequestContext(request, { 'info': info, 'form':form, 'selected':selected, 'course':course, 'season':season, 'folder':folder}))