cs-models 0.0.681__py3-none-any.whl → 0.0.683__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of cs-models might be problematic. Click here for more details.

File without changes
@@ -0,0 +1,45 @@
1
+ from datetime import datetime
2
+
3
+ from sqlalchemy import Column, DateTime, Boolean, ForeignKey, Integer, Text, String
4
+ from sqlalchemy.orm import relationship
5
+
6
+ from ...database import Base
7
+
8
+
9
+ class SmartGridCellModel(Base):
10
+ __tablename__ = "smart_grid_cells"
11
+
12
+ id = Column(Integer, primary_key=True)
13
+ block_id = Column(
14
+ Integer,
15
+ ForeignKey("workbook_blocks.id"),
16
+ nullable=False,
17
+ )
18
+ row = Column(Integer, nullable=False)
19
+ col = Column(Integer, nullable=False)
20
+ type = Column(String(20), nullable=False)
21
+ data = Column(Text, nullable=True)
22
+ user_query_id = Column(
23
+ Integer,
24
+ ForeignKey("assistant_user_queries.id"),
25
+ nullable=True,
26
+ )
27
+ is_deleted = Column(Boolean, nullable=True)
28
+ updated_at = Column(
29
+ DateTime,
30
+ nullable=False,
31
+ # https://stackoverflow.com/questions/58776476/why-doesnt-freezegun-work-with-sqlalchemy-default-values
32
+ default=lambda: datetime.utcnow(),
33
+ onupdate=lambda: datetime.utcnow(),
34
+ )
35
+
36
+ # These are ORM fields. Don't need to be added in the corresponding migration.
37
+ # https://docs.sqlalchemy.org/en/14/orm/tutorial.html#building-a-relationship
38
+ workbook_block = relationship(
39
+ "WorkbookBlockModel",
40
+ back_populates="grid",
41
+ )
42
+
43
+ user_query = relationship(
44
+ "AssistantUserQueryModel",
45
+ )
@@ -0,0 +1,16 @@
1
+ """Marshmallow Schema for AssistantCommand."""
2
+ from marshmallow import Schema, fields
3
+
4
+
5
+ class SmartGridCellResourceSchema(Schema):
6
+ """Class for AssistantCommandResource schema"""
7
+
8
+ id = fields.Integer(dump_only=True)
9
+ block_id = fields.Integer(required=True)
10
+ row = fields.Integer(required=True)
11
+ col = fields.Integer(required=True)
12
+ type = fields.String(required=True)
13
+ data = fields.String(allow_none=True)
14
+ user_query_id = fields.Integer(allow_none=True)
15
+ is_deleted = fields.Boolean(allow_none=True)
16
+ updated_at = fields.DateTime(dump_only=True)
@@ -17,8 +17,8 @@ class WorkbookBlockModel(Base):
17
17
  nullable=False,
18
18
  )
19
19
  sequence_number = Column(Integer, nullable=False)
20
- block_type = Column(String(50), nullable=False)
21
- block_data = Column(Text, nullable=True)
20
+ type = Column(String(50), nullable=False)
21
+ data = Column(Text, nullable=True)
22
22
  is_deleted = Column(Boolean, nullable=True)
23
23
  created_at = Column(DateTime, nullable=False, default=lambda: datetime.utcnow())
24
24
  updated_at = Column(
@@ -43,3 +43,10 @@ class WorkbookBlockModel(Base):
43
43
  order_by=WorkbookBlockCommentModel.sequence_number,
44
44
  back_populates="workbook_block",
45
45
  )
46
+
47
+ grid = relationship(
48
+ "SmartGridCellModel",
49
+ primaryjoin="and_(WorkbookBlockModel.id==SmartGridCellModel.block_id, "
50
+ "or_(SmartGridCellModel.is_deleted==False, SmartGridCellModel.is_deleted==None))",
51
+ back_populates="workbook_block",
52
+ )
@@ -4,6 +4,9 @@ from marshmallow import Schema, fields
4
4
  from ..WorkbookBlockComment.schemas import (
5
5
  WorkbookBlockCommentResourceSchema,
6
6
  )
7
+ from ..SmartGridCell.schemas import (
8
+ SmartGridCellResourceSchema
9
+ )
7
10
 
8
11
 
9
12
  class WorkbookBlockDataField(fields.Field):
@@ -50,13 +53,18 @@ class WorkbookBlockResourceSchema(Schema):
50
53
  id = fields.Integer(dump_only=True)
51
54
  workbook_id = fields.Integer(required=True)
52
55
  sequence_number = fields.Integer(required=True)
53
- block_type = fields.String(required=True)
54
- block_data = WorkbookBlockDataField(required=True, allow_none=True)
56
+ type = fields.String(required=True)
57
+ data = WorkbookBlockDataField(required=True, allow_none=True)
55
58
  comments = fields.Nested(
56
59
  WorkbookBlockCommentResourceSchema(exclude=("block_id",)),
57
60
  many=True,
58
61
  dump_only=True,
59
62
  )
63
+ grid = fields.Nested(
64
+ SmartGridCellResourceSchema(exclude=("block_id",)),
65
+ many=True,
66
+ dump_only=True,
67
+ )
60
68
  is_deleted = fields.Boolean(allow_none=True)
