Skip to content

Commit

Permalink
Kalmyk markup groups -- ispras/lingvodoc-react#1152 (#1525)
Browse files Browse the repository at this point in the history
* Init

* now tsakorpus requires administrator for force mode only

* mutations

* model

* model

* next changes

* alembic migration

* fixes

* daily work

* fixes

* next fixes

* next work

* fixes

* next work

* fixes

* daily work

* next work

* next work

* fixes

* minor

* fixed dnd metadata

* refetching only changed lexical entries

* cleanup

* important fix

* breakdown with markups

* save xlsx

* using real dictionary name

* fix
  • Loading branch information
vmonakhov authored Dec 22, 2024
1 parent 2e5a4d9 commit 0fe640f
Show file tree
Hide file tree
Showing 7 changed files with 722 additions and 4 deletions.
32 changes: 32 additions & 0 deletions alembic/versions/882f3864b825_markup_group_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""markup_group_table
Revision ID: 882f3864b825
Revises: 50847f29994c
Create Date: 2024-12-04 18:14:28.470514
"""

# revision identifiers, used by Alembic.
revision = '882f3864b825'
down_revision = '50847f29994c'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa
from lingvodoc.models import SLBigInteger


def upgrade():
op.create_table('markupgroup',
sa.Column('object_id', SLBigInteger(), nullable=False),
sa.Column('client_id', SLBigInteger(), nullable=False),
sa.Column('perspective_object_id', SLBigInteger(), nullable=False),
sa.Column('perspective_client_id', SLBigInteger(), nullable=False),
sa.Column('type', sa.UnicodeText(), nullable=False),
sa.Column('marked_for_deletion', sa.Boolean(), nullable=False),
sa.Column('created_at', sa.TIMESTAMP(), nullable=False),
sa.PrimaryKeyConstraint('object_id', 'client_id'))

def downgrade():
op.drop_table('markupgroup')
12 changes: 12 additions & 0 deletions lingvodoc/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2763,3 +2763,15 @@ class AdverbAnnotationData(
instance_id = Column(SLBigInteger(), ForeignKey('adverb_instance_data.id'), primary_key = True)
user_id = Column(SLBigInteger(), ForeignKey('user.id'), primary_key = True)
accepted = Column(Boolean, default = None)


class MarkupGroup(
Base,
TableNameMixin,
CompositeIdMixin,
CreatedAtMixin,
MarkedForDeletionMixin):

type = Column(UnicodeText, nullable = False)
perspective_client_id = Column(SLBigInteger(), nullable = False)
perspective_object_id = Column(SLBigInteger(), nullable = False)
10 changes: 10 additions & 0 deletions lingvodoc/schema/gql_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
from lingvodoc.utils.elan_functions import eaf_wordlist
from lingvodoc.utils.lexgraph_marker import marker_between_arith as marker_between
from lingvodoc.utils.verification import check_client_id, check_lingvodoc_id
from pdb import set_trace as A


# Setting up logging.
Expand Down Expand Up @@ -1275,6 +1276,7 @@ class Arguments:
"""
id = LingvodocID()
content = graphene.String()
markups = graphene.List(ObjectVal)
lexgraph_before = graphene.String()
lexgraph_after = graphene.String()

Expand All @@ -1287,6 +1289,7 @@ def mutate(root, info, **args):
old_client_id, object_id = args.get('id')
client_id = DBSession.query(Client).filter_by(id=info.context.client_id).first().id
content = args.get("content")
markups = args.get("markups")
lexgraph_before = args.get("lexgraph_before", '')
lexgraph_after = args.get("lexgraph_after", '')
if content is None and (lexgraph_before or lexgraph_after):
Expand Down Expand Up @@ -1321,6 +1324,13 @@ def mutate(root, info, **args):

info.context.acl_check('create', 'lexical_entries_and_entities',
(parent.parent_client_id, parent.parent_object_id))

if markups:
if type(dbentity_old.additional_metadata) is dict:
dbentity_old.additional_metadata['markups'] = markups
else:
dbentity_old.additional_metadata = {'markups': markups}

dbentity = dbEntity(client_id=client_id,
object_id=None,
field_client_id=dbentity_old.field_client_id,
Expand Down
3 changes: 3 additions & 0 deletions lingvodoc/schema/gql_holders.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
)
from lingvodoc.utils.verification import check_client_id
from lingvodoc.cache.caching import CACHE
from pdb import set_trace as A


# Setting up logging.
Expand Down Expand Up @@ -997,6 +998,8 @@ class Metadata(graphene.ObjectType):

uploaded_at = graphene.String()

markups = graphene.List(ObjectVal)

metadata_key_set = {

key
Expand Down
1 change: 1 addition & 0 deletions lingvodoc/schema/gql_lexicalentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
from lingvodoc.utils.creation import create_lexicalentry
from lingvodoc.utils.deletion import real_delete_entity
from lingvodoc.utils.search import find_all_tags, find_lexical_entries_by_tags
from pdb import set_trace as A


# Setting up logging.
Expand Down
Loading

0 comments on commit 0fe640f

Please sign in to comment.