remove organisation from api

This commit is contained in:
Leo Hemsted
2018-02-07 11:39:33 +00:00
parent 80b3ca8a55
commit ba20010f27
7 changed files with 17 additions and 119 deletions

View File

@@ -161,8 +161,6 @@ def register_blueprint(application):
email_branding_blueprint.before_request(requires_admin_auth)
application.register_blueprint(email_branding_blueprint, url_prefix='/email-branding')
# TODO: remove this route after admin is updated to refer to email branding
application.register_blueprint(email_branding_blueprint, url_prefix='/organisation')
dvla_organisation_blueprint.before_request(requires_admin_auth)
application.register_blueprint(dvla_organisation_blueprint, url_prefix='/dvla_organisations')

View File

@@ -21,17 +21,13 @@ register_errors(email_branding_blueprint)
@email_branding_blueprint.route('', methods=['GET'])
def get_email_branding_options():
email_branding_options = [o.serialize() for o in dao_get_email_branding_options()]
key = 'organisations' if request.path.startswith('/organisation') else 'email_branding'
return jsonify(**{key: email_branding_options})
return jsonify(email_branding=email_branding_options)
@email_branding_blueprint.route('/<uuid:email_branding_id>', methods=['GET'])
def get_email_branding_by_id(email_branding_id):
email_branding = dao_get_email_branding_by_id(email_branding_id)
# TODO: remove this switch after admin is updated to refer to email branding
key = 'organisation' if request.path.startswith('/organisation') else 'email_branding'
return jsonify(**{key: email_branding.serialize()})
return jsonify(email_branding=email_branding.serialize())
@email_branding_blueprint.route('', methods=['POST'])

View File

@@ -148,25 +148,6 @@ class BrandingTypes(db.Model):
name = db.Column(db.String(255), primary_key=True)
# TODO: remove this model after admin is updated to refer to email branding
class Organisation(db.Model):
__tablename__ = 'organisation'
id = db.Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
colour = db.Column(db.String(7), nullable=True)
logo = db.Column(db.String(255), nullable=True)
name = db.Column(db.String(255), nullable=True)
def serialize(self):
serialized = {
"id": str(self.id),
"colour": self.colour,
"logo": self.logo,
"name": self.name,
}
return serialized
class EmailBranding(db.Model):
__tablename__ = 'email_branding'
id = db.Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
@@ -257,8 +238,6 @@ class Service(db.Model, Versioned):
created_by = db.relationship('User')
created_by_id = db.Column(UUID(as_uuid=True), db.ForeignKey('users.id'), index=True, nullable=False)
prefix_sms = db.Column(db.Boolean, nullable=False, default=True)
organisation_id = db.Column(UUID(as_uuid=True), db.ForeignKey('organisation.id'), index=True, nullable=True)
organisation = db.relationship('Organisation')
dvla_organisation_id = db.Column(
db.String,
db.ForeignKey('dvla_organisation.id'),

View File

@@ -203,8 +203,6 @@ class ServiceSchema(BaseSchema):
branding = field_for(models.Service, 'branding')
dvla_organisation = field_for(models.Service, 'dvla_organisation')
permissions = fields.Method("service_permissions")
# TODO: remove this variable after admin is updated to refer to email branding
organisation = field_for(models.Service, 'organisation')
email_branding = field_for(models.Service, 'email_branding')
override_flag = False
reply_to_email_address = fields.Method(method_name="get_reply_to_email_address")
@@ -285,8 +283,6 @@ class DetailedServiceSchema(BaseSchema):
'template_statistics',
'service_provider_stats',
'service_notification_stats',
# TODO: remove this field after admin is updated to refer to email branding
'organisation',
'email_branding',
'service_sms_senders',
'monthly_billing',

View File

@@ -184,11 +184,6 @@ def update_service(service_id):
if org_type:
service.crown = org_type == 'central'
# TODO: remove this block after admin is updated to refer to email branding
if 'organisation' in req_json:
org_id = req_json['organisation']
service.email_branding = None if not org_id else EmailBranding.query.get(org_id)
if 'email_branding' in req_json:
email_branding_id = req_json['email_branding']
service.email_branding = None if not email_branding_id else EmailBranding.query.get(email_branding_id)