本文整理汇总了Python中models.Group.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Group.get_by_id方法的具体用法?Python Group.get_by_id怎么用?Python Group.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Group
的用法示例。
在下文中一共展示了Group.get_by_id方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import get_by_id [as 别名]
def post(self):
# TODO: sanity test
group = self.request.get('group')
vendor = self.request.get('vendor')
event = Event(group = Group.get_by_id(long(group)),
vendor = Vendor.get_by_id(long(vendor)),
advocate = users.get_current_user())
event.put()
self.redirect('/u/mine/profile')
示例2: get_fees
# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import get_by_id [as 别名]
def get_fees(group_id=None):
"""
please notice, there's a different function in helpers.py
with the same name.
"""
fee_query = db.Query(Fee)
if group_id:
group = Group.get_by_id(group_id)
fee_query.filter("group =", group)
fee_query.order('-date')
fees = fee_query.fetch(20)
return fees
示例3: post
# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import get_by_id [as 别名]
def post(self):
data = UserForm(data=self.request.POST)
logging.info(self.request.POST)
if not data.is_valid():
self.redirect('/u/register')
else:
user = data.save(commit=False)
if not exists_by_property(User, 'name', user.name):
user.who = users.get_current_user()
user.put()
for group in self.request.POST.getall('group'):
user.join(Group.get_by_id(group))
self.redirect('/u/%s/profile' % user.name)
else:
logging.debug('user %s already exists!' % user.name)
self.generate('add_user.html',
{'form':data,
'groups':Group.all()})
示例4: get_group
# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import get_by_id [as 别名]
def get_group(id):
try:
return Group.get_by_id(int(id))
except:
return None
示例5: admin_update
# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import get_by_id [as 别名]
def admin_update(what, id):
if what == 'specialty':
form = SpecialtyForm()
tmp = Specialty.get_by_id(id)
if form.validate_on_submit():
tmp.long_form = form.long_form.data
tmp.short_form = form.short_form.data
Specialty.update(tmp)
flash(u'Спеціальність успішно оновлено!')
return redirect_back('admin_specialty')
elif request.method == 'POST':
next = get_redirect_target()
return render_template('admin_update.html', form=form, type=what, id=id, next=next)
else:
form.long_form.data = tmp.long_form
form.short_form.data = tmp.short_form
next = get_redirect_target()
return render_template('admin_update.html', form=form, type=what, id=id, next=next)
if what == 'subject':
form = SubjectForm()
tmp = Subject.get_by_id(id)
if form.validate_on_submit():
tmp.title = form.title.data
Subject.update(tmp)
flash(u'Предмет успішно оновлено!')
return redirect_back('admin_subject')
elif request.method == 'POST':
next = get_redirect_target()
return render_template('admin_update.html', form=form, type=what, id=id, next=next)
else:
form.title.data = tmp.title
next = get_redirect_target()
return render_template('admin_update.html', form=form, type=what, id=id, next=next)
if what == 'group':
form = GroupForm()
form.group_specialty.choices = [(h.id, h.long_form) for h in Specialty.get_all()]
tmp = Group.get_by_id(id)
if form.validate_on_submit():
tmp.group_number = form.group_number.data
tmp.group_course = form.group_course.data
tmp.specialty_id = form.group_specialty.data
Group.update(tmp)
flash(u'Групу упішно оновлено!')
return redirect_back('admin_group')
elif request.method == 'POST':
next = get_redirect_target()
return render_template('admin_update.html', form=form, type=what, id=id, next=next)
else:
form.group_number.data = tmp.group_number
form.group_course.data = tmp.group_course
form.group_specialty.data = tmp.specialty_id
next = get_redirect_target()
return render_template('admin_update.html', form=form, type=what, id=id, next=next)
if what == 'lecturer':
form = LecturerForm()
form.lessons.choices = [(h.id, h.title) for h in Subject.get_all()]
tmp = Lecturer.get_by_id(id)
if form.validate_on_submit():
tmp.first_name = form.first_name.data
tmp.middle_name = form.middle_name.data
tmp.last_name = form.last_name.data
Lecturer.update(tmp)
Lessons.add(id, form.lessons.data)
flash(u'Дані викладача успішно оновлено!')
return redirect_back('admin_lecturer')
elif request.method == 'POST':
next = get_redirect_target()
return render_template('admin_update.html', form=form, type=what, id=id, next=next)
else:
form.lessons.data = [h.id for h in tmp.subjects]
form.first_name.data = tmp.first_name
form.middle_name.data = tmp.middle_name
form.last_name.data = tmp.last_name
next = get_redirect_target()
return render_template('admin_update.html', form=form, type=what, id=id, next=next)
示例6: admin_timetable
# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import get_by_id [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)