def submit_data(self, event): ret, frame = self.capture.read() if ret: self.timer.Stop() self.capture.release() self._db = DB() last_id = self._db.insertImage(self._front_img, self._back_img, self._side_img) rec_window = EditForm(self, 'Rec window', id=int(last_id[0])) rec_window.Show() self.Hide()
def edit(): form = EditForm(g.user.nickname) if form.validate_on_submit(): g.user.nickname = form.nickname.data g.user.about_me = form.about_me.data db.session.add(g.user) db.session.commit() flash('Your changes have been saved.') return redirect(url_for('edit')) else: form.nickname.data = g.user.nickname form.about_me.data = g.user.about_me return render_template('edit.html', form=form)
def publish(): form = EditForm() if form.validate_on_submit(): entry = Entry(title = form.title.data, content = form.content.data, pub_date = datetime.now()) try: db.session.add(entry) db.session.commit() except: flash('Database error!') return redirect('/edit') flash('Publich success!') return redirect('/entry/%d'%(entry.id)) return render_template('publish.html',form = form)
def edit(id): entry = Entry.query.filter_by(id = id).first() if entry == None: flash('entry error') return redirect(url_for('index')) form = EditForm(obj = entry) if form.validate_on_submit(): entry.title = form.title.data entry.content = form.content.data entry.pub_date = datetime.now() try: db.session.add(entry) db.session.commit() except: flash('Database error!') return redirect('/edit/%d'%entry.id) flash('Edit success!') return redirect('/entry/%d'%(entry.id)) return render_template('publish.html', form = form)
def edit_command(command_id): form = EditForm() commands = mongo.db.commands cmd_to_update = mongo.db.commands.find_one({'_id': ObjectId(command_id)}) distros = mongo.db.distros.find() if request.method == 'GET': return render_template('edit_command.html', form=AddCommandForm(), cmd_to_update=cmd_to_update, distros=distros) else: if form.validate(): if form.form_submit: commands.update({'_id': ObjectId(command_id)}, { 'app_name': form.form_name.data, 'app_distro': request.form.get('app_distro'), 'app_url': form.form_url.data, 'app_instruction': form.form_instruction.data, 'app_command': form.form_command.data }) flash('Command updated', 'info') form = SimpleSearch() choices = [('', 'select distro')] for distro in mongo.db.distros.find(): choices.append((f"{distro['distro_name']}", f"{distro['distro_name']}")) form.search_distro.choices = choices return render_template('find_command.html', form=form, results=mongo.db.commands.find( {'_id': ObjectId(command_id)}), distros=mongo.db.distros.find(), commands=mongo.db.commands.find()) else: flash("ReCAPTCHA missing!", "warning") return redirect(request.referrer)
def insertData(self, event): _id = event.GetEventObject().id rec_window = EditForm('Rec window', id=_id) rec_window.Show()