fastapi-mongo-base 0.12.1__tar.gz → 0.12.2__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.
Files changed (28) hide show
  1. {fastapi_mongo_base-0.12.1/src/fastapi_mongo_base.egg-info → fastapi_mongo_base-0.12.2}/PKG-INFO +2 -1
  2. {fastapi_mongo_base-0.12.1 → fastapi_mongo_base-0.12.2}/pyproject.toml +2 -1
  3. fastapi_mongo_base-0.12.2/src/fastapi_mongo_base/core/timezone.py +6 -0
  4. {fastapi_mongo_base-0.12.1 → fastapi_mongo_base-0.12.2}/src/fastapi_mongo_base/models.py +5 -4
  5. {fastapi_mongo_base-0.12.1 → fastapi_mongo_base-0.12.2}/src/fastapi_mongo_base/schemas.py +6 -5
  6. {fastapi_mongo_base-0.12.1 → fastapi_mongo_base-0.12.2}/src/fastapi_mongo_base/sql.py +5 -4
  7. {fastapi_mongo_base-0.12.1 → fastapi_mongo_base-0.12.2}/src/fastapi_mongo_base/tasks.py +4 -3
  8. {fastapi_mongo_base-0.12.1 → fastapi_mongo_base-0.12.2/src/fastapi_mongo_base.egg-info}/PKG-INFO +2 -1
  9. {fastapi_mongo_base-0.12.1 → fastapi_mongo_base-0.12.2}/src/fastapi_mongo_base.egg-info/SOURCES.txt +1 -0
  10. {fastapi_mongo_base-0.12.1 → fastapi_mongo_base-0.12.2}/src/fastapi_mongo_base.egg-info/requires.txt +1 -0
  11. {fastapi_mongo_base-0.12.1 → fastapi_mongo_base-0.12.2}/LICENSE.txt +0 -0
  12. {fastapi_mongo_base-0.12.1 → fastapi_mongo_base-0.12.2}/README.md +0 -0
  13. {fastapi_mongo_base-0.12.1 → fastapi_mongo_base-0.12.2}/setup.cfg +0 -0
  14. {fastapi_mongo_base-0.12.1 → fastapi_mongo_base-0.12.2}/src/fastapi_mongo_base/__init__.py +0 -0
  15. {fastapi_mongo_base-0.12.1 → fastapi_mongo_base-0.12.2}/src/fastapi_mongo_base/core/__init__.py +0 -0
  16. {fastapi_mongo_base-0.12.1 → fastapi_mongo_base-0.12.2}/src/fastapi_mongo_base/core/app_factory.py +0 -0
  17. {fastapi_mongo_base-0.12.1 → fastapi_mongo_base-0.12.2}/src/fastapi_mongo_base/core/config.py +0 -0
  18. {fastapi_mongo_base-0.12.1 → fastapi_mongo_base-0.12.2}/src/fastapi_mongo_base/core/db.py +0 -0
  19. {fastapi_mongo_base-0.12.1 → fastapi_mongo_base-0.12.2}/src/fastapi_mongo_base/core/enums.py +0 -0
  20. {fastapi_mongo_base-0.12.1 → fastapi_mongo_base-0.12.2}/src/fastapi_mongo_base/core/exceptions.py +0 -0
  21. {fastapi_mongo_base-0.12.1 → fastapi_mongo_base-0.12.2}/src/fastapi_mongo_base/core/middlewares.py +0 -0
  22. {fastapi_mongo_base-0.12.1 → fastapi_mongo_base-0.12.2}/src/fastapi_mongo_base/routes.py +0 -0
  23. {fastapi_mongo_base-0.12.1 → fastapi_mongo_base-0.12.2}/src/fastapi_mongo_base/utils/__init__.py +0 -0
  24. {fastapi_mongo_base-0.12.1 → fastapi_mongo_base-0.12.2}/src/fastapi_mongo_base/utils/basic.py +0 -0
  25. {fastapi_mongo_base-0.12.1 → fastapi_mongo_base-0.12.2}/src/fastapi_mongo_base/utils/bsontools.py +0 -0
  26. {fastapi_mongo_base-0.12.1 → fastapi_mongo_base-0.12.2}/src/fastapi_mongo_base/utils/conditions.py +0 -0
  27. {fastapi_mongo_base-0.12.1 → fastapi_mongo_base-0.12.2}/src/fastapi_mongo_base.egg-info/dependency_links.txt +0 -0
  28. {fastapi_mongo_base-0.12.1 → fastapi_mongo_base-0.12.2}/src/fastapi_mongo_base.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastapi-mongo-base
