Skip to content

Commit

Permalink
fix: admin & SCHEMA: annotation, assertion add datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
moogoo78 committed May 30, 2024
1 parent a3d66bf commit 5eb8d4e
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
"""notes-disposition-assertion-annotation-date
Revision ID: 0dc9eae4c472
Revises: 60df15f0646f
Create Date: 2024-05-29 10:56:15.139121
"""
from alembic import op
import sqlalchemy as sa

import geoalchemy2

# revision identifiers, used by Alembic.
revision = '0dc9eae4c472'
down_revision = '60df15f0646f'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('alternative_name',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=500), nullable=True),
sa.Column('lang', sa.String(length=8), nullable=True),
sa.Column('named_area_id', sa.Integer(), nullable=False),
sa.Column('created', sa.DateTime(), nullable=True),
sa.Column('updated', sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(['named_area_id'], ['named_area.id'], ),
sa.PrimaryKeyConstraint('id', 'named_area_id')
)
op.drop_table('addon_geoname')
op.add_column('multimedia_object_annotation', sa.Column('datetime', sa.DateTime(), nullable=True))
op.add_column('record_assertion', sa.Column('datetime', sa.DateTime(), nullable=True))
op.add_column('unit', sa.Column('disposition', sa.String(length=500), nullable=True))
op.add_column('unit', sa.Column('notes', sa.Text(), nullable=True))
op.add_column('unit_annotation', sa.Column('datetime', sa.DateTime(), nullable=True))
op.add_column('unit_assertion', sa.Column('datetime', sa.DateTime(), nullable=True))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('unit_assertion', 'datetime')
op.drop_column('unit_annotation', 'datetime')
op.drop_column('unit', 'notes')
op.drop_column('unit', 'disposition')
op.drop_column('record_assertion', 'datetime')
op.drop_column('multimedia_object_annotation', 'datetime')
op.create_table('addon_geoname',
sa.Column('geonameid', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('name', sa.VARCHAR(length=500), autoincrement=False, nullable=True),
sa.Column('asciiname', sa.VARCHAR(length=500), autoincrement=False, nullable=True),
sa.Column('alternatenames', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('latitude', sa.VARCHAR(length=500), autoincrement=False, nullable=True),
sa.Column('longitude', sa.VARCHAR(length=500), autoincrement=False, nullable=True),
sa.Column('feature_class', sa.VARCHAR(length=500), autoincrement=False, nullable=True),
sa.Column('feature_code', sa.VARCHAR(length=500), autoincrement=False, nullable=True),
sa.Column('country_code', sa.VARCHAR(length=2), autoincrement=False, nullable=True),
sa.Column('cc2', sa.VARCHAR(length=500), autoincrement=False, nullable=True),
sa.Column('admin1_code', sa.VARCHAR(length=500), autoincrement=False, nullable=True),
sa.Column('admin2_code', sa.VARCHAR(length=500), autoincrement=False, nullable=True),
sa.Column('admin3_code', sa.VARCHAR(length=500), autoincrement=False, nullable=True),
sa.Column('admin4_code', sa.VARCHAR(length=500), autoincrement=False, nullable=True),
sa.Column('population', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('elevation', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('dem', sa.VARCHAR(length=500), autoincrement=False, nullable=True),
sa.Column('timezone', sa.VARCHAR(length=500), autoincrement=False, nullable=True),
sa.Column('modification_date', sa.VARCHAR(length=500), autoincrement=False, nullable=True),
sa.PrimaryKeyConstraint('geonameid', name='addon_geoname_pkey')
)
op.drop_table('alternative_name')
# ### end Alembic commands ###
3 changes: 3 additions & 0 deletions app/blueprints/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1003,8 +1003,11 @@ def dispatch_request(self, item_id):
if 'filter_by' in self.register:
if self.register['filter_by'] == 'organization':
self.item = self.register['model'](organization_id=current_user.organization_id)
else:
self.item = self.register['model']()
else:
self.item = self.register['model']()

session.add(self.item)

#change_log = ChangeLog(self.item)
Expand Down
4 changes: 3 additions & 1 deletion app/blueprints/admin_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,10 @@
'label': {'label': '標題'},
'input_type': {'label': '管理', 'type': 'select', 'options': AnnotationType.INPUT_TYPE_OPTIONS, 'display_func': AnnotationType.get_input_type_display },
'collection': { 'label': '資料集', 'type': 'select', 'current_user': 'organization.collections', 'display': 'label'},
'sort': {'label': '排序', 'type': 'number'},
'target': {'label': 'target', 'type': 'select', 'options': AnnotationType.TARGET_OPTIONS, 'display_func': AnnotationType.get_target_display},
},
'list_display': ('name', 'label', 'input_type', 'collection'),
'list_display': ('name', 'label', 'target','input_type', 'sort', 'collection'),
},
'user_list_category': {
'name': 'user_list_category',
Expand Down
12 changes: 11 additions & 1 deletion app/models/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ class Unit(Base, TimestampMixin, UpdateMixin):
annotations = relationship('Annotation')
propagations = relationship('Propagation')
# abcd: Disposition (in collection/missing...)
#disposition = Column(String(500)) # DwC curatorial extension r. 14: 'The current disposition of the catalogued item. Examples: "in collection", "missing", "source gone", "voucher elsewhere", "duplicates elsewhere","consumed".'
disposition = Column(String(500)) # DwC curatorial extension r. 14: 'The current disposition of the catalogued item. Examples: "in collection", "missing", "source gone", "voucher elsewhere", "duplicates elsewhere","consumed".' 保存狀況

# observation
source_data = Column(JSONB)
Expand All @@ -761,6 +761,8 @@ class Unit(Base, TimestampMixin, UpdateMixin):
multimedia_objects = relationship('MultimediaObject')
legal_statement_id = Column(ForeignKey('legal_statement.id', ondelete='SET NULL'))

notes = Column(Text)

@property
def ark(self):
for x in self.pids:
Expand Down Expand Up @@ -1271,6 +1273,10 @@ def assertion_type_id(self):
def assertion_type(self):
return relationship('AssertionType')

@declared_attr
def datetime(self):
return Column(DateTime)

value = Column(String(500))


Expand Down Expand Up @@ -1413,6 +1419,10 @@ def annotation_type_id(self):
def annotation_type(self):
return relationship('AnnotationType')

@declared_attr
def datetime(self):
return Column(DateTime)

value = Column(String(500))

class AnnotationType(Base):
Expand Down

0 comments on commit 5eb8d4e

Please sign in to comment.