internal 1.0.14__py3-none-any.whl → 1.0.16__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 internal might be problematic. Click here for more details.

@@ -45,3 +45,12 @@ class NoChangeException(InternalBaseException):
45
45
  def __init__(self, message: str = None, **kwargs):
46
46
  _message = message or self.message
47
47
  super().__init__(status.HTTP_200_OK, self.code, _message, **kwargs)
48
+
49
+
50
+ class PermissionDeniedException(InternalBaseException):
51
+ code = "error_permission_denied"
52
+ message = "Permission denied"
53
+
54
+ def __init__(self, message: str = None, **kwargs):
55
+ _message = message or self.message
56
+ super().__init__(status.HTTP_403_FORBIDDEN, self.code, _message, **kwargs)
@@ -1,27 +1,39 @@
1
1
  import json
2
+ import arrow
3
+
4
+ from datetime import datetime
5
+
2
6
  import httpx
3
7
 
4
8
  from fastapi import status
5
9
  from fastapi.responses import JSONResponse
6
10
  from fastapi.encoders import jsonable_encoder
7
11
  from beanie import Document, Link
12
+ from ..const import ARR_HUMAN_READ_FMT
8
13
 
9
14
 
10
15
  async def async_response(data=None, message=None, code=None, page_no=None, total_num=None, page_size=None,
11
- status_code=status.HTTP_200_OK):
16
+ time_zone="Asia/Taipei", time_format=ARR_HUMAN_READ_FMT, status_code=status.HTTP_200_OK):
12
17
  def _serialize(data):
13
18
  if issubclass(type(data), Document):
14
19
  link_field_list = []
20
+ datetime_field_list = []
15
21
  for field_name in data.__annotations__:
16
22
  field_type = getattr(data, field_name)
17
23
  if isinstance(field_type, Link):
18
24
  link_field_list.append(field_name)
25
+ if isinstance(field_type, datetime):
26
+ datetime_field_list.append(field_name)
19
27
 
20
28
  data = json.loads(data.model_dump_json(exclude="password", by_alias=False))
21
29
  if link_field_list:
22
30
  for field_name in link_field_list:
23
31
  if isinstance(data[field_name], dict) and "id" in data[field_name].keys():
24
32
  data[field_name] = data[field_name]["id"]
33
+ for field_name in datetime_field_list:
34
+ if data[field_name]:
35
+ data[field_name] = arrow.get(data[field_name]).to(time_zone).format(time_format)
36
+
25
37
  return data
26
38
 
27
39
  if isinstance(data, httpx.Response):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: internal
3
- Version: 1.0.14
3
+ Version: 1.0.16
4
4
  Summary:
5
5
  Author: Ray
6
6
  Author-email: ray@cruisys.com
@@ -11,14 +11,14 @@ internal/const.py,sha256=U1S9r7bjtHgad2oYQoHO19s8D4V0WDUG-L-haV4UaIw,1025
11
11
  internal/database.py,sha256=atf0iyEqeG97eYr3s4GrTHKM5LjLiKlCNWiuAWoE2vs,2124
12
12
  internal/exception/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  internal/exception/base_exception.py,sha256=U0ZXx1FOXydAnQQImznkeAdsKVC_YaukPWvJdWqEBfg,363
14
- internal/exception/internal_exception.py,sha256=byaaH5DBZTp-M8YMzGicOS2rHMg7S4zS7Two-1r7tj8,1651
14
+ internal/exception/internal_exception.py,sha256=gAhlAJGR7HbGRFDKHzndH0riyhwpxICHS9fNBSr3Yso,1962
15
15
  internal/ext/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  internal/ext/amazon/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  internal/ext/amazon/aws/__init__.py,sha256=2YFjb-rHG1JaZGZiZffYDesgTAJjDshOqQbswOYzhP8,834
18
18
  internal/ext/amazon/aws/const.py,sha256=l4WMg5bKWujwOKABBkCO2zclNg3abnYOfbhD7DG8GsA,109
19
19
  internal/http/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  internal/http/requests.py,sha256=C2MfPaRcFuF8p52aPwtOyzXQEVu5MWMY8UUCrggxONw,1675
21
- internal/http/responses.py,sha256=b3Qc-iQmoYyFYrFv_lCQKbMNUu6My53YRRbUMn_1QoI,1687
21
+ internal/http/responses.py,sha256=J4O0L1nMG5kIVqucJTl0gDbc2jchPaPYcR_jucZtDQE,2167
22
22
  internal/interface/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
23
  internal/interface/base_interface.py,sha256=R5MmO5oa5-ORPV_adkegLVCwsVio2zFOuQFGiby3khs,340
24
24
  internal/middleware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -27,6 +27,6 @@ internal/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
27
  internal/model/base_model.py,sha256=wnAKz21bXcbR4QqENc1_hKbUkzc8a8aT8oyhS9WT7kw,3032
28
28
  internal/model/operate.py,sha256=luEoP_Asvso_11qz1SAE1Kn5KxAnDRptM0VylC5tNik,1493
29
29
  internal/utils.py,sha256=0SubS0iUhDvjSX1F4TykasA5-enYJzt2VH-f7_0BnjI,1509
30
- internal-1.0.14.dist-info/METADATA,sha256=BB9Xe5mnu1SuBHI-e4CkHtswlmIXPbyL72LpQhDL_ss,625
31
- internal-1.0.14.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
32
- internal-1.0.14.dist-info/RECORD,,
30
+ internal-1.0.16.dist-info/METADATA,sha256=9CLELbpneXP6t7-EZ2KvDNUgcE_EKrF4zhRoEOlfblE,625
31
+ internal-1.0.16.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
32
+ internal-1.0.16.dist-info/RECORD,,