From fdee6cbfb2675e5868e52d033ebf24c48b15ed85 Mon Sep 17 00:00:00 2001 From: Rebecca Law Date: Wed, 14 Aug 2019 13:23:20 +0100 Subject: [PATCH] As per PR comments: - Remove Organisation.services - added backref='services' to Services.organisation relationship and removed redundant foreign_keys argument. --- app/dao/services_dao.py | 1 - app/models.py | 8 +------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/app/dao/services_dao.py b/app/dao/services_dao.py index 85d2a6e17..199c1a5c7 100644 --- a/app/dao/services_dao.py +++ b/app/dao/services_dao.py @@ -293,7 +293,6 @@ def dao_create_service( insert_service_sms_sender(service, current_app.config['FROM_NUMBER']) if organisation: - # service.organisation = organisation service.organisation_id = organisation.id service.organisation_type = organisation.organisation_type if organisation.email_branding: diff --git a/app/models.py b/app/models.py index 0c454fb85..1879d5827 100644 --- a/app/models.py +++ b/app/models.py @@ -349,12 +349,6 @@ class Organisation(db.Model): active = db.Column(db.Boolean, nullable=False, default=True) created_at = db.Column(db.DateTime, nullable=False, default=datetime.datetime.utcnow) updated_at = db.Column(db.DateTime, nullable=True, onupdate=datetime.datetime.utcnow) - - services = db.relationship( - 'Service', - uselist=True, - backref=db.backref('services')) - agreement_signed = db.Column(db.Boolean, nullable=True) agreement_signed_at = db.Column(db.DateTime, nullable=True) agreement_signed_by_id = db.Column( @@ -480,7 +474,7 @@ class Service(db.Model, Versioned): go_live_at = db.Column(db.DateTime, nullable=True) organisation_id = db.Column(UUID(as_uuid=True), db.ForeignKey('organisation.id'), index=True, nullable=True) - organisation = db.relationship('Organisation', foreign_keys=[organisation_id]) + organisation = db.relationship('Organisation', backref='services') email_branding = db.relationship( 'EmailBranding',