当前位置: 首页>>代码示例>>Python>>正文


Python Group.get_all方法代码示例

本文整理汇总了Python中models.Group.get_all方法的典型用法代码示例。如果您正苦于以下问题:Python Group.get_all方法的具体用法?Python Group.get_all怎么用?Python Group.get_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Group的用法示例。


在下文中一共展示了Group.get_all方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: admin_group

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import get_all [as 别名]
def admin_group():
    form = GroupForm()
    form.group_specialty.choices = [(h.id, h.long_form) for h in Specialty.get_all()]
    if form.validate_on_submit():
        Group.add(form.group_number.data, form.group_course.data, form.group_specialty.data)
        flash(u'Спеціальність успішно додано')
        return redirect_back('admin_group')
    return render_template('admin_group.html', data=Group.get_all(), form=form)
开发者ID:stepanov-valentin,项目名称:TimeTable,代码行数:10,代码来源:views.py

示例2: index

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import get_all [as 别名]
def index():
    return render_template('groups.html', all_groups=Group.get_all())
开发者ID:stepanov-valentin,项目名称:TimeTable,代码行数:4,代码来源:views.py

示例3: admin_replacement

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import get_all [as 别名]
def admin_replacement():
    form = ReplacementForm()
    choises = []
    courses = [u'Перший курс', u'Другий курс', u'Третій курс', u'Четвертий', u'Бакалаврат']
    index = 1
    for j in courses:
        tmp = [j]
        tmp.append([(h.id, unicode(h.group_number) + '-' + h.specialty.short_form) for h in Group.get_all() if
                    h.group_course == index])
        choises.append(tmp)
        index += 1
    form.group.choices = choises
    # form.finish_subject.choices = [(i.id,i.subject.title)for i in Lessons.get]
    if request.method == 'POST':
        Replacement.add(form.group.data,form.start.data,form.start_lesson.data,form.start_subject.data,form.finish.data,form.finish_lesson.data,form.finish_subject.data)
        flash(u'Заміну здійснено!')
    return render_template('admin_replacement.html', form=form)
开发者ID:stepanov-valentin,项目名称:TimeTable,代码行数:19,代码来源:views.py

示例4: admin_timetable

# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import get_all [as 别名]
def admin_timetable():
    form = TimeTable()
    all_groups = Group.get_all()
    choises = []
    courses = [u'Перший курс', u'Другий курс', u'Третій курс', u'Четвертий', u'Бакалаврат']
    index = 1
    for j in courses:
        tmp = [j]
        tmp.append([(h.id, unicode(h.group_number) + '-' + h.specialty.short_form) for h in all_groups if
                    h.group_course == index])
        choises.append(tmp)
        index += 1
    form.group.choices = choises
    edit = EditForm()

    if form.validate_on_submit():
        group = form.group.data
        day = form.day.data
        item = None
        if group or group != 'None':
            item = Group.get_by_id(group)
        if day or day != 'None':
            item_day = getattr(item, day)
            if item_day != []:
                for i in item_day:
                    if i.week == 1:
                        if i.subject_one:
                            edit.one_lesson_one.data = i.subject_one.subject_id
                            edit.one_lesson_one_lecturer.data = i.subject_one.lecturer_id
                        if i.subject_two:
                            edit.one_lesson_two.data = i.subject_two.subject_id
                            edit.one_lesson_two_lecturer.data = i.subject_two.lecturer_id
                        if i.subject_three:
                            edit.one_lesson_three.data = i.subject_three.subject_id
                            edit.one_lesson_three_lecturer.data = i.subject_three.lecturer_id
                        if i.subject_four:
                            edit.one_lesson_four.data = i.subject_four.subject_id
                            edit.one_lesson_four_lecturer.data = i.subject_four.lecturer_id
                        if i.subject_five:
                            edit.one_lesson_five.data = i.subject_five.subject_id
                            edit.one_lesson_five_lecturer.data = i.subject_five.lecturer_id
                        if i.subject_six:
                            edit.one_lesson_six.data = i.subject_six.subject_id
                            edit.one_lesson_six_lecturer.data = i.subject_six.lecturer_id
                    if i.week == 2:
                        if i.subject_one:
                            edit.two_lesson_one.data = i.subject_one.subject_id
                            edit.two_lesson_one_lecturer.data = i.subject_one.lecturer_id
                        if i.subject_two:
                            edit.two_lesson_two.data = i.subject_two.subject_id
                            edit.two_lesson_two_lecturer.data = i.subject_two.lecturer_id
                        if i.subject_three:
                            edit.two_lesson_three.data = i.subject_three.subject_id
                            edit.two_lesson_three_lecturer.data = i.subject_three.lecturer_id
                        if i.subject_four:
                            edit.two_lesson_four.data = i.subject_four.subject_id
                            edit.two_lesson_four_lecturer.data = i.subject_four.lecturer_id
                        if i.subject_five:
                            edit.two_lesson_five.data = i.subject_five.subject_id
                            edit.two_lesson_five_lecturer.data = i.subject_five.lecturer_id
                        if i.subject_six:
                            edit.two_lesson_six.data = i.subject_six.subject_id
                            edit.two_lesson_six_lecturer.data = i.subject_six.lecturer_id
            return render_template('admin_timetable.html', form=form, edit=edit)
    elif request.method == 'POST' and edit.data:
        day = None
        group = None
        try:
            day = request.args.get('day')
            group = int(request.args.get('group'))
        except ValueError:
            pass
        if group != None and day != None:
            lessons = globals().get(day.capitalize()).get_by_group(group)
            while len(lessons) < 2:
                lessons.append(globals().get(day.capitalize())(week=len(lessons) + 1, group_id=group))
            for item in lessons:
                for i in range(1, 7):
                    if item.week == 1:
                        setattr(item, 'lesson_' + num2words(i), Lessons.get_id(
                            getattr(edit, unicode(num2words(1)) + '_lesson_' + unicode(num2words(i))).data,
                            getattr(edit, unicode(num2words(1)) + '_lesson_' + unicode(num2words(i)) + unicode(
                                '_lecturer')).data))
                    if item.week == 2:
                        setattr(item, 'lesson_' + num2words(i), Lessons.get_id(
                            getattr(edit, unicode(num2words(2)) + '_lesson_' + unicode(num2words(i))).data,
                            getattr(edit, unicode(num2words(2)) + '_lesson_' + unicode(num2words(i)) + unicode(
                                '_lecturer')).data))
                    globals().get(day.capitalize()).update(item)
            flash(u'Розклад успішно оновлено')
            form.day.errors = None
            form.group.errors = None
        return render_template('admin_timetable.html', form=form)
    else:
        return render_template('admin_timetable.html', form=form)
开发者ID:stepanov-valentin,项目名称:TimeTable,代码行数:97,代码来源:views.py


注:本文中的models.Group.get_all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。