Part one of three for Release 1.6.0
This commit is contained in:
parent
236db65bb0
commit
731e8da673
|
@ -211,6 +211,16 @@ def run_full_export():
|
|||
click.echo('This system is not configured to run exports. Ingoring.')
|
||||
|
||||
|
||||
@app.cli.command()
|
||||
def copyorgnames():
|
||||
"""Used for copying organization names on resources, studies, and investigators from the related organization
|
||||
model over to a text field"""
|
||||
click.echo('Copying Org Names')
|
||||
from app import data_loader
|
||||
data_loader = data_loader.DataLoader()
|
||||
data_loader.copy_org_names()
|
||||
|
||||
|
||||
from app import views
|
||||
from app.model.email_log import EmailLog
|
||||
from app.model.study import Study
|
||||
|
|
|
@ -349,3 +349,24 @@ class DataLoader:
|
|||
|
||||
def __increment_id_sequence(self, model):
|
||||
db.session.execute(Sequence(model.__tablename__ + '_id_seq'))
|
||||
|
||||
def copy_org_names(self):
|
||||
resources = db.session.query(Resource).all()
|
||||
for resource in resources:
|
||||
if resource.organization_id is not None:
|
||||
resource.organization_name = resource.organization.name
|
||||
db.session.add(resource)
|
||||
|
||||
studies = db.session.query(Study).all()
|
||||
for study in studies:
|
||||
if study.organization_id is not None:
|
||||
study.organization_name = study.organization.name
|
||||
db.session.add(study)
|
||||
|
||||
investigators = db.session.query(Investigator).all()
|
||||
for investigator in investigators:
|
||||
if investigator.organization_id is not None:
|
||||
investigator.organization_name = investigator.organization.name
|
||||
db.session.add(investigator)
|
||||
|
||||
db.session.commit()
|
||||
|
|
|
@ -9,5 +9,6 @@ class Investigator(db.Model):
|
|||
last_updated = db.Column(db.DateTime(timezone=True), default=func.now())
|
||||
name = db.Column(db.String)
|
||||
title = db.Column(db.String)
|
||||
organization_name = db.Column(db.String)
|
||||
organization_id = db.Column('organization_id', db.Integer, db.ForeignKey('organization.id'))
|
||||
bio_link = db.Column(db.String)
|
||||
|
|
|
@ -15,6 +15,7 @@ class Resource(db.Model):
|
|||
last_updated = db.Column(db.DateTime(timezone=True), default=func.now())
|
||||
description = db.Column(db.String)
|
||||
insurance = db.Column(db.String)
|
||||
organization_name = db.Column(db.String)
|
||||
organization_id = db.Column('organization_id', db.Integer,
|
||||
db.ForeignKey('organization.id'))
|
||||
phone = db.Column(db.String)
|
||||
|
|
|
@ -38,6 +38,7 @@ class Study(db.Model):
|
|||
coordinator_email = db.Column(db.String)
|
||||
eligibility_url = db.Column(db.String)
|
||||
results_url = db.Column(db.String)
|
||||
organization_name = db.Column(db.String)
|
||||
organization_id = db.Column('organization_id', db.Integer,
|
||||
db.ForeignKey('organization.id'))
|
||||
location = db.Column(db.String)
|
||||
|
|
|
@ -137,7 +137,7 @@ class OrganizationSchema(ModelSchema):
|
|||
class InvestigatorSchema(ModelSchema):
|
||||
class Meta:
|
||||
model = Investigator
|
||||
fields = ('id', 'last_updated', 'name', 'title', 'organization_id', 'organization', 'bio_link',
|
||||
fields = ('id', 'last_updated', 'name', 'title', 'organization_name', 'organization_id', 'organization', 'bio_link',
|
||||
'_links')
|
||||
organization_id = fields.Integer(required=False, allow_none=True)
|
||||
organization = fields.Nested(OrganizationSchema(), dump_only=True, allow_none=True)
|
||||
|
@ -298,7 +298,7 @@ class InvestigatorsOnStudySchema(ModelSchema):
|
|||
class ResourceSchema(ModelSchema):
|
||||
class Meta:
|
||||
model = Resource
|
||||
fields = ('id', 'type', 'title', 'last_updated', 'description', 'organization_id', 'phone', 'website',
|
||||
fields = ('id', 'type', 'title', 'last_updated', 'description', 'organization_name', 'organization_id', 'phone', 'website',
|
||||
'contact_email', 'video_code', 'is_uva_education_content', 'organization', 'resource_categories',
|
||||
'is_draft', 'ages', 'insurance', 'phone_extension', 'languages', 'covid19_categories', '_links')
|
||||
organization_id = fields.Integer(required=False, allow_none=True)
|
||||
|
@ -353,7 +353,7 @@ class EventSchema(ModelSchema):
|
|||
fields = ('id', 'type', 'title', 'last_updated', 'description', 'date', 'time', 'ticket_cost', 'organization_id',
|
||||
'primary_contact', 'location_name', 'street_address1', 'street_address2', 'city', 'state', 'zip',
|
||||
'phone', 'website', 'contact_email', 'video_code', 'is_uva_education_content', 'is_draft',
|
||||
'organization', 'resource_categories', 'latitude', 'longitude', 'ages', 'insurance',
|
||||
'organization', 'organization_name', 'resource_categories', 'latitude', 'longitude', 'ages', 'insurance',
|
||||
'phone_extension', 'languages', 'covid19_categories', '_links')
|
||||
id = fields.Integer(required=False, allow_none=True)
|
||||
organization_id = fields.Integer(required=False, allow_none=True)
|
||||
|
@ -407,7 +407,7 @@ class LocationSchema(ModelSchema):
|
|||
model = Location
|
||||
fields = ('id', 'type', 'title', 'last_updated', 'description', 'primary_contact', 'organization_id',
|
||||
'street_address1', 'street_address2', 'city', 'state', 'zip', 'phone', 'email', 'website',
|
||||
'contact_email', 'video_code', 'is_uva_education_content', 'organization', 'resource_categories',
|
||||
'contact_email', 'video_code', 'is_uva_education_content', 'organization', 'organization_name', 'resource_categories',
|
||||
'latitude', 'longitude', '_links', 'ages', 'insurance', 'phone_extension', 'languages',
|
||||
'covid19_categories', 'is_draft')
|
||||
id = fields.Integer(required=False, allow_none=True)
|
||||
|
@ -460,7 +460,7 @@ class StudySchema(ModelSchema):
|
|||
class Meta:
|
||||
model = Study
|
||||
fields = ('id', 'title', 'short_title', 'short_description', 'image_url', 'last_updated', 'description',
|
||||
'participant_description', 'benefit_description', 'coordinator_email', 'organization_id',
|
||||
'participant_description', 'benefit_description', 'coordinator_email', 'organization_id', 'organization_name',
|
||||
'organization', 'location', 'status', 'study_categories', 'study_investigators', 'study_users',
|
||||
'eligibility_url', 'results_url', 'ages', 'languages', 'num_visits', '_links')
|
||||
organization_id = fields.Integer(required=False, allow_none=True)
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
"""empty message
|
||||
|
||||
Revision ID: c29fc0a07930
|
||||
Revises: 62150b1fb708
|
||||
Create Date: 2020-04-14 16:39:28.460452
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'c29fc0a07930'
|
||||
down_revision = '62150b1fb708'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('investigator', sa.Column('organization_name', sa.String(), nullable=True))
|
||||
op.add_column('resource', sa.Column('organization_name', sa.String(), nullable=True))
|
||||
op.add_column('study', sa.Column('organization_name', sa.String(), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('study', 'organization_name')
|
||||
op.drop_column('resource', 'organization_name')
|
||||
op.drop_column('investigator', 'organization_name')
|
||||
# ### end Alembic commands ###
|
|
@ -27,6 +27,6 @@
|
|||
|
||||
<body>
|
||||
<app-root></app-root>
|
||||
<script src="runtime-es2015.858f8dd898b75fe86926.js" type="module"></script><script src="polyfills-es2015.696ad2b135b52dd9855f.js" type="module"></script><script src="runtime-es5.741402d1d47331ce975c.js" nomodule></script><script src="polyfills-es5.6ba1fc6238374eb32f77.js" nomodule></script><script src="main-es2015.4daa419b900e1491b34c.js" type="module"></script><script src="main-es5.52f8a199d3a2c9f0ac93.js" nomodule></script></body>
|
||||
<script src="runtime-es2015.858f8dd898b75fe86926.js" type="module"></script><script src="polyfills-es2015.696ad2b135b52dd9855f.js" type="module"></script><script src="runtime-es5.741402d1d47331ce975c.js" nomodule></script><script src="polyfills-es5.6ba1fc6238374eb32f77.js" nomodule></script><script src="main-es2015.a342640e34907814b8c8.js" type="module"></script><script src="main-es5.992959cd91a4b5afbee0.js" nomodule></script></body>
|
||||
|
||||
</html>
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue