本文整理匯總了Python中enroll.models.Course.list_filter方法的典型用法代碼示例。如果您正苦於以下問題:Python Course.list_filter方法的具體用法?Python Course.list_filter怎麽用?Python Course.list_filter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類enroll.models.Course
的用法示例。
在下文中一共展示了Course.list_filter方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: index
# 需要導入模塊: from enroll.models import Course [as 別名]
# 或者: from enroll.models.Course import list_filter [as 別名]
def index(request):
course_list = None
season = None
folder = None
if request.method == "POST":
form = SeasonCategoryFilterForm(request.POST)
if form.is_valid():
season = Season.get(str(form.cleaned_data["season_key"]))
folder = Folder.get(str(form.cleaned_data["folder_key"]))
if not season is None:
request.session["course_season_key"] = str(season.key())
if not folder is None:
request.session["course_folder_key"] = str(folder.key())
else:
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 (season is None) or (folder is None):
form = SeasonCategoryFilterForm()
else:
form = SeasonCategoryFilterForm({"season_key": str(season.key()), "folder_key": str(folder.key())})
if (season is None) or (folder is None):
course_list = None
if request.GET.get("all", None):
logging.info("all mode")
course_list = Course.list()
else:
if request.GET.get("all", None):
logging.info("all mode")
course_list = Course.list()
else:
course_list = Course.list_filter(str(season.key()), str(folder.key()))
tc_em = 0
tc_ef = 0
tc_e = 0
tc_pm = 0
tc_pf = 0
tc_p = 0
tc_ppm = 0
tc_ppf = 0
tc_pp = 0
tc_npm = 0
tc_npf = 0
tc_np = 0
tc_sum = 0
if course_list is not None:
for c in course_list:
tc_em += c.stat_e_m
tc_ef += c.stat_e_f
tc_e += c.usage
tc_pm += c.stat_fp_m
tc_pf += c.stat_fp_f
tc_p += c.stat_fp_m + c.stat_fp_f
tc_ppm += c.stat_pp_m
tc_ppf += c.stat_pp_f
tc_pp += c.stat_pp_m + c.stat_pp_f
tc_npm += c.stat_np_m
tc_npf += c.stat_np_f
tc_np += c.stat_np_m + c.stat_np_f
tc_sum += c.stat_paid
return render_to_response(
"admin/courses_index.html",
RequestContext(
request,
{
"form": form,
"course_list": course_list,
"tc_em": tc_em,
"tc_ef": tc_ef,
"tc_e": tc_e,
"tc_pm": tc_pm,
"tc_pf": tc_pf,
"tc_p": tc_p,
"tc_ppm": tc_ppm,
"tc_ppf": tc_ppf,
"tc_pp": tc_pp,
"tc_npm": tc_npm,
"tc_npf": tc_npf,
"tc_np": tc_np,
"tc_sum": tc_sum,
},
),
)
示例2: update_folder_stats
# 需要導入模塊: from enroll.models import Course [as 別名]
# 或者: from enroll.models.Course import list_filter [as 別名]
def update_folder_stats(request):
logging.info(request.POST)
folder_key = request.POST['folder_key']
season_key = request.POST['season_key']
course_list=Course.list_filter(season_key,folder_key)
tc_em = 0
tc_ef = 0
tc_e = 0
tc_pm = 0
tc_pf = 0
tc_p = 0
tc_ppm = 0
tc_ppf = 0
tc_pp = 0
tc_npm = 0
tc_npf = 0
tc_np = 0
tc_sum = 0
if course_list is not None:
for c in course_list:
tc_em+=c.stat_e_m
tc_ef+=c.stat_e_f
tc_e+=c.usage
tc_pm+=c.stat_fp_m
tc_pf+=c.stat_fp_f
tc_p+=c.stat_fp_m+c.stat_fp_f
tc_ppm+=c.stat_pp_m
tc_ppf+=c.stat_pp_f
tc_pp+=c.stat_pp_m+c.stat_pp_f
tc_npm+=c.stat_np_m
tc_npf+=c.stat_np_f
tc_np+=c.stat_np_m+c.stat_np_f
tc_sum+=c.stat_paid
logging.info('stat done')
fs = FolderStats.get_or_create(season_key,folder_key)
logging.info('old folder stats %s' % (fs))
fs.stat_em = tc_em
fs.stat_ef = tc_ef
fs.stat_e = tc_e
fs.stat_pm = tc_pm
fs.stat_pf = tc_pf
fs.stat_p = tc_p
fs.stat_ppm = tc_ppm
fs.stat_ppf = tc_ppf
fs.stat_pp = tc_pp
fs.stat_npm = tc_npm
fs.stat_npf = tc_npf
fs.stat_np = tc_np
fs.stat_sum = tc_sum
fs.mark_update()
fs.save()
logging.info('folder stats %s' % (fs))
return HttpResponse('ok')