def service_add_email_reply_to(service_id): form = ServiceReplyToEmailForm() first_email_address = current_service.count_email_reply_to_addresses == 0 is_default = first_email_address if first_email_address else form.is_default.data if form.validate_on_submit(): try: notification_id = service_api_client.verify_reply_to_email_address( service_id, form.email_address.data)["data"]["id"] except HTTPError as e: error_msg = "Your service already uses '{}' as an email reply-to address.".format( form.email_address.data) if e.status_code == 400 and error_msg == e.message: flash(error_msg, 'error') return redirect( url_for('.service_email_reply_to', service_id=service_id)) else: raise e return redirect( url_for('.service_verify_reply_to_address', service_id=service_id, notification_id=notification_id, is_default=is_default)) return render_template('views/service-settings/email-reply-to/add.html', form=form, first_email_address=first_email_address)
def service_add_email_reply_to(service_id): form = ServiceReplyToEmailForm() first_email_address = current_service.count_email_reply_to_addresses == 0 if form.validate_on_submit(): service_api_client.add_reply_to_email_address( current_service.id, email_address=form.email_address.data, is_default=first_email_address if first_email_address else form.is_default.data) return redirect( url_for('.service_email_reply_to', service_id=service_id)) return render_template('views/service-settings/email-reply-to/add.html', form=form, first_email_address=first_email_address)
def service_edit_email_reply_to(service_id, reply_to_email_id): form = ServiceReplyToEmailForm() reply_to_email_address = current_service.get_email_reply_to_address( reply_to_email_id) if request.method == 'GET': form.email_address.data = reply_to_email_address['email_address'] form.is_default.data = reply_to_email_address['is_default'] if form.validate_on_submit(): if form.email_address.data == reply_to_email_address["email_address"]: service_api_client.update_reply_to_email_address( current_service.id, reply_to_email_id=reply_to_email_id, email_address=form.email_address.data, is_default=True if reply_to_email_address['is_default'] else form.is_default.data) return redirect( url_for('.service_email_reply_to', service_id=service_id)) try: notification_id = service_api_client.verify_reply_to_email_address( service_id, form.email_address.data)["data"]["id"] except HTTPError as e: error_msg = "Your service already uses ‘{}’ as a reply-to email address.".format( form.email_address.data) if e.status_code == 400 and error_msg == e.message: flash(error_msg, 'error') return redirect( url_for('.service_email_reply_to', service_id=service_id)) else: raise e return redirect( url_for('.service_verify_reply_to_address', service_id=service_id, notification_id=notification_id, is_default=True if reply_to_email_address['is_default'] else form.is_default.data, replace=reply_to_email_id)) if (request.endpoint == "main.service_confirm_delete_email_reply_to"): flash( _('Are you sure you want to delete this reply-to email address?'), 'delete') return render_template( 'views/service-settings/email-reply-to/edit.html', form=form, reply_to_email_address_id=reply_to_email_id, )
def service_edit_email_reply_to(service_id, reply_to_email_id): form = ServiceReplyToEmailForm() reply_to_email_address = service_api_client.get_reply_to_email_address(service_id, reply_to_email_id) if request.method == 'GET': form.email_address.data = reply_to_email_address['email_address'] form.is_default.data = reply_to_email_address['is_default'] if form.validate_on_submit(): service_api_client.update_reply_to_email_address( current_service['id'], reply_to_email_id=reply_to_email_id, email_address=form.email_address.data, is_default=True if reply_to_email_address['is_default'] else form.is_default.data ) return redirect(url_for('.service_email_reply_to', service_id=service_id)) return render_template( 'views/service-settings/email-reply-to/edit.html', form=form, reply_to_email_address_id=reply_to_email_address['id'])
def service_edit_email_reply_to(service_id, reply_to_email_id): form = ServiceReplyToEmailForm() reply_to_email_address = current_service.get_email_reply_to_address( reply_to_email_id) if request.method == 'GET': form.email_address.data = reply_to_email_address['email_address'] form.is_default.data = reply_to_email_address['is_default'] if form.validate_on_submit(): service_api_client.update_reply_to_email_address( current_service.id, reply_to_email_id=reply_to_email_id, email_address=form.email_address.data, is_default=True if reply_to_email_address['is_default'] else form.is_default.data) return redirect( url_for('.service_email_reply_to', service_id=service_id)) if (request.endpoint == "main.service_confirm_delete_email_reply_to"): flash("Are you sure you want to delete this email reply-to address?", 'delete') return render_template( 'views/service-settings/email-reply-to/edit.html', form=form, reply_to_email_address_id=reply_to_email_id, )