61
69
  created_at = fields.DateTime(dump_only=True)
62
70
  updated_at = fields.DateTime(dump_only=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cs-models
3
- Version: 0.0.681
3
+ Version: 0.0.683
4
4
  Summary: MySQL db models
5
5
  Home-page: https://github.com/mindgram/cs-models
6
6
  Author: Shrey Verma
@@ -869,6 +869,9 @@ cs_models/resources/ScratchpadTable/schemas.py,sha256=pQPf6xpsg0ZKDM9xwesvrpdq8H
869
869
  cs_models/resources/SearchLink/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
870
870
  cs_models/resources/SearchLink/models.py,sha256=l1tPCSKHK7Wq1OUWFH72NYncEt6Q3bR0P6ii7YKoxCM,729
871
871
  cs_models/resources/SearchLink/schemas.py,sha256=A8Y6LRgw7MHs9bihf0gZPfqp6KDm0Z8k6PJSL9WVxsc,448
872
+ cs_models/resources/SmartGridCell/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
873
+ cs_models/resources/SmartGridCell/models.py,sha256=uFugY1RrzA7xl96YW_5DX3e6OH2s4A8UUd0AkSeI7oY,1367
874
+ cs_models/resources/SmartGridCell/schemas.py,sha256=6bjs1Zy2TzQZzwCd6SVgreXef3iel5k9x_v4eGzBByQ,581
872
875
  cs_models/resources/Stream/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
873
876
  cs_models/resources/Stream/models.py,sha256=wXb7yOjW82ZqmLhRcDhjLPk6_WJ5FGmvKpOcSvDMuBM,1884
874
877
  cs_models/resources/Stream/schemas.py,sha256=ZFsdEKINFGaSBUAcQQvilq5MKpYGliZseguQoc_opxk,3111
@@ -1087,8 +1090,8 @@ cs_models/resources/Workbook/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NM
1087
1090
  cs_models/resources/Workbook/models.py,sha256=4p2R8WCYYX0FOSXG0b2YhmuzKHTxYY4WZVi9X7e9GKQ,1003
1088
1091
  cs_models/resources/Workbook/schemas.py,sha256=xcNoPzHK6ER06XA3fAvX3x7VtX47aBP0vrIqiJvUVKw,688
1089
1092
  cs_models/resources/WorkbookBlock/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1090
- cs_models/resources/WorkbookBlock/models.py,sha256=F6qxBNuDe27Cma_wu75KmvEuDYrU2jHQvBvjtQG-5FI,1671
1091
- cs_models/resources/WorkbookBlock/schemas.py,sha256=CfjGkuRff_ohR4WNSRKYkwpIrwPBvfuK9o21lNU3sWM,1859
1093
+ cs_models/resources/WorkbookBlock/models.py,sha256=jiVAA08dm6Im5X7yBZ2p31o8Ml_I_YUzRTKKQLgkOWg,1945
1094
+ cs_models/resources/WorkbookBlock/schemas.py,sha256=yAcYHaQXD8KPV-cfKfv15ZqJwku8ANRj1INtve5KGSk,2054
1092
1095
  cs_models/resources/WorkbookBlockComment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1093
1096
  cs_models/resources/WorkbookBlockComment/models.py,sha256=t1dLdweoPOzld1uBqrGJ3rrr66UkMwdiplNZEA1WtPU,1251
1094
1097
  cs_models/resources/WorkbookBlockComment/schemas.py,sha256=9UI_mTuPBYBk5qKUC2u0oR_clHA9XZ-bh5hhr24E-vs,563
@@ -1138,7 +1141,7 @@ cs_models/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1138
1141
  cs_models/utils/alchemy.py,sha256=fhINGFn41owJ2DLXQKXAAtLqeZ1BRzD_qU0wPK_bsGQ,1598
1139
1142
  cs_models/utils/utils.py,sha256=bY623DuzycfPQiaOQT2AxfANeWfwr5w76dBuQ813-ns,3664
1140
1143
  cs_models/utils/profiling/__init__.py,sha256=N-73vb0M92C975fxgXyBCBjCPELl8Oh21ZY_-tzDnns,569
1141
- cs_models-0.0.681.dist-info/METADATA,sha256=MMmOvmkbDD3LH9MTcyv3swU1GXvG8Uy7am_WjlumBEA,792
1142
- cs_models-0.0.681.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
1143
- cs_models-0.0.681.dist-info/top_level.txt,sha256=M7CA8Nh5t0vRManQ9gHfphhO16uhMqIbfaxr1jPDg18,10
1144
- cs_models-0.0.681.dist-info/RECORD,,
1144
+ cs_models-0.0.683.dist-info/METADATA,sha256=Vhnswq6AzPfR92ZnH1kY1qY-1MG8dIWh_hUvWoxPbaU,792
1145
+ cs_models-0.0.683.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
1146
+ cs_models-0.0.683.dist-info/top_level.txt,sha256=M7CA8Nh5t0vRManQ9gHfphhO16uhMqIbfaxr1jPDg18,10
1147
+ cs_models-0.0.683.dist-info/RECORD,,