def new_notes(id): form = NoteForm(request.form) form.author.choices = [(volunteer.id, volunteer.name) for volunteer in Volunteer.query.all()] form.author.choices.insert(0, (-1, 'Select your name')) openhour = Openhour.query.get(id) if request.method == 'POST' and form.validate(): new_note = Note(openhour_id=id, author=form.author.data, customers=form.customers.data, body=form.body.data, shopping=form.shopping.data) shopping_list = new_note.shopping db.session.add(new_note) db.session.commit() flash( 'Notes created for %s. Thank you for volunteering tonight!' % openhour.date.strftime('%B %d'), 'success') return redirect(url_for('index')) return render_template('notes_form.html', form=form)
def note(username): user = User.query.filter_by(username=username).first_or_404() if user != current_user: return redirect(url_for('index')) form = NoteForm() language_form = LanguageForm() if form.submit.data and form.validate(): n = Note(header=form.header.data, body=form.body.data, author=user) db.session.add(n) db.session.commit() render_template('index.html', title='Home', notes=push_notes(user)) flash('Saved') return redirect(url_for('index')) # elif language_form.submit2.data and language_form.validate(): # translate(form.header.data, form.body.data) return render_template('note.html', title='Make note', form=form, LanguageForm=language_form)
def new_notes(id): form = NoteForm(request.form) form.author.choices = [(volunteer.id, volunteer.name) for volunteer in Volunteer.query.all()] form.author.choices.insert(0, (-1, 'Select your name')) openhour = Openhour.query.get(id) if request.method == 'POST' and form.validate(): new_note = Note(openhour_id=id, author=form.author.data, customers=form.customers.data, body=form.body.data, shopping=form.shopping.data) db.session.add(new_note) db.session.commit() # Send email based on the Notes ##[ ] Turn this email msg into a template version to send # sender = '*****@*****.**' # subject = 'Open Hour: ' + openhour.date.strftime('%m/%d/%Y') # msgHtml = new_note.shopping # msgPlain = new_note.shopping # recipients = [] # # for volunteer in openhour.volunteers: # recipients.append(volunteer.email) # # to = ','.join(recipients) # # SendMessage(sender, to, subject, msgHtml, msgPlain) flash( 'Notes created for %s. Thank you!' % openhour.date.strftime('%m/%d/%Y'), 'success') return redirect(url_for('index')) return render_template('notes_form.html', form=form)