本文整理汇总了Python中models.factory.PosGraduationFactory.grades_of_subjects_dao方法的典型用法代码示例。如果您正苦于以下问题:Python PosGraduationFactory.grades_of_subjects_dao方法的具体用法?Python PosGraduationFactory.grades_of_subjects_dao怎么用?Python PosGraduationFactory.grades_of_subjects_dao使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.factory.PosGraduationFactory
的用法示例。
在下文中一共展示了PosGraduationFactory.grades_of_subjects_dao方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_subjects
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import grades_of_subjects_dao [as 别名]
def delete_subjects():
"""
Render a delete subject form.
"""
course_type = request.args.get('course_type')
form = SubjectsForm(course_type=course_type)
pfactory = PosGraduationFactory(current_user.pg_initials)
dao = pfactory.grades_of_subjects_dao()
json = pfactory.grades_of_subjects_dao().find({'courseType' : course_type})
json = list(json)
json = dumps(json)
if form.validate_on_submit():
index = str(form.index.data)
condition = {'title': form.requirement.data, 'courseType' : form.course_type.data}
dao.find_one_and_update(condition, {
'$set': {'subjects.' + index + '.deleted' : ""}
})
return redirect(
url_for(
'crud_subjects.delete_subjects',
success_msg='Disciplina deletada com sucesso',
course_type=form.course_type.data
)
)
return render_template(
'admin/delete_subjects.html',
form=form,
subjects=json,
success_msg=request.args.get('success_msg'),
)
示例2: edit_subjects
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import grades_of_subjects_dao [as 别名]
def edit_subjects():
"""
Render an edit subject form.
"""
course_type = request.args.get('course_type')
if (course_type is None):
course_type = 'Mestrado'
form = SubjectsForm(course_type=course_type)
pfactory = PosGraduationFactory(current_user.pg_initials)
dao = pfactory.grades_of_subjects_dao()
json = pfactory.grades_of_subjects_dao().find({'courseType': course_type })
json = list(json)
json = dumps(json)
if form.validate_on_submit():
index = str(form.index.data)
new_subject = {
'name': form.name.data,
'description': form.description.data,
'workloadInHours': form.workload_in_hours.data,
'credits': form.credits.data
}
condition = {'title': form.requirement.data, 'courseType' : form.course_type.data}
dao.find_one_and_update(condition, {
'$set': {'subjects.' + index : new_subject}
})
return redirect(
url_for(
'crud_subjects.edit_subjects',
course_type=form.course_type.data
)
)
return render_template(
'admin/edit_subjects.html',
form=form,
subjects=json,
)
示例3: view_subjects
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import grades_of_subjects_dao [as 别名]
def view_subjects(initials):
"""Render a view for subjects."""
pfactory = PosGraduationFactory(initials)
post_graduation = pfactory.post_graduation
grades_of_subjects = pfactory.grades_of_subjects_dao().find({ '$or': [ { 'title': 'Eletivas' }, { 'title':'Obrigatórias' } ] })
# renders an own page or redirect to another (external/404)?
return render_template(
'public/subjects.html',
std=get_std_for_template(post_graduation),
grades_of_subjects=grades_of_subjects
)
示例4: subjects
# 需要导入模块: from models.factory import PosGraduationFactory [as 别名]
# 或者: from models.factory.PosGraduationFactory import grades_of_subjects_dao [as 别名]
def subjects():
"""
Render a subject form.
"""
course_type = request.args.get('course_type')
form = SubjectsForm(course_type=course_type)
print(course_type, file=sys.stderr)
pfactory = PosGraduationFactory(current_user.pg_initials)
dao = pfactory.grades_of_subjects_dao()
if form.validate_on_submit():
new_subject = {
'name': form.name.data,
'description': form.description.data,
'workloadInHours': form.workload_in_hours.data,
'credits': form.credits.data
}
condition = {'title': form.requirement.data, 'courseType' : form.course_type.data }
dao.find_one_and_update(condition, {
'$push': {'subjects': new_subject}
})
return redirect(
url_for(
'crud_subjects.subjects',
success_msg='Disciplina adicionada com sucesso.',
course_type=form.course_type.data,
)
)
return render_template(
'admin/subjects.html',
form=form,
)