本文整理汇总了Python中oasis.lib.Courses2.reload_if_needed方法的典型用法代码示例。如果您正苦于以下问题:Python Courses2.reload_if_needed方法的具体用法?Python Courses2.reload_if_needed怎么用?Python Courses2.reload_if_needed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oasis.lib.Courses2
的用法示例。
在下文中一共展示了Courses2.reload_if_needed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: admin_course_save
# 需要导入模块: from oasis.lib import Courses2 [as 别名]
# 或者: from oasis.lib.Courses2 import reload_if_needed [as 别名]
def admin_course_save(course_id):
""" accept saved settings """
form = request.form
cancel_edit = form.get("cancel_edit", False)
if cancel_edit:
flash("Course edits cancelled")
return redirect(url_for("admin_courses"))
changed = False
course = Courses2.get_course(course_id)
groups = Courses.get_groups(course_id)
for g_id, group in groups.iteritems():
if form.get('delgroup_%s' % g_id):
changed = True
flash("Removing group %s" % group.name, "info")
Courses.del_group(int(g_id), course_id)
if 'course_name' in form:
name = form['course_name']
if not name == course['name']:
changed = True
Courses.set_name(course_id, name)
if 'course_title' in form:
title = form['course_title']
if not title == course['title']:
changed = True
Courses.set_title(course_id, title)
if 'course_active' in form:
active = form['course_active']
if active == '1' or active == 1:
active = True
else:
active = False
if not (active == course['active']):
changed = True
Courses.set_active(course_id, active)
addbtn = form.get('group_addbtn')
if addbtn:
newgroup = form.get('addgroup', None)
if newgroup:
Courses.add_group(newgroup, course_id)
changed = True
group = Groups.Group(newgroup)
flash("Group %s added." % group.name)
if changed:
Courses2.reload_if_needed()
flash("Course changes saved!")
return redirect(url_for("admin_course", course_id=course_id))
course = Courses2.get_course(course_id)
course['size'] = len(Courses.get_users(course_id))
return redirect(url_for("admin_courses"))