3
- Version: 0.12.1
3
+ Version: 0.12.2
4
4
  Summary: A simple boilerplate application, including models and schemas and abstract router, for FastAPI with MongoDB
5
5
  Author-email: Mahdi Kiani <mahdikiany@gmail.com>
6
6
  Maintainer-email: Mahdi Kiani <mahdikiany@gmail.com>
@@ -47,6 +47,7 @@ Requires-Dist: httpx>=0.24.0
47
47
  Requires-Dist: singleton_package
48
48
  Requires-Dist: json-advanced
49
49
  Requires-Dist: uuid6
50
+ Requires-Dist: pytz
50
51
  Requires-Dist: fastapi>=0.65.0
51
52
  Requires-Dist: uvicorn[standard]>=0.13.0
52
53
  Provides-Extra: image
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "fastapi-mongo-base"
7
- version = "0.12.1"
7
+ version = "0.12.2"
8
8
  description = "A simple boilerplate application, including models and schemas and abstract router, for FastAPI with MongoDB"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -33,6 +33,7 @@ dependencies = [
33
33
  "singleton_package",
34
34
  "json-advanced",
35
35
  "uuid6",
36
+ "pytz",
36
37
  "fastapi>=0.65.0",
37
38
  "uvicorn[standard]>=0.13.0"
38
39
  ]
@@ -0,0 +1,6 @@
1
+ import os
2
+
3
+ import pytz
4
+
5
+ tz = pytz.timezone(os.getenv("TIMEZONE", "UTC"))
6
+ utc = pytz.timezone("UTC")
@@ -1,10 +1,11 @@
1
- from datetime import datetime, timezone
1
+ from datetime import datetime
2
2
 
3
3
  from beanie import Document, Insert, Replace, Save, SaveChanges, Update, before_event
4
4
  from beanie.odm.queries.find import FindMany
5
5
  from pydantic import ConfigDict
6
6
  from pymongo import ASCENDING, IndexModel
7
7
 
8
+ from .core import timezone
8
9
  from .core.config import Settings
9
10
  from .schemas import (
10
11
  BaseEntitySchema,
@@ -33,7 +34,7 @@ class BaseEntity(BaseEntitySchema, Document):
33
34
 
34
35
  @before_event([Insert, Replace, Save, SaveChanges, Update])
35
36
  async def pre_save(self):
36
- self.updated_at = datetime.now(timezone.utc)
37
+ self.updated_at = datetime.now(timezone.tz)
37
38
 
38
39
  @classmethod
39
40
  def get_queryset(
@@ -255,8 +256,8 @@ class BaseEntity(BaseEntitySchema, Document):
255
256
  for key in pop_keys:
256
257
  data.pop(key, None)
257
258
 
258
- data["created_at"] = datetime.now(timezone.utc)
259
- data["updated_at"] = datetime.now(timezone.utc)
259
+ data["created_at"] = datetime.now(timezone.tz)
260
+ data["updated_at"] = datetime.now(timezone.tz)
260
261
 
261
262
  item = cls(**data)
262
263
  await item.save()
@@ -1,9 +1,10 @@
1
- import uuid6
2
- from datetime import datetime, timezone
1
+ from datetime import datetime
3
2
  from typing import Generic, TypeVar
4
3
 
4
+ import uuid6
5
5
  from pydantic import BaseModel, Field
6
6
 
7
+ from .core import timezone
7
8
  from .core.config import Settings
8
9
 
9
10
 
@@ -14,12 +15,12 @@ class BaseEntitySchema(BaseModel):
14
15
  description="Unique identifier for the entity",
15
16
  )
16
17
  created_at: datetime = Field(
17
- default_factory=lambda: datetime.now(timezone.utc),
18
+ default_factory=lambda: datetime.now(timezone.tz),
18
19
  json_schema_extra={"index": True},
19
20
  description="Date and time the entity was created",
20
21
  )
21
22
  updated_at: datetime = Field(
22
- default_factory=lambda: datetime.now(timezone.utc),
23
+ default_factory=lambda: datetime.now(timezone.tz),
23
24
  json_schema_extra={"index": True},
24
25
  description="Date and time the entity was last updated",
25
26
  )
@@ -60,7 +61,7 @@ class BaseEntitySchema(BaseModel):
60
61
  return []
61
62
 
62
63
  def expired(self, days: int = 3):
63
- return (datetime.now(timezone.utc) - self.updated_at).days > days
64
+ return (datetime.now(timezone.tz) - self.updated_at).days > days
64
65
 
65
66
  @property
66
67
  def item_url(self):
@@ -1,12 +1,13 @@
1
1
  import json
2
2
  import uuid
3
- from datetime import datetime, timezone
3
+ from datetime import datetime
4
4
  from typing import Any
5
5
 
6
6
  from sqlalchemy import JSON, event, select
7
7
  from sqlalchemy.orm import Mapped, as_declarative, declared_attr, mapped_column
8
8
  from sqlalchemy.sql import func
9
9
 
10
+ from .core import timezone
10
11
  from .core.config import Settings
11
12
  from .utils import basic
12
13
 
@@ -30,11 +31,11 @@ class BaseEntity:
30
31
  index=True,
31
32
  )
