def get(self, id): if Staff.select().count() != 0: query = Staff.select() staff = get_object_or_404(query, Staff.id == int(id)) return render_template('staffs/staff.html', staff=staff, title=staff.name) else: content = 'There are current no staff' return render_template('infor.html', content=content)
def get(self, page=1): max_page = Staff.max_staff_page_all() if Staff.select().count() != 0: staffs = Staff.select().paginate(page, 10) return render_template('staffs/simlist.html', staffs=staffs, max_page=max_page, page=page) else: content = 'No staffs hav been added yet' return render_template('info.html', content=content, title='staff')
def get(self, page=1): max_page = Staff.max_staff_page_all() staffs = Staff.select().paginate(page, 10) return render_template('staffs/list.html', staffs=staffs, max_page=max_page, page=page, title='Staff List')
def get_context(self, id=None): form_cls = model_form(Staff) if id: query = Staff.select() staff = get_object_or_404(query, Staff.id == id) if request.method == 'POST': form = form_cls(request.form, intial=staff.bio) else: form = form_cls(obj=staff) else: staff = Staff() form = form_cls(request.form) context = {'staff': staff, 'form': form, 'create': id is None} return context