def add_talk_seminar(seminarid): sem = Seminar.query.get(seminarid) if sem is None: flash("No Such Seminar", "Error") return default() if request.method == 'POST': if sem.Organizer_id == current_user.id or current_user.has_role('admin'): talk = Talk() talk.topic = request.form.get("topic") talk.abstract = request.form.get("abstract") talk.date_of = datetime.strptime(request.form.get("date_of"), '%m/%d/%Y %I:%M %p') talk.seminar_id = seminarid talk.speaker = request.form.get("speaker") talk.speaker_info = request.form.get("speaker_info") talk.location = request.form.get("location") base_app.db.session.add(talk) base_app.db.session.commit() flash("Talk added for seminar %s" % sem.title, "Success") return default() else: flash("Insufficient Permissions", "Error") return default() return render_template('add_talk.html', seminar=sem)
def test_creating_talk_basic(self): """test to create a Talk instance""" talk = Talk() talk.topic = u"Bla" talk.when = datetime.datetime.now() talk.tags = [u"foo", u"bar"] talk.duration = 5.5 talk.validate() talk.save() self.assertTrue(talk['_id']) self.assertEqual(talk.duration, 5.5)