32
33
  created_at: Mapped[datetime] = mapped_column(
33
- default=lambda: datetime.now(timezone.utc),
34
+ default=lambda: datetime.now(timezone.tz),
34
35
  index=True,
35
36
  )
36
37
  updated_at: Mapped[datetime] = mapped_column(
37
- default=lambda: datetime.now(timezone.utc), onupdate=func.now()
38
+ default=lambda: datetime.now(timezone.tz), onupdate=func.now()
38
39
  )
39
40
  is_deleted: Mapped[bool] = mapped_column(default=False)
40
41
  meta_data: Mapped[dict | None] = mapped_column(JSON, nullable=True)
@@ -64,7 +65,7 @@ class BaseEntity:
64
65
  return []
65
66
 
66
67
  def expired(self, days: int = 3):
67
- return (datetime.now(timezone.utc) - self.updated_at).days > days
68
+ return (datetime.now(timezone.tz) - self.updated_at).days > days
68
69
 
69
70
  def dump(
70
71
  self, include_fields: list[str] = None, exclude_fields: list[str] = None
@@ -1,6 +1,6 @@
1
1
  import asyncio
2
2
  import logging
3
- from datetime import datetime, timezone
3
+ from datetime import datetime
4
4
  from enum import Enum
5
5
  from typing import Any, Callable, Coroutine, Literal, Union
6
6
 
@@ -8,6 +8,7 @@ import json_advanced as json
8
8
  from pydantic import BaseModel, Field, field_serializer, field_validator
9
9
  from singleton import Singleton
10
10
 
11
+ from .core import timezone
11
12
  from .schemas import BaseEntitySchema
12
13
  from .utils import basic
13
14
 
@@ -40,7 +41,7 @@ class SignalRegistry(metaclass=Singleton):
40
41
 
41
42
 
42
43
  class TaskLogRecord(BaseModel):
43
- reported_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
44
+ reported_at: datetime = Field(default_factory=lambda: datetime.now(timezone.tz))
44
45
  message: str
45
46
  task_status: TaskStatusEnum
46
47
  duration: int = 0
@@ -134,7 +135,7 @@ class TaskMixin(BaseModel):
134
135
  if self.task_start_at:
135
136
  if self.task_end_at:
136
137
  return self.task_end_at - self.task_start_at
137
- return datetime.now(timezone.utc) - self.task_start_at
138
+ return datetime.now(timezone.tz) - self.task_start_at
138
139
  return 0
139
140
 
140
141
  @field_validator("task_status", mode="before")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastapi-mongo-base
3
- Version: 0.12.1
3
+ Version: 0.12.2
4
4
  Summary: A simple boilerplate application, including models and schemas and abstract router, for FastAPI with MongoDB
5
5
  Author-email: Mahdi Kiani <mahdikiany@gmail.com>
6
6
  Maintainer-email: Mahdi Kiani <mahdikiany@gmail.com>
@@ -47,6 +47,7 @@ Requires-Dist: httpx>=0.24.0
47
47
  Requires-Dist: singleton_package
48
48
  Requires-Dist: json-advanced
49
49
  Requires-Dist: uuid6
50
+ Requires-Dist: pytz
50
51
  Requires-Dist: fastapi>=0.65.0
51
52
  Requires-Dist: uvicorn[standard]>=0.13.0
52
53
  Provides-Extra: image
@@ -19,6 +19,7 @@ src/fastapi_mongo_base/core/db.py
19
19
  src/fastapi_mongo_base/core/enums.py
20
20
  src/fastapi_mongo_base/core/exceptions.py
21
21
  src/fastapi_mongo_base/core/middlewares.py
22
+ src/fastapi_mongo_base/core/timezone.py
22
23
  src/fastapi_mongo_base/utils/__init__.py
23
24
  src/fastapi_mongo_base/utils/basic.py
24
25
  src/fastapi_mongo_base/utils/bsontools.py
@@ -3,6 +3,7 @@ httpx>=0.24.0
3
3
  singleton_package
4
4
  json-advanced
5
5
  uuid6
6
+ pytz
6
7
  fastapi>=0.65.0
7
8
  uvicorn[standard]>=0.13.0
8
9