def service_add_sms_sender(service_id): form = ServiceSmsSenderForm() first_sms_sender = current_service.count_sms_senders == 0 if form.validate_on_submit(): service_api_client.add_sms_sender( current_service.id, sms_sender=form.sms_sender.data.replace('\r', '') or None, is_default=first_sms_sender if first_sms_sender else form.is_default.data) return redirect(url_for('.service_sms_senders', service_id=service_id)) return render_template('views/service-settings/sms-sender/add.html', form=form, first_sms_sender=first_sms_sender)
def service_add_sms_sender(service_id): form = ServiceSmsSenderForm() blocklist_values = service_api_client.get_blocklist_for_service( service_id)['blocklist'] blocklist_validator = next(v for v in form.sms_sender.validators if type(v) == SenderBlocklistValidator) blocklist_validator.values = blocklist_values first_sms_sender = current_service.count_sms_senders == 0 if form.validate_on_submit(): service_api_client.add_sms_sender( current_service.id, sms_sender=form.sms_sender.data.replace('\r', '') or None, is_default=first_sms_sender if first_sms_sender else form.is_default.data) return redirect(url_for('.service_sms_senders', service_id=service_id)) return render_template('views/service-settings/sms-sender/add.html', form=form, first_sms_sender=first_sms_sender)