本文整理汇总了Python中models.Group.get_by_number_and_specialty方法的典型用法代码示例。如果您正苦于以下问题:Python Group.get_by_number_and_specialty方法的具体用法?Python Group.get_by_number_and_specialty怎么用?Python Group.get_by_number_and_specialty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Group
的用法示例。
在下文中一共展示了Group.get_by_number_and_specialty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: search
# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import get_by_number_and_specialty [as 别名]
def search():
if request.method == 'POST':
if g.search_form.validate_on_submit():
n = unicode(g.search_form.select.data)
text = unicode(g.search_form.text.data)
if n == 'group':
if text.isdigit():
return render_template('search_result.html', type=n,
data=Group.get_group_by_number_like(int(text)),
count=Specialty.count() + 1)
elif text.isalpha():
return render_template('search_result.html', type=n, data=Group.get_by_specialty_like(text),
count=Specialty.count() + 1)
else:
if text.find(' ') != -1:
arr = text.split(' ')
if arr[0].isdigit():
return render_template('search_result.html', type=n,
data=Group.get_by_number_and_specialty(arr[0], arr[1]),
count=Specialty.count() + 1)
else:
return render_template('search_result.html', type=n,
data=Group.get_by_number_and_specialty(arr[1], arr[0]),
count=Specialty.count() + 1)
elif n == 'lecturer':
if text.isalpha():
return render_template('search_result.html', type=n, data=Lecturer.get_by_name(text))
elif n == 'subject':
if text.isalnum():
return render_template('search_result.html', type=n, data=Subject.get_by_substring(text), text=text)
return redirect(url_for('index'))
return redirect(url_for('group_timetable', group_number=427, week=get_week()))