From 67dc0e188b706cbc5dec00ce4810e02d87ff5e60 Mon Sep 17 00:00:00 2001 From: Francesco Siddi Date: Mon, 23 Jun 2014 15:08:04 +0200 Subject: [PATCH] Attempt at fixing cross db FK issue --- blender-bfct/application/controllers/admin.py | 10 +++++----- .../application/models/applications.py | 18 ++++++++++++++---- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/blender-bfct/application/controllers/admin.py b/blender-bfct/application/controllers/admin.py index 0faf11e..882c130 100644 --- a/blender-bfct/application/controllers/admin.py +++ b/blender-bfct/application/controllers/admin.py @@ -51,11 +51,11 @@ class ApplicationView(CustomModelView): column_labels = {'user.first_name' : 'First Name', 'user.last_name' : 'Last Name'} column_searchable_list = ('website', 'status') can_create = False - form_ajax_refs = { - 'user': { - 'fields': (User.email, User.first_name, User.id) - } - } + # form_ajax_refs = { + # 'user': { + # 'fields': (User.email, User.first_name, User.id) + # } + # } # Create admin diff --git a/blender-bfct/application/models/applications.py b/blender-bfct/application/models/applications.py index 9008c26..c9fe40c 100644 --- a/blender-bfct/application/models/applications.py +++ b/blender-bfct/application/models/applications.py @@ -10,8 +10,9 @@ from sqlalchemy.ext.associationproxy import association_proxy class Application(db.Model): __table_args__ = {'schema': 'blender-bfct'} id = db.Column(db.Integer(), primary_key=True) - blender_id = db.Column(db.Integer(), db.ForeignKey(User.id), nullable=False) - user = db.relationship('User') + #blender_id = db.Column(db.Integer(), db.ForeignKey(User.id), nullable=False) + #user = db.relationship('User') + blender_id = db.Column(db.Integer(), nullable=False) network_profile = db.Column(db.String(255)) website = db.Column(db.String(255)) city_country = db.Column(db.String(255)) @@ -40,6 +41,10 @@ class Application(db.Model): else: return '--' + @property + def user(self): + return User.query.get_or_404(self.blender_id) + class Skill(db.Model): @@ -61,6 +66,11 @@ class ReviewersApplications(db.Model): id = db.Column(db.Integer(), primary_key=True) application_id = db.Column(db.Integer(), db.ForeignKey(Application.id), nullable=False) application = db.relationship('Application') - reviewer_blender_id = db.Column(db.Integer(), db.ForeignKey(User.id), nullable=False) - reviewer = db.relationship('User') + #reviewer_blender_id = db.Column(db.Integer(), db.ForeignKey(User.id), nullable=False) + #reviewer = db.relationship('User') + reviewer_blender_id = db.Column(db.Integer(), nullable=False) approved = db.Column(db.Boolean(), nullable=False) + + @property + def reviewer(self): + return User.query.get_or_404(self.reviewer_blender_id)