def process_stakeholders_form(form): errors = False for i in range(1, 15): label = ROUTES[i] key = 'field-route-' + str(i) value = request.form[key] if is_valid_email_list(value): stakeholder = Stakeholder.query.filter_by(label=label).first() if not stakeholder: stakeholder = Stakeholder( label=label, email_list=value ) else: stakeholder.update(email_list=value) db.session.add(stakeholder) else: errors = True db.session.rollback() if not errors: db.session.commit() flash("Your settings have been saved!", "alert-success") return redirect(url_for('user.user_manage'))
def seed_stakeholder(email, section): ''' Creates a new stakeholder. ''' from feedback.surveys.models import Stakeholder seed_email = email if email else app.config.get('SEED_EMAIL') try: section_title = ROUTES[int(section)] stakeholder_exists = Stakeholder.query.filter( Stakeholder.id == int(section)).first() if stakeholder_exists: current_app.logger.info( 'Stakeholder for Section {0} ({1}) already exists'.format( section, section_title)) else: new_stakeholder = Stakeholder.create(email_list=seed_email, id=int(section), label=ROUTES[int(section)]) db.session.add(new_stakeholder) db.session.commit() current_app.logger.info( 'Stakeholder for Section {0} successfully created!'.format( section_title)) except Exception, e: current_app.logger.error( 'Something went wrong: {exception}'.format(exception=e.message))
def seed_stakeholder(email, section): ''' Creates a new stakeholder. ''' from feedback.surveys.models import Stakeholder seed_email = email if email else app.config.get('SEED_EMAIL') try: section_title = ROUTES[int(section)] stakeholder_exists = Stakeholder.query.filter(Stakeholder.id == int(section)).first() if stakeholder_exists: current_app.logger.info( 'Stakeholder for Section {0} ({1}) already exists'.format( section, section_title)) else: new_stakeholder = Stakeholder.create( email_list=seed_email, id=int(section), label=ROUTES[int(section)] ) db.session.add(new_stakeholder) db.session.commit() current_app.logger.info( 'Stakeholder for Section {0} successfully created!'.format( section_title)) except Exception, e: current_app.logger.error( 'Something went wrong: {exception}'.format(exception=e.message))
def process_stakeholders_form(form): errors = False for i in range(1, 8): label = PERMIT_TYPE[i] key = 'field-route-' + str(i) value = request.form[key] if is_valid_email_list(value): stakeholder = Stakeholder.query.filter_by(label=label).first() if not stakeholder: stakeholder = Stakeholder(label=label, email_list=value) else: stakeholder.update(email_list=value) db.session.add(stakeholder) else: errors = True db.session.rollback() if not errors: db.session.commit() flash("Your settings have been saved!", "alert-success") return redirect(url_for('user.user_manage'))