mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-30 12:23:04 -05:00
no longer add an annual billing entry creating a service
this is now handled by a separate call from the admin app
This commit is contained in:
@@ -41,7 +41,6 @@ from app.models import (
|
||||
)
|
||||
from app.statsd_decorators import statsd
|
||||
from app.utils import get_london_month_from_utc_column, get_london_midnight_in_utc
|
||||
from app.dao.annual_billing_dao import dao_insert_annual_billing_for_this_year
|
||||
|
||||
DEFAULT_SERVICE_PERMISSIONS = [
|
||||
SMS_TYPE,
|
||||
@@ -155,7 +154,7 @@ def dao_fetch_service_by_id_and_user(service_id, user_id):
|
||||
|
||||
@transactional
|
||||
@version_class(Service)
|
||||
def dao_create_service(service, user, free_sms_fragment_limit, service_id=None, service_permissions=None):
|
||||
def dao_create_service(service, user, service_id=None, service_permissions=None):
|
||||
# the default property does not appear to work when there is a difference between the sqlalchemy schema and the
|
||||
# db schema (ie: during a migration), so we have to set sms_sender manually here. After the GOVUK sms_sender
|
||||
# migration is completed, this code should be able to be removed.
|
||||
@@ -177,7 +176,6 @@ def dao_create_service(service, user, free_sms_fragment_limit, service_id=None,
|
||||
|
||||
# do we just add the default - or will we get a value from FE?
|
||||
insert_service_sms_sender(service, current_app.config['FROM_NUMBER'])
|
||||
dao_insert_annual_billing_for_this_year(service, free_sms_fragment_limit)
|
||||
db.session.add(service)
|
||||
|
||||
|
||||
|
||||
@@ -153,24 +153,20 @@ def get_service_by_id(service_id):
|
||||
@service_blueprint.route('', methods=['POST'])
|
||||
def create_service():
|
||||
data = request.get_json()
|
||||
errors = {
|
||||
required_field: ['Missing data for required field.']
|
||||
for required_field in ['user_id', 'free_sms_fragment_limit']
|
||||
if not data.get(required_field)
|
||||
}
|
||||
if errors:
|
||||
|
||||
if not data.get('user_id'):
|
||||
errors = {'user_id': ['Missing data for required field.']}
|
||||
raise InvalidRequest(errors, status_code=400)
|
||||
|
||||
# validate json with marshmallow
|
||||
service_schema.load(data)
|
||||
|
||||
user = get_user_by_id(data.pop('user_id', None))
|
||||
free_sms_fragment_limit = data.pop('free_sms_fragment_limit')
|
||||
user = get_user_by_id(data.pop('user_id'))
|
||||
|
||||
# unpack valid json into service object
|
||||
valid_service = Service.from_json(data)
|
||||
|
||||
dao_create_service(valid_service, user, free_sms_fragment_limit)
|
||||
dao_create_service(valid_service, user)
|
||||
return jsonify(data=service_schema.dump(valid_service).data), 201
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user