def get(self): args = self.req_parser.parse_args() try: event = db.session.query(Event).filter(Event.id == args['event_id']).first() if not event: LOGGER.warn("Event not found for event_id: {}".format(args['event_id'])) return errors.EVENT_NOT_FOUND form = db.session.query(ApplicationForm).filter(ApplicationForm.event_id == args['event_id']).first() if not form: LOGGER.warn("Form not found for event_id: {}".format(args['event_id'])) return errors.FORM_NOT_FOUND # Get the latest response (note there may be older withdrawn responses) response = db.session.query(Response).filter( Response.application_form_id == form.id, Response.user_id == g.current_user['id'] ).order_by(Response.started_timestamp.desc()).first() if not response: LOGGER.debug("Response not found for event_id: {}".format(args['event_id'])) return errors.RESPONSE_NOT_FOUND answers = db.session.query(Answer).filter(Answer.response_id == response.id).all() response.answers = list(answers) return response except SQLAlchemyError as e: LOGGER.error("Database error encountered: {}".format(e)) return errors.DB_NOT_AVAILABLE except: LOGGER.error("Encountered unknown error: {}".format(traceback.format_exc())) return errors.DB_NOT_AVAILABLE
def delete(self): args = self.del_req_parser.parse_args() current_user_id = g.current_user['id'] response = response_repository.get_by_id(args['id']) if not response: return errors.RESPONSE_NOT_FOUND if response.user_id != current_user_id: return errors.UNAUTHORIZED response.withdraw() response_repository.save(response) try: user = user_repository.get_by_id(current_user_id) event = response.application_form.event organisation = event.organisation emailer.email_user( 'withdrawal', template_parameters=dict( organisation_name=organisation.name ), event=event, user=user ) except: LOGGER.error('Failed to send withdrawal confirmation email for response with ID : {id}, but the response was withdrawn succesfully'.format(id=args['id'])) return {}, 204
def put(self): # update existing offer args = self.req_parser.parse_args() offer_id = args['offer_id'] candidate_response = args['candidate_response'] accepted_accommodation_award = args['accepted_accommodation_award'] accepted_travel_award = args['accepted_travel_award'] rejected_reason = args['rejected_reason'] offer = db.session.query(Offer).filter(Offer.id == offer_id).first() LOGGER.info('Updating offer {} with values: candidate response: {}, Accepted accommodation: {}, ' 'Accepted travel: {}, Rejected Reason: {}'.format(offer_id, candidate_response, accepted_accommodation_award, accepted_travel_award, rejected_reason)) if not offer: return errors.OFFER_NOT_FOUND try: user_id = verify_token(request.headers.get('Authorization'))['id'] if offer and offer.user_id != user_id: return errors.FORBIDDEN offer.responded_at = datetime.now() offer.candidate_response = candidate_response offer.accepted_accommodation_award = accepted_accommodation_award offer.accepted_travel_award = accepted_travel_award offer.rejected_reason = rejected_reason db.session.commit() except Exception as e: LOGGER.error("Failed to update offer with id {} due to {}".format(args['offer_id'], e)) return errors.ADD_OFFER_FAILED return offer_update_info(offer), 201
def send_confirmation(self, user, response): try: answers = db.session.query(Answer).filter(Answer.response_id == response.id).all() if answers is None: LOGGER.warn('Found no answers associated with response with id {response_id}'.format(response_id=response.id)) questions = db.session.query(Question).filter(Question.application_form_id == response.application_form_id).all() if questions is None: LOGGER.warn('Found no questions associated with application form with id {form_id}'.format(form_id=response.application_form_id)) application_form = db.session.query(ApplicationForm).filter(ApplicationForm.id == response.application_form_id).first() if application_form is None: LOGGER.warn('Found no application form with id {form_id}'.format(form_id=response.application_form_id)) event = db.session.query(Event).filter(Event.id == application_form.event_id).first() if event is None: LOGGER.warn('Found no event id {event_id}'.format(form_id=application_form.event_id)) except: LOGGER.error('Could not connect to the database to retrieve response confirmation email data on response with ID : {response_id}'.format(response_id=response.id)) try: # Building the summary, where the summary is a dictionary whose key is the question headline, and the value is the relevant answer summary = {} for answer in answers: for question in questions: if answer.question_id == question.id: summary[question.headline] = _get_answer_value(answer, question) subject = 'Your application to {}'.format(event.description) greeting = strings.build_response_email_greeting(user.user_title, user.firstname, user.lastname) body_text = greeting + '\n\n' + strings.build_response_email_body(event.name, event.description, summary) emailer.send_mail(user.email, subject, body_text=body_text) except: LOGGER.error('Could not send confirmation email for response with id : {response_id}'.format(response_id=response.id))
def send_confirmation(self, user, questions, answers, confirmed, event): if answers is None: LOGGER.warn( 'Found no answers associated with response with id {response_id}' .format(response_id=user.id)) if questions is None: LOGGER.warn( 'Found no questions associated with application form with id {form_id}' .format(form_id=user.id)) try: # Building the summary, where the summary is a dictionary whose key is the question headline, and the value # is the relevant answer summary = "" for answer in answers: for question in questions: if answer.registration_question_id == question.id: summary += "Question:" + question.headline + "\nAnswer:" + _get_answer_value( answer, question) + "\n" emailer.email_user('registration-with-confirmation' if confirmed else 'registration-pending-confirmation', template_parameters=dict(summary=summary), event=event, user=user) except Exception as e: LOGGER.error( 'Could not send confirmation email for response with id : {response_id}' .format(response_id=user.id))
def _create(self, alert): desc = alert.message if alert.grafana_url: jira_link = "[Go to Grafana|{}]".format(alert.grafana_url) desc = alert.message + " - " + jira_link issue_dict = { 'project': { 'key': self._project_key }, 'summary': alert.id, 'description': desc, # 'assignee': {'name': self._assignee}, 'components': [{ 'name': self._assignee }], 'issuetype': { 'name': 'Incident' }, 'security': { 'name': 'Internal Issue' } } jira = self._connect() if jira: try: LOGGER.info("Creating JIRA ticket") issue = jira.create_issue(fields=issue_dict) if issue: return issue.key except JIRAError as err: LOGGER.error("Failed creating JIRA ticket") LOGGER.error(err) return None
def get(self): args = self.req_parser.parse_args() language = args['language'] try: form = application_form_repository.get_by_event_id( args['event_id']) if not form: return FORM_NOT_FOUND if not form.is_open: return APPLICATIONS_CLOSED if not form.sections: return SECTION_NOT_FOUND if not form.questions: return QUESTION_NOT_FOUND return get_form_fields(form, language) except SQLAlchemyError as e: LOGGER.error("Database error encountered: {}".format(e)) return DB_NOT_AVAILABLE except: LOGGER.error("Encountered unknown error: {}".format( traceback.format_exc())) return DB_NOT_AVAILABLE
def get(self): args = self.req_parser.parse_args() event_id = args['event_id'] user_id = g.current_user['id'] try: offer = db.session.query(Offer).filter(Offer.event_id == event_id).filter(Offer.user_id == user_id).first() response = response_repository.get_submitted_by_user_id_for_event(user_id, event_id) if not response: return errors.RESPONSE_NOT_FOUND request_travel = response_repository.get_answer_by_question_key_and_response_id('travel_grant', response.id) if not offer: return errors.OFFER_NOT_FOUND elif offer.is_expired(): return errors.OFFER_EXPIRED else: return offer_info(offer, request_travel), 200 except SQLAlchemyError as e: LOGGER.error("Database error encountered: {}".format(e)) return errors.DB_NOT_AVAILABLE except: LOGGER.error("Encountered unknown error: {}".format( traceback.format_exc())) return errors.DB_NOT_AVAILABLE
def get(self): LOGGER.debug('Received get request for camera') args = self.req_parser.parse_args() LOGGER.debug('Parsed Args for site_id: {}'.format(args)) try: site = db.session.query(Site).filter( Site.id == args['site_id']).first() if (not site): LOGGER.warn('Site not found for site_id: {}'.format( args['site_id'])) return SITE_NOT_FOUND cameras = db.session.query(Camera).filter( Camera.site_id == site.id).all() #All cameras at our site if (not cameras): LOGGER.warn( 'No cameras found for site with site_id: {}'.format( args['site_id'])) return CAMERA_NOT_FOUND for camera in cameras: cv2.VideoCapture(camera.ip_address).read() except SQLAlchemyError as e: LOGGER.error("Database error encountered: {}".format(e)) return DB_NOT_AVAILABLE except: LOGGER.error("Encountered unknown error: {}".format( traceback.format_exc())) return DB_NOT_AVAILABLE
def build_response_email_body(answers, language, application_form): #stringifying the dictionary summary, with linebreaks between question/answer pairs stringified_summary = "" for section in application_form.sections: if not section.questions: continue section_translation = section.get_translation(language) if section_translation is None: LOGGER.error('Missing {} translation for section {}.'.format( language, section.id)) section_translation = section.get_translation('en') stringified_summary += section_translation.name + '\n' + '-' * 20 + '\n\n' for question in section.questions: question_translation = question.get_translation(language) if question_translation is None: LOGGER.error('Missing {} translation for question {}.'.format( language, question.id)) question_translation = question.get_translation('en') answer = _find_answer(question, answers) if answer: answer_value = _get_answer_value(answer, answer.question, question_translation) stringified_summary += '{question}\n{answer}\n\n'.format( question=question_translation.headline, answer=answer_value) return stringified_summary
def post(self): req_parser = reqparse.RequestParser() req_parser.add_argument('user_id', type=int, required=True) req_parser.add_argument('email_subject', type=str, required=True) req_parser.add_argument('email_body', type=str, required=True) args = req_parser.parse_args() user = user_repository.get_by_id(args['user_id']) if user is None: return errors.USER_NOT_FOUND try: send_mail(recipient=user.email, sender_name=g.organisation.name, sender_email=g.organisation.email_from, subject=args['email_subject'], body_text=GENERIC_EMAIL_TEMPLATE.format( user_title=user.user_title, user_firstname=user.firstname, user_lastname=user.lastname, body=args['email_body'], ) ) except Exception as e: LOGGER.error('Error sending email: {}'.format(e)) return errors.EMAIL_NOT_SENT
def get(self): email = request.args.get('email') LOGGER.debug("Resending verification email to: {}".format(email)) user = db.session.query(AppUser).filter( func.lower(AppUser.email) == func.lower(email)).first() if not user: LOGGER.debug("User not found for email: {}".format(email)) return USER_NOT_FOUND if user.verify_token is None: user.verify_token = make_code() try: db.session.commit() except IntegrityError: LOGGER.error("Adding verify token for {} failed. ".format(email)) return ADD_VERIFY_TOKEN_FAILED send_mail(recipient=user.email, subject='Baobab Email Verification', body_text=VERIFY_EMAIL_BODY.format(user.user_title, user.firstname, user.lastname, get_baobab_host(), user.verify_token)) LOGGER.debug("Resent email verification to: {}".format(email)) return {}, 201
def post(self): args = self.req_parser.parse_args() registration_id = args['registration_id'] user_id = g.current_user['id'] try: current_user = UserRepository.get_by_id(user_id) registration, offer = RegistrationRepository.get_by_id_with_offer( registration_id) if not current_user.is_registration_admin(offer.event_id): return errors.FORBIDDEN registration.confirm() registration_user = UserRepository.get_by_id(offer.user_id) registration_event = EventRepository.get_by_id(offer.event_id) if _send_registration_confirmation_mail(registration_user, registration_event): registration.confirmation_email_sent_at = datetime.now() db.session.commit() return 'Confirmed Registration for {} {}'.format( registration_user.firstname, registration_user.lastname), 200 except Exception as e: LOGGER.error( 'Error occured while confirming registration with id {}: {}'. format(registration_id, e)) return errors.DB_NOT_AVAILABLE
def build_response_html_answers(answers, language, application_form): """ Stringifying the dictionary answers, for output in a html file, with sections as headers(<h1>), questions as second headings (<h2>) and answers as paragraphs (<p>) """ stringified_answers = "" for section in application_form.sections: if not section.questions: continue section_translation = section.get_translation(language) if section_translation is None: LOGGER.error('Missing {} translation for section {}.'.format( language, section.id)) section_translation = section.get_translation('en') stringified_answers += '<h1>' + section_translation.name + '</h1>' for question in section.questions: question_translation = question.get_translation(language) if question_translation is None: LOGGER.error('Missing {} translation for question {}.'.format( language, question.id)) question_translation = question.get_translation('en') answer = _find_answer(question, answers) if answer: answer_value = _get_answer_value(answer, answer.question, question_translation) stringified_answers += f"<h2> {question_translation.headline} </h2> <p>{answer_value}</p>" return stringified_answers
def post(self): args = self.req_parser.parse_args() event_id = args['event_id'] event = db.session.query(Event).filter( Event.id == event_id).first() if not event: return errors.EVENT_NOT_FOUND registration_form = RegistrationForm( event_id=event_id ) db.session.add(registration_form) try: db.session.commit() except IntegrityError: LOGGER.error( "Failed to add registration form for event : {}".format(event_id)) return errors.ADD_REGISTRATION_FORM_FAILED return registration_form_info(registration_form), 201
def get(self): args = self.req_parser.parse_args() event_id = args['event_id'] user_id = g.current_user['id'] try: offer = db.session.query(Offer).filter(Offer.event_id == event_id).filter(Offer.user_id == user_id).first() request_travel = db.session.query(Answer).join( Question, Question.id == Answer.question_id ).filter( Question.headline == 'Would you like to be considered for a travel award?' ).join(Response, Answer.response_id == Response.id).filter( Response.user_id == user_id, Response.is_submitted == True ).first() if not offer: return errors.OFFER_NOT_FOUND elif offer.is_expired(): return errors.OFFER_EXPIRED else: return offer_info(offer, request_travel), 200 except SQLAlchemyError as e: LOGGER.error("Database error encountered: {}".format(e)) return errors.DB_NOT_AVAILABLE except: LOGGER.error("Encountered unknown error: {}".format( traceback.format_exc())) return errors.DB_NOT_AVAILABLE
def get(self): email = request.args.get('email') LOGGER.debug("Resending verification email to: {}".format(email)) user = user_repository.get_by_email(email, g.organisation.id) if not user: LOGGER.debug( "User not found for email: {} in organisation: {}".format( email, g.organisation.name)) return USER_NOT_FOUND if user.verify_token is None: user.verify_token = make_code() try: db.session.commit() except IntegrityError: LOGGER.error("Adding verify token for {} failed. ".format(email)) return ADD_VERIFY_TOKEN_FAILED email_user('verify-email', template_parameters=dict(system=g.organisation.system_name, organisation=g.organisation.name, host=misc.get_baobab_host(), token=user.verify_token), user=user, subject_parameters=dict(system=g.organisation.system_name)) LOGGER.debug("Resent email verification to: {}".format(email)) return {}, 201
def get(self): try: user_id = verify_token(request.headers.get('Authorization'))['id'] db_offer = db.session.query(Offer).filter( Offer.user_id == user_id).first() if db_offer is None: return errors.OFFER_NOT_FOUND registration = db.session.query(Registration).filter( Registration.offer_id == db_offer.id).first() if registration is None: return 'no Registration', 404 registration_form = db.session.query(RegistrationForm).filter(RegistrationForm.id == registration. registration_form_id).first() if registration_form is None: return errors.REGISTRATION_FORM_NOT_FOUND db_answers = db.session.query(RegistrationAnswer).filter(RegistrationAnswer.registration_id == registration.id).all() response = { 'registration_id': registration.id, 'offer_id': db_offer.id, 'registration_form_id': registration_form.id, 'answers': db_answers } return marshal(response, self.response_fields) except Exception as e: LOGGER.error("Database error encountered: {}".format(e)) return errors.DB_NOT_AVAILABLE
def _get_registrations(event_id, user_id, confirmed, exclude_already_signed_in=False): try: current_user = UserRepository.get_by_id(user_id) if not current_user.is_registration_volunteer(event_id): return errors.FORBIDDEN if(exclude_already_signed_in == True): registrations = RegistrationRepository.get_unsigned_in_attendees( event_id, confirmed=confirmed) guest_registration = GuestRegistrationRepository.get_all_unsigned_guests( event_id) else: if confirmed is None: registrations = RegistrationRepository.get_all_for_event( event_id) else: registrations = RegistrationRepository.get_confirmed_for_event( event_id, confirmed=confirmed) guest_registration = GuestRegistrationRepository.get_all_guests( event_id) registrations = [map_registration_info(info) for info in registrations] guest_registrations = [map_registration_info_guests( info) for info in guest_registration] all_registrations = registrations + guest_registrations # remove duplicates all_registrations_no_duplicates = list() for name, group in itertools.groupby(sorted(all_registrations, key=lambda d : d['user_id']), key=lambda d : d['user_id']): all_registrations_no_duplicates.append(next(group)) return marshal(all_registrations_no_duplicates, registration_admin_fields) except Exception as e: LOGGER.error( 'Error occured while retrieving unconfirmed registrations: {}'.format(e)) return errors.DB_NOT_AVAILABLE
def send_confirmation(self, user, questions, answers, confirmed, event_name): if answers is None: LOGGER.warn( 'Found no answers associated with response with id {response_id}'.format(response_id=user.id)) if questions is None: LOGGER.warn( 'Found no questions associated with application form with id {form_id}'.format(form_id=user.id)) try: # Building the summary, where the summary is a dictionary whose key is the question headline, and the value # is the relevant answer summary = "" for answer in answers: for question in questions: if answer.registration_question_id == question.id: summary += "Question heading :" + question.headline + "\nQuestion Description :" + \ question.description + "\nAnswer :" + _get_answer_value( answer, question) + "\n" subject = event_name + ' Registration' greeting = strings.build_response_email_greeting( user.user_title, user.firstname, user.lastname) if len(summary) <= 0: summary = '\nNo valid questions were answered' body_text = greeting + '\n\n' + REGISTRATION_MESSAGE + \ self.get_confirmed_message( confirmed) + '\n\nHere is a copy of your responses:\n\n' + summary emailer.send_mail(user.email, subject, body_text=body_text) except Exception as e: LOGGER.error('Could not send confirmation email for response with id : {response_id}'.format( response_id=user.id))
def send_confirmation(self, user, questions, answers, event_name): if answers is None: LOGGER.warn( 'Found no answers associated with response with id {response_id}' .format(response_id=user.id)) if questions is None: LOGGER.warn( 'Found no questions associated with application form with id {form_id}' .format(form_id=user.id)) try: # Building the summary, where the summary is a dictionary whose key is the question headline, and the value # is the relevant answer summary = "" for answer in answers: for question in questions: if answer.registration_question_id == question.id: summary += "Question heading :" + question.headline + "\nQuestion Description :" + \ question.description + "\nAnswer :" + _get_answer_value( answer, question) + "\n" subject = event_name + ' Registration' greeting = strings.build_response_email_greeting( user.user_title, user.firstname, user.lastname) if len(summary) <= 0: summary = '\nNo valid questions were answered' body_text = greeting + '\n\n' + 'Thank you for completing your guest registration. Please find a copy of your answers below for future reference.' + '\n\n' + summary + '\n\nKind Regards, The Deep Learning Indaba Team' emailer.send_mail(user.email, subject, body_text=body_text) return True except Exception as e: LOGGER.error( 'Could not send confirmation email for response with id : {response_id}' .format(response_id=user.id)) return False
def _update_db(self, data): LOGGER.debug("Running insert or update") try: self._db.write_points([data]) except InfluxDBClientError as err: LOGGER.error("Error(%s) - %s", err.code, err.content) except requests.ConnectionError as err: LOGGER.error(err)
def delete_active(self, al): if app.config['INFLUXDB_ENABLED'] is True: LOGGER.debug("Running delete series") try: self._db.delete_series(measurement="active", tags={"hash": al.alhash}) except InfluxDBClientError as err: LOGGER.error("Error(%s) - %s", err.code, err.content)
def get_tick_script_content(script): try: byte_ticks = subprocess.check_output(['kapacitor', 'show', script]) return byte_ticks.decode() except subprocess.CalledProcessError: LOGGER.error("Failed to show tick script") except FileNotFoundError: LOGGER.error("Kapacitor is not installed")
def post(self, invitedGuest=False): args = self.req_parser.parse_args() email = args['email'] firstname = args['firstname'] lastname = args['lastname'] user_title = args['user_title'] policy_agreed = args['policy_agreed'] user_primaryLanguage = args['language'] if (invitedGuest): password = self.randomPassword() else: password = args['password'] if (password is None): return MISSING_PASSWORD if not policy_agreed: return POLICY_NOT_AGREED LOGGER.info("Registering email: {}".format(email)) user = AppUser(email=email, firstname=firstname, lastname=lastname, user_title=user_title, password=password, organisation_id=g.organisation.id) user.user_primaryLanguage = user_primaryLanguage db.session.add(user) try: db.session.commit() except IntegrityError: LOGGER.error("email: {} already in use".format(email)) return EMAIL_IN_USE if (not invitedGuest): email_user( 'verify-email', template_parameters=dict(system=g.organisation.system_name, organisation=g.organisation.name, host=misc.get_baobab_host(), token=user.verify_token), user=user, subject_parameters=dict(system=g.organisation.system_name)) LOGGER.debug("Sent verification email to {}".format(user.email)) else: user.verified_email = True try: db.session.commit() except IntegrityError: LOGGER.error("Unable to verify email: {}".format(email)) return VERIFY_EMAIL_INVITED_GUEST return user_info(user, []), 201
def send_mail(recipient, subject, body_text='', body_html='', charset='UTF-8', mail_type='AMZ', file_name='', file_path=''): '''[summary] Arguments: recipient {[type]} -- [description] subject {[type]} -- [description] body_text {[type]} -- [description] Keyword Arguments: body_html {[type]} -- [description] (default: {None}) type {str} -- [description] (default: {'AMZ'}) Raises: e -- [description] ''' if (not DEBUG): if mail_type == 'AMZ': try: msg = MIMEMultipart() msg['Subject'] = subject msg['From'] = email.utils.formataddr( (SMTP_SENDER_NAME, SMTP_SENDER_EMAIL)) msg['To'] = recipient body_part1 = MIMEText(body_text, 'plain', _charset=charset) body_part2 = MIMEText(body_html, 'html', _charset=charset) if file_name != "" and file_path != "": attachment = open(file_path, "rb") part = MIMEBase('application', 'octet-stream') part.set_payload(attachment.read()) encoders.encode_base64(part) part.add_header('Content-Disposition', "attachment; filename= %s" % file_name) msg.attach(part) msg.attach(body_part1) msg.attach(body_part2) server = smtplib.SMTP(SMTP_HOST, SMTP_PORT) server.ehlo() server.starttls() server.ehlo() server.login(SMTP_USERNAME, SMTP_PASSWORD) server.sendmail(SMTP_SENDER_EMAIL, recipient, msg.as_string()) server.close() except Exception as e: LOGGER.error("Exception {} while trying to send email: {}, {}".format(e, traceback.format_exc())) raise e else: LOGGER.debug('Recipient : {recipient}'.format(recipient=recipient)) LOGGER.debug('Subject : {subject}'.format(subject=subject)) LOGGER.debug('Body Text : {body}'.format(body=body_text)) LOGGER.debug('Body HTML : {body}'.format(body=body_html))
def _send_registration_confirmation_mail(user, event): try: emailer.email_user('registration-confirmed', event=event, user=user) return True except Exception as e: LOGGER.error('Error occured while sending email to {}: {}'.format( user.email, e)) return False
def _resolve_and_close(self, key): jira = self._connect() if jira: issue = jira.issue(key) if not issue: LOGGER.error("Failed to get issue") return self._resolve(jira, issue) self._close(jira, issue)
def put(self): args = self.req_parser.parse_args() email = args['email'] firstname = args['firstname'] lastname = args['lastname'] user_title = args['user_title'] nationality_country_id = args['nationality_country_id'] residence_country_id = args['residence_country_id'] user_gender = args['user_gender'] affiliation = args['affiliation'] department = args['department'] user_disability = args['user_disability'] user_category_id = args['user_category_id'] user_dateOfBirth = datetime.strptime((args['user_dateOfBirth']), '%Y-%m-%dT%H:%M:%S.%fZ') user_primaryLanguage = args['user_primaryLanguage'] user = db.session.query(AppUser).filter( AppUser.id == g.current_user['id']).first() if user.email != email: user.update_email(email) user.firstname = firstname user.lastname = lastname user.user_title = user_title user.nationality_country_id = nationality_country_id user.residence_country_id = residence_country_id user.user_gender = user_gender user.affiliation = affiliation user.department = department user.user_disability = user_disability user.user_category_id = user_category_id user.user_dateOfBirth = user_dateOfBirth user.user_primaryLanguage = user_primaryLanguage try: db.session.commit() except IntegrityError: LOGGER.error("email {} already in use".format(email)) return EMAIL_IN_USE if not user.verified_email: send_mail(recipient=user.email, subject='Baobab Email Re-Verification', body_text=VERIFY_EMAIL_BODY.format( user_title, firstname, lastname, get_baobab_host(), user.verify_token)) LOGGER.debug("Sent re-verification email to {}".format(user.email)) roles = db.session.query(EventRole).filter( EventRole.user_id == user.id).all() return user_info(user, roles), 200
def value_display(self): question_translation = self.question.get_translation(self.response.language) if question_translation is None: LOGGER.error('Missing {} translation for question {}'.format(self.response.language, self.question.id)) question_translation = self.question.get_translation('en') if self.question.type == 'multi-choice' and question_translation.options is not None: option = [option for option in question_translation.options if option['value'] == self.value] if option: return option[0]['label'] return self.value