xync-schema 0.6.32.dev1__tar.gz → 0.6.34__tar.gz
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.
- {xync_schema-0.6.32.dev1/xync_schema.egg-info → xync_schema-0.6.34}/PKG-INFO +1 -1
- {xync_schema-0.6.32.dev1 → xync_schema-0.6.34}/xync_schema/models.py +39 -58
- {xync_schema-0.6.32.dev1 → xync_schema-0.6.34}/xync_schema/pydantic.py +7 -1
- {xync_schema-0.6.32.dev1 → xync_schema-0.6.34/xync_schema.egg-info}/PKG-INFO +1 -1
- {xync_schema-0.6.32.dev1 → xync_schema-0.6.34}/.env.sample +0 -0
- {xync_schema-0.6.32.dev1 → xync_schema-0.6.34}/.gitignore +0 -0
- {xync_schema-0.6.32.dev1 → xync_schema-0.6.34}/.pre-commit-config.yaml +0 -0
- {xync_schema-0.6.32.dev1 → xync_schema-0.6.34}/README.md +0 -0
- {xync_schema-0.6.32.dev1 → xync_schema-0.6.34}/makefile +0 -0
- {xync_schema-0.6.32.dev1 → xync_schema-0.6.34}/pyproject.toml +0 -0
- {xync_schema-0.6.32.dev1 → xync_schema-0.6.34}/setup.cfg +0 -0
- {xync_schema-0.6.32.dev1 → xync_schema-0.6.34}/tests/__init__.py +0 -0
- {xync_schema-0.6.32.dev1 → xync_schema-0.6.34}/tests/test_db.py +0 -0
- {xync_schema-0.6.32.dev1 → xync_schema-0.6.34}/xync_schema/__init__.py +0 -0
- {xync_schema-0.6.32.dev1 → xync_schema-0.6.34}/xync_schema.egg-info/SOURCES.txt +0 -0
- {xync_schema-0.6.32.dev1 → xync_schema-0.6.34}/xync_schema.egg-info/dependency_links.txt +0 -0
- {xync_schema-0.6.32.dev1 → xync_schema-0.6.34}/xync_schema.egg-info/requires.txt +0 -0
- {xync_schema-0.6.32.dev1 → xync_schema-0.6.34}/xync_schema.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from datetime import datetime
|
|
2
2
|
from enum import IntEnum
|
|
3
3
|
from tortoise import fields
|
|
4
|
+
from tortoise.queryset import QuerySet
|
|
4
5
|
from x_auth.enums import Role
|
|
5
6
|
from x_auth.models import Model
|
|
6
7
|
from x_model.models import TsTrait, DatetimeSecField
|
|
@@ -178,6 +179,9 @@ class Ex(Model):
|
|
|
178
179
|
table_description = "Exchanges"
|
|
179
180
|
unique_together = (("name", "type_"),)
|
|
180
181
|
|
|
182
|
+
class PydanticMeta(Model.PydanticMeta):
|
|
183
|
+
include = "name", "logo"
|
|
184
|
+
|
|
181
185
|
|
|
182
186
|
class Curex(Model):
|
|
183
187
|
cur: fields.ForeignKeyRelation[Cur] = fields.ForeignKeyField("models.Cur")
|
|
@@ -224,7 +228,7 @@ class Direction(Model):
|
|
|
224
228
|
|
|
225
229
|
class User(Model, TsTrait):
|
|
226
230
|
id: int = fields.BigIntField(True)
|
|
227
|
-
role: Role = fields.IntEnumField(Role)
|
|
231
|
+
role: Role = fields.IntEnumField(Role, default=Role.READER)
|
|
228
232
|
status: UserStatus = fields.IntEnumField(UserStatus, default=UserStatus.RESTRICTED)
|
|
229
233
|
username: str | None = fields.CharField(95, unique=True, null=True)
|
|
230
234
|
ref: fields.ForeignKeyNullableRelation["User"] = fields.ForeignKeyField(
|
|
@@ -281,21 +285,18 @@ class Agent(Model, TsTrait):
|
|
|
281
285
|
unique_together = (("ex", "user"),)
|
|
282
286
|
|
|
283
287
|
class PydanticMeta(Model.PydanticMeta):
|
|
288
|
+
# max_recursion = 3
|
|
289
|
+
include = "ex", "assets", "auth"
|
|
284
290
|
computed = ["balance"]
|
|
285
291
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
# backward_relations: bool = True
|
|
289
|
-
# exclude = ("user",)
|
|
290
|
-
# computed = ["balance"]
|
|
292
|
+
async def client(self):
|
|
293
|
+
import sys
|
|
291
294
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
# client = sys.modules[f'xync_client.{self.ex.name}.p2p'].AgentClient
|
|
298
|
-
# return client(self)
|
|
295
|
+
if isinstance(self.ex, QuerySet):
|
|
296
|
+
# noinspection PyTypeChecker
|
|
297
|
+
self.ex: Ex = await self.ex
|
|
298
|
+
client = sys.modules[f"xync_client.{self.ex.name}.p2p"].AgentClient
|
|
299
|
+
return client(self)
|
|
299
300
|
|
|
300
301
|
|
|
301
302
|
class Adpm(Model):
|
|
@@ -365,32 +366,11 @@ class Pmcur(Model): # for fiat with no exs tie
|
|
|
365
366
|
|
|
366
367
|
_name = {"pm__name", "cur__ticker"}
|
|
367
368
|
|
|
368
|
-
# _sorts = ['-limits_count']
|
|
369
|
-
|
|
370
|
-
# @classmethod
|
|
371
|
-
# def pydListItem(cls, max_recursion: int = 1, backward_relations: bool = False, exclude: tuple[str] = (), include: tuple[str] = (), force: bool = False) -> type[PydanticModel]:
|
|
372
|
-
# if not cls._pydListItem:
|
|
373
|
-
# mo = PydanticMeta
|
|
374
|
-
# mo.max_recursion = 1
|
|
375
|
-
# mo.exclude_raw_fields = True # default: True
|
|
376
|
-
# # mo.backward_relations = False # default: True
|
|
377
|
-
# cls._pydListItem = pydantic_model_creator(cls, name=cls.__name__ + 'ListItem', meta_override=mo, exclude=('pmcurexs',))
|
|
378
|
-
# return cls._pydListItem
|
|
379
|
-
|
|
380
|
-
# @classmethod
|
|
381
|
-
# def pageQuery(cls, sorts: list[str], limit: int = 1000, offset: int = 0, q: str = None, owner: bool = None, **kwargs) -> QuerySet:
|
|
382
|
-
# query = super().pageQuery([], limit, offset, q)
|
|
383
|
-
# if kwargs.pop('only_empty', None):
|
|
384
|
-
# query = query.exclude(limits__not_isnull=True)
|
|
385
|
-
# else:
|
|
386
|
-
# query = query.annotate(limits_count=Count('limits')).order_by('-limits_count')
|
|
387
|
-
# return query.filter(**kwargs)
|
|
388
|
-
|
|
389
369
|
class Meta:
|
|
390
370
|
table_description = "Payment methods - Currencies"
|
|
391
371
|
unique_together = (("pm", "cur"),)
|
|
392
372
|
|
|
393
|
-
class PydanticMeta:
|
|
373
|
+
class PydanticMeta(Model.PydanticMeta):
|
|
394
374
|
exclude_raw_fields: bool = False
|
|
395
375
|
|
|
396
376
|
|
|
@@ -436,15 +416,16 @@ class Fiat(Model):
|
|
|
436
416
|
exs: fields.ManyToManyRelation[Ex] = fields.ManyToManyField("models.Ex", through="fiatex", related_name="fiats")
|
|
437
417
|
orders: fields.ReverseRelation["Order"]
|
|
438
418
|
|
|
439
|
-
_name = {"pmcur__pm__name", "pmcur__cur__ticker", "amount"}
|
|
419
|
+
# _name = {"pmcur__pm__name", "pmcur__cur__ticker", "amount"}
|
|
440
420
|
|
|
441
421
|
class Meta:
|
|
442
422
|
table_description = "Currency accounts balance"
|
|
443
423
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
424
|
+
class PydanticMeta(Model.PydanticMeta):
|
|
425
|
+
# max_recursion: int = 2
|
|
426
|
+
backward_relations = False
|
|
427
|
+
include = "id", "pmcur", "detail", "name", "amount"
|
|
428
|
+
|
|
448
429
|
# # exclude_raw_fields = True
|
|
449
430
|
|
|
450
431
|
|
|
@@ -497,8 +478,8 @@ class Asset(Model):
|
|
|
497
478
|
table_description = "Coin balance"
|
|
498
479
|
unique_together = (("coin", "agent", "type_"),)
|
|
499
480
|
|
|
500
|
-
|
|
501
|
-
|
|
481
|
+
class PydanticMeta(Model.PydanticMeta):
|
|
482
|
+
max_recursion: int = 2 # default: 3
|
|
502
483
|
|
|
503
484
|
|
|
504
485
|
class Order(Model, TsTrait):
|
|
@@ -578,22 +559,22 @@ class Order(Model, TsTrait):
|
|
|
578
559
|
# table_description = "Investments"
|
|
579
560
|
|
|
580
561
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
#
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
562
|
+
class TestEx(Model):
|
|
563
|
+
ex: fields.ForeignKeyRelation[Ex] = fields.ForeignKeyField("models.Ex", related_name="tests")
|
|
564
|
+
# ex_id: int
|
|
565
|
+
action: ExAction = fields.IntEnumField(ExAction)
|
|
566
|
+
ok: bool | None = fields.BooleanField(default=False, null=True)
|
|
567
|
+
updated_at: datetime | None = DatetimeSecField(auto_now=True)
|
|
568
|
+
|
|
569
|
+
_icon = "test-pipe"
|
|
570
|
+
_name = {"ex__name", "action", "ok"}
|
|
571
|
+
|
|
572
|
+
def repr(self, *args):
|
|
573
|
+
return f"{self.ex.name} {self.action.name} {self.ok}"
|
|
574
|
+
|
|
575
|
+
class Meta:
|
|
576
|
+
table_description = "Test Exs"
|
|
577
|
+
unique_together = (("action", "ex"),)
|
|
597
578
|
|
|
598
579
|
|
|
599
580
|
# class Vpn(Model):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|