fastapi-rtk 1.0.18__py3-none-any.whl → 1.0.20__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.
@@ -1,8 +1,8 @@
1
1
  import typing
2
2
 
3
3
  from ..bases.file_manager import AbstractFileManager
4
- from ..const import logger
5
- from ..utils import smart_run
4
+ from ..setting import Setting
5
+ from ..utils import lazy, smart_run, use_default_when_none
6
6
 
7
7
  __all__ = ["S3FileManager"]
8
8
 
@@ -12,10 +12,14 @@ class S3FileManager(AbstractFileManager):
12
12
  FileManager for handling files in S3 buckets.
13
13
  """
14
14
 
15
+ allowed_extensions = lazy(lambda: Setting.FILE_ALLOWED_EXTENSIONS)
16
+ max_file_size = lazy(lambda: Setting.FILE_MAX_SIZE)
17
+
15
18
  def __init__(
16
19
  self,
17
20
  base_path: str | None = None,
18
21
  allowed_extensions: list[str] | None = None,
22
+ max_file_size: int | None = None,
19
23
  namegen: typing.Callable[[str], str] | None = None,
20
24
  permission: int | None = None,
21
25
  bucket_name: str | None = None,
@@ -24,6 +28,8 @@ class S3FileManager(AbstractFileManager):
24
28
  secret_key: str | None = None,
25
29
  open_params: dict[str, typing.Any] | None = None,
26
30
  boto3_client: typing.Any | None = None,
31
+ boto3_args: tuple[typing.Any, ...] | None = None,
32
+ boto3_kwargs: dict[str, typing.Any] | None = None,
27
33
  ):
28
34
  """
29
35
  Initializes the S3FileManager.
@@ -31,6 +37,7 @@ class S3FileManager(AbstractFileManager):
31
37
  Args:
32
38
  base_path (str | None, optional): URL path to the S3 bucket. Defaults to None.
33
39
  allowed_extensions (list[str] | None, optional): Allowed file extensions. Defaults to None.
40
+ max_file_size (int | None, optional): Maximum file size allowed. Defaults to None.
34
41
  namegen (typing.Callable[[str], str] | None, optional): Callable for generating file names. Defaults to None.
35
42
  permission (int | None, optional): File permission settings. Defaults to None.
36
43
  bucket_name (str | None, optional): Name of the S3 bucket. Defaults to None.
@@ -39,10 +46,14 @@ class S3FileManager(AbstractFileManager):
39
46
  secret_key (str | None, optional): AWS secret key. Needed for default boto3 client in order to delete files. Defaults to None.
40
47
  open_params (dict[str, typing.Any] | None, optional): Parameters for opening files. Defaults to None.
41
48
  boto3_client (typing.Any | None, optional): Boto3 client instance. If None, a new client will be created. Defaults to None.
49
+ boto3_args (tuple[typing.Any, ...] | None, optional): Positional arguments for boto3 client creation. Defaults to None.
50
+ boto3_kwargs (dict[str, typing.Any] | None, optional): Keyword arguments for boto3 client creation. Defaults to None.
42
51
  Raises:
43
52
  ImportError: If required libraries are not installed.
44
53
  """
45
- super().__init__(base_path, allowed_extensions, namegen, permission)
54
+ super().__init__(
55
+ base_path, allowed_extensions, max_file_size, namegen, permission
56
+ )
46
57
 
47
58
  try:
48
59
  import boto3
@@ -61,22 +72,28 @@ class S3FileManager(AbstractFileManager):
61
72
  self.access_key = access_key
62
73
  self.secret_key = secret_key
63
74
  self.open_params = open_params or {}
75
+ boto3_args = use_default_when_none(boto3_args, ("s3",))
76
+ boto3_kwargs = {
77
+ "aws_access_key_id": access_key,
78
+ "aws_secret_access_key": secret_key,
79
+ **(boto3_kwargs or {}),
80
+ }
64
81
  self.boto3_client = boto3_client or self.boto3.client(
65
- "s3",
66
- aws_access_key_id=self.access_key,
67
- aws_secret_access_key=self.secret_key,
82
+ *boto3_args, **boto3_kwargs
68
83
  )
69
84
 
70
85
  if not self.bucket_name:
71
- logger.warning(
72
- f"Bucket name is not set for {self.__class__.__name__}. "
73
- "Files may not be able to be deleted"
86
+ raise ValueError(
87
+ f"Bucket name must be provided for {self.__class__.__name__}"
74
88
  )
75
89
 
76
- if not self.access_key or not self.secret_key:
77
- logger.warning(
78
- f"Access key or secret key is not set for {self.__class__.__name__}. "
79
- "Files may not be able to be deleted"
90
+ if not self.access_key:
91
+ raise ValueError(
92
+ f"Access key must be provided for {self.__class__.__name__}"
93
+ )
94
+ if not self.secret_key:
95
+ raise ValueError(
96
+ f"Secret key must be provided for {self.__class__.__name__}"
80
97
  )
81
98
 
82
99
  def get_path(self, filename):
@@ -1,4 +1,6 @@
1
1
  from ..bases.file_manager import AbstractImageManager
2
+ from ..setting import Setting
3
+ from ..utils import lazy
2
4
  from .s3_file_manager import S3FileManager
3
5
 
4
6
  __all__ = ["S3ImageManager"]
@@ -9,3 +11,6 @@ class S3ImageManager(S3FileManager, AbstractImageManager):
9
11
  S3ImageManager is a specialized S3FileManager for handling image files.
10
12
  It inherits from S3FileManager and implements AbstractImageManager.
11
13
  """
14
+
15
+ allowed_extensions = lazy(lambda: Setting.IMG_ALLOWED_EXTENSIONS)
16
+ max_file_size = lazy(lambda: Setting.IMG_MAX_SIZE)
@@ -1,14 +1,14 @@
1
1
  # Translations template for PROJECT.
2
- # Copyright (C) 2025 ORGANIZATION
2
+ # Copyright (C) 2026 ORGANIZATION
3
3
  # This file is distributed under the same license as the PROJECT project.
4
- # FIRST AUTHOR <EMAIL@ADDRESS>, 2025.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, 2026.
5
5
  #
6
6
  #, fuzzy
7
7
  msgid ""
8
8
  msgstr ""
9
9
  "Project-Id-Version: PROJECT VERSION\n"
10
10
  "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
11
- "POT-Creation-Date: 2025-10-30 10:07+0100\n"
11
+ "POT-Creation-Date: 2026-01-21 20:34+0100\n"
12
12
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -17,98 +17,103 @@ msgstr ""
17
17
  "Content-Transfer-Encoding: 8bit\n"
18
18
  "Generated-By: Babel 2.17.0\n"
19
19
 
20
- #: fastapi_rtk/schemas.py:419
20
+ #: fastapi_rtk/schemas.py:421
21
21
  msgid "Columns must be a list"
22
22
  msgstr ""
23
23
 
24
- #: fastapi_rtk/schemas.py:429
24
+ #: fastapi_rtk/schemas.py:431
25
25
  msgid "Invalid columns: Not a valid JSON string"
26
26
  msgstr ""
27
27
 
28
- #: fastapi_rtk/schemas.py:452
28
+ #: fastapi_rtk/schemas.py:454
29
29
  msgid "Both 'order_column' and 'order_direction' must be filled or empty"
30
30
  msgstr ""
31
31
 
32
- #: fastapi_rtk/schemas.py:470
32
+ #: fastapi_rtk/schemas.py:472
33
33
  msgid "Filters must be a list"
34
34
  msgstr ""
35
35
 
36
- #: fastapi_rtk/schemas.py:485
36
+ #: fastapi_rtk/schemas.py:487
37
37
  msgid "Filter must be an object"
38
38
  msgstr ""
39
39
 
40
- #: fastapi_rtk/schemas.py:495
40
+ #: fastapi_rtk/schemas.py:497
41
41
  msgid "Invalid filters: Not a valid JSON string"
42
42
  msgstr ""
43
43
 
44
- #: fastapi_rtk/schemas.py:520
44
+ #: fastapi_rtk/schemas.py:522
45
45
  msgid "Opr Filters must be a list"
46
46
  msgstr ""
47
47
 
48
- #: fastapi_rtk/schemas.py:535
48
+ #: fastapi_rtk/schemas.py:537
49
49
  msgid "Opr Filter must be an object"
50
50
  msgstr ""
51
51
 
52
- #: fastapi_rtk/schemas.py:545
52
+ #: fastapi_rtk/schemas.py:547
53
53
  msgid "Invalid opr_filters: Not a valid JSON string"
54
54
  msgstr ""
55
55
 
56
- #: fastapi_rtk/api/model_rest_api.py:476
56
+ #: fastapi_rtk/api/model_rest_api.py:485
57
57
  #, python-brace-format
58
58
  msgid "List {ModelName}"
59
59
  msgstr ""
60
60
 
61
- #: fastapi_rtk/api/model_rest_api.py:485
61
+ #: fastapi_rtk/api/model_rest_api.py:494
62
62
  #, python-brace-format
63
63
  msgid "Show {ModelName}"
64
64
  msgstr ""
65
65
 
66
- #: fastapi_rtk/api/model_rest_api.py:494
66
+ #: fastapi_rtk/api/model_rest_api.py:503
67
67
  #, python-brace-format
68
68
  msgid "Add {ModelName}"
69
69
  msgstr ""
70
70
 
71
- #: fastapi_rtk/api/model_rest_api.py:503
71
+ #: fastapi_rtk/api/model_rest_api.py:512
72
72
  #, python-brace-format
73
73
  msgid "Edit {ModelName}"
74
74
  msgstr ""
75
75
 
76
- #: fastapi_rtk/api/model_rest_api.py:1395
76
+ #: fastapi_rtk/api/model_rest_api.py:1426
77
77
  msgid "OK"
78
78
  msgstr ""
79
79
 
80
- #: fastapi_rtk/api/model_rest_api.py:2411
81
- #: fastapi_rtk/api/model_rest_api.py:2810
80
+ #: fastapi_rtk/api/model_rest_api.py:2506
81
+ #: fastapi_rtk/api/model_rest_api.py:2926
82
82
  #, python-brace-format
83
83
  msgid "Number of items in '{column}' does not match the number of items found."
84
84
  msgstr ""
85
85
 
86
- #: fastapi_rtk/api/model_rest_api.py:2432
86
+ #: fastapi_rtk/api/model_rest_api.py:2527
87
87
  #, python-brace-format
88
88
  msgid "Could not find related item for column '{column}'"
89
89
  msgstr ""
90
90
 
91
- #: fastapi_rtk/api/model_rest_api.py:2464
91
+ #: fastapi_rtk/api/model_rest_api.py:2559
92
92
  #, python-brace-format
93
93
  msgid "File type from '{filename}' is not allowed."
94
94
  msgstr ""
95
95
 
96
- #: fastapi_rtk/api/model_rest_api.py:2872
96
+ #: fastapi_rtk/api/model_rest_api.py:2571
97
+ #, python-brace-format
98
+ msgid "File size from '{filename}' exceeds the allowed limit {file_size_limit}."
99
+ msgstr ""
100
+
101
+ #: fastapi_rtk/api/model_rest_api.py:2988
97
102
  #, python-brace-format
98
103
  msgid "Invalid column: {column}"
99
104
  msgstr ""
100
105
 
101
- #: fastapi_rtk/api/model_rest_api.py:2882
106
+ #: fastapi_rtk/api/model_rest_api.py:2998
102
107
  #, python-brace-format
103
108
  msgid "Invalid filter: {column}"
104
109
  msgstr ""
105
110
 
106
- #: fastapi_rtk/backends/generic/db.py:66 fastapi_rtk/backends/sqla/db.py:163
111
+ #: fastapi_rtk/backends/generic/db.py:66 fastapi_rtk/backends/sqla/db.py:165
107
112
  #, python-brace-format
108
113
  msgid "Invalid filter operator: {operator}"
109
114
  msgstr ""
110
115
 
111
- #: fastapi_rtk/backends/generic/db.py:90 fastapi_rtk/backends/sqla/db.py:194
116
+ #: fastapi_rtk/backends/generic/db.py:90 fastapi_rtk/backends/sqla/db.py:196
112
117
  #, python-brace-format
113
118
  msgid "Invalid opr_filter operator: {operator}"
114
119
  msgstr ""
@@ -223,16 +228,16 @@ msgstr ""
223
228
  msgid "Not Overlaps"
224
229
  msgstr ""
225
230
 
226
- #: fastapi_rtk/bases/db.py:463
231
+ #: fastapi_rtk/bases/db.py:481
227
232
  #, python-brace-format
228
233
  msgid "Invalid ID: {id}, expected {count} values"
229
234
  msgstr ""
230
235
 
231
- #: fastapi_rtk/bases/db.py:476
236
+ #: fastapi_rtk/bases/db.py:494
232
237
  msgid "Invalid ID"
233
238
  msgstr ""
234
239
 
235
- #: fastapi_rtk/security/sqla/apis.py:299
240
+ #: fastapi_rtk/security/sqla/apis.py:314
236
241
  msgid "User updated successfully."
237
242
  msgstr ""
238
243
 
@@ -7,7 +7,7 @@ msgid ""
7
7
  msgstr ""
8
8
  "Project-Id-Version: PROJECT VERSION\n"
9
9
  "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
10
- "POT-Creation-Date: 2025-10-30 10:07+0100\n"
10
+ "POT-Creation-Date: 2026-01-21 20:34+0100\n"
11
11
  "PO-Revision-Date: 2025-07-16 18:01+0200\n"
12
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
13
  "Language: de\n"
@@ -18,107 +18,114 @@ msgstr ""
18
18
  "Content-Transfer-Encoding: 8bit\n"
19
19
  "Generated-By: Babel 2.17.0\n"
20
20
 
21
- #: fastapi_rtk/schemas.py:419
21
+ #: fastapi_rtk/schemas.py:421
22
22
  #, fuzzy
23
23
  msgid "Columns must be a list"
24
24
  msgstr "Spalten müssen eine Liste sein"
25
25
 
26
- #: fastapi_rtk/schemas.py:429
26
+ #: fastapi_rtk/schemas.py:431
27
27
  #, fuzzy
28
28
  msgid "Invalid columns: Not a valid JSON string"
29
29
  msgstr "Ungültige Spalten: Kein gültiger JSON-String"
30
30
 
31
- #: fastapi_rtk/schemas.py:452
31
+ #: fastapi_rtk/schemas.py:454
32
32
  msgid "Both 'order_column' and 'order_direction' must be filled or empty"
33
33
  msgstr ""
34
34
  "Beide 'order_column' und 'order_direction' müssen ausgefüllt oder leer "
35
35
  "sein"
36
36
 
37
- #: fastapi_rtk/schemas.py:470
37
+ #: fastapi_rtk/schemas.py:472
38
38
  msgid "Filters must be a list"
39
39
  msgstr "Filter müssen eine Liste sein"
40
40
 
41
- #: fastapi_rtk/schemas.py:485
41
+ #: fastapi_rtk/schemas.py:487
42
42
  msgid "Filter must be an object"
43
43
  msgstr "Filter muss ein Objekt sein"
44
44
 
45
- #: fastapi_rtk/schemas.py:495
45
+ #: fastapi_rtk/schemas.py:497
46
46
  msgid "Invalid filters: Not a valid JSON string"
47
47
  msgstr "Ungültige Filters: Kein gültiger JSON-String"
48
48
 
49
- #: fastapi_rtk/schemas.py:520
49
+ #: fastapi_rtk/schemas.py:522
50
50
  #, fuzzy
51
51
  msgid "Opr Filters must be a list"
52
52
  msgstr "Opr Filter müssen eine Liste sein"
53
53
 
54
- #: fastapi_rtk/schemas.py:535
54
+ #: fastapi_rtk/schemas.py:537
55
55
  #, fuzzy
56
56
  msgid "Opr Filter must be an object"
57
57
  msgstr "Opr Filter muss ein Objekt sein"
58
58
 
59
- #: fastapi_rtk/schemas.py:545
59
+ #: fastapi_rtk/schemas.py:547
60
60
  #, fuzzy
61
61
  msgid "Invalid opr_filters: Not a valid JSON string"
62
62
  msgstr "Ungültige opr_filters: Kein gültiger JSON-String"
63
63
 
64
- #: fastapi_rtk/api/model_rest_api.py:476
64
+ #: fastapi_rtk/api/model_rest_api.py:485
65
65
  #, python-brace-format
66
66
  msgid "List {ModelName}"
67
67
  msgstr "Liste von {ModelName}"
68
68
 
69
- #: fastapi_rtk/api/model_rest_api.py:485
69
+ #: fastapi_rtk/api/model_rest_api.py:494
70
70
  #, python-brace-format
71
71
  msgid "Show {ModelName}"
72
72
  msgstr "Anzeigen von {ModelName}"
73
73
 
74
- #: fastapi_rtk/api/model_rest_api.py:494
74
+ #: fastapi_rtk/api/model_rest_api.py:503
75
75
  #, python-brace-format
76
76
  msgid "Add {ModelName}"
77
77
  msgstr "Hinzufügen von {ModelName}"
78
78
 
79
- #: fastapi_rtk/api/model_rest_api.py:503
79
+ #: fastapi_rtk/api/model_rest_api.py:512
80
80
  #, python-brace-format
81
81
  msgid "Edit {ModelName}"
82
82
  msgstr "Bearbeiten von {ModelName}"
83
83
 
84
- #: fastapi_rtk/api/model_rest_api.py:1395
84
+ #: fastapi_rtk/api/model_rest_api.py:1426
85
85
  msgid "OK"
86
86
  msgstr "OK"
87
87
 
88
- #: fastapi_rtk/api/model_rest_api.py:2411
89
- #: fastapi_rtk/api/model_rest_api.py:2810
88
+ #: fastapi_rtk/api/model_rest_api.py:2506
89
+ #: fastapi_rtk/api/model_rest_api.py:2926
90
90
  #, python-brace-format
91
91
  msgid "Number of items in '{column}' does not match the number of items found."
92
92
  msgstr ""
93
93
  "Anzahl der Elemente in '{column}' stimmt nicht mit der Anzahl der "
94
94
  "gefundenen Elemente überein."
95
95
 
96
- #: fastapi_rtk/api/model_rest_api.py:2432
96
+ #: fastapi_rtk/api/model_rest_api.py:2527
97
97
  #, python-brace-format
98
98
  msgid "Could not find related item for column '{column}'"
99
99
  msgstr "Konnte kein zugehöriges Element für die Spalte '{column}' finden"
100
100
 
101
- #: fastapi_rtk/api/model_rest_api.py:2464
101
+ #: fastapi_rtk/api/model_rest_api.py:2559
102
102
  #, python-brace-format
103
103
  msgid "File type from '{filename}' is not allowed."
104
104
  msgstr "Dateityp von '{filename}' ist nicht erlaubt."
105
105
 
106
- #: fastapi_rtk/api/model_rest_api.py:2872
106
+ #: fastapi_rtk/api/model_rest_api.py:2571
107
+ #, fuzzy, python-brace-format
108
+ msgid "File size from '{filename}' exceeds the allowed limit {file_size_limit}."
109
+ msgstr ""
110
+ "Dateigröße von '{filename}' überschreitet das zulässige Limit "
111
+ "{file_size_limit}."
112
+
113
+ #: fastapi_rtk/api/model_rest_api.py:2988
107
114
  #, fuzzy, python-brace-format
108
115
  msgid "Invalid column: {column}"
109
116
  msgstr "Ungültige Spalte: {column}"
110
117
 
111
- #: fastapi_rtk/api/model_rest_api.py:2882
118
+ #: fastapi_rtk/api/model_rest_api.py:2998
112
119
  #, python-brace-format
113
120
  msgid "Invalid filter: {column}"
114
121
  msgstr "Ungültiger Filter: {column}"
115
122
 
116
- #: fastapi_rtk/backends/generic/db.py:66 fastapi_rtk/backends/sqla/db.py:163
123
+ #: fastapi_rtk/backends/generic/db.py:66 fastapi_rtk/backends/sqla/db.py:165
117
124
  #, python-brace-format
118
125
  msgid "Invalid filter operator: {operator}"
119
126
  msgstr "Ungültiger Filteroperator: {operator}"
120
127
 
121
- #: fastapi_rtk/backends/generic/db.py:90 fastapi_rtk/backends/sqla/db.py:194
128
+ #: fastapi_rtk/backends/generic/db.py:90 fastapi_rtk/backends/sqla/db.py:196
122
129
  #, fuzzy, python-brace-format
123
130
  msgid "Invalid opr_filter operator: {operator}"
124
131
  msgstr "Ungültiger Oprfilteroperator: {operator}"
@@ -233,16 +240,16 @@ msgstr "Überlappt"
233
240
  msgid "Not Overlaps"
234
241
  msgstr "Nicht überlappt"
235
242
 
236
- #: fastapi_rtk/bases/db.py:463
243
+ #: fastapi_rtk/bases/db.py:481
237
244
  #, python-brace-format
238
245
  msgid "Invalid ID: {id}, expected {count} values"
239
246
  msgstr "Ungültige ID: {id}, erwartet {count} Werte"
240
247
 
241
- #: fastapi_rtk/bases/db.py:476
248
+ #: fastapi_rtk/bases/db.py:494
242
249
  msgid "Invalid ID"
243
250
  msgstr "Ungültige ID"
244
251
 
245
- #: fastapi_rtk/security/sqla/apis.py:299
252
+ #: fastapi_rtk/security/sqla/apis.py:314
246
253
  msgid "User updated successfully."
247
254
  msgstr "Benutzer erfolgreich aktualisiert."
248
255
 
@@ -7,7 +7,7 @@ msgid ""
7
7
  msgstr ""
8
8
  "Project-Id-Version: PROJECT VERSION\n"
9
9
  "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
10
- "POT-Creation-Date: 2025-10-30 10:07+0100\n"
10
+ "POT-Creation-Date: 2026-01-21 20:34+0100\n"
11
11
  "PO-Revision-Date: 2025-07-16 18:01+0200\n"
12
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
13
  "Language: en\n"
@@ -18,103 +18,108 @@ msgstr ""
18
18
  "Content-Transfer-Encoding: 8bit\n"
19
19
  "Generated-By: Babel 2.17.0\n"
20
20
 
21
- #: fastapi_rtk/schemas.py:419
21
+ #: fastapi_rtk/schemas.py:421
22
22
  #, fuzzy
23
23
  msgid "Columns must be a list"
24
24
  msgstr "Columns must be a list"
25
25
 
26
- #: fastapi_rtk/schemas.py:429
26
+ #: fastapi_rtk/schemas.py:431
27
27
  #, fuzzy
28
28
  msgid "Invalid columns: Not a valid JSON string"
29
29
  msgstr "Invalid columns: Not a valid JSON string"
30
30
 
31
- #: fastapi_rtk/schemas.py:452
31
+ #: fastapi_rtk/schemas.py:454
32
32
  msgid "Both 'order_column' and 'order_direction' must be filled or empty"
33
33
  msgstr "Both 'order_column' and 'order_direction' must be filled or empty"
34
34
 
35
- #: fastapi_rtk/schemas.py:470
35
+ #: fastapi_rtk/schemas.py:472
36
36
  msgid "Filters must be a list"
37
37
  msgstr "Filters must be a list"
38
38
 
39
- #: fastapi_rtk/schemas.py:485
39
+ #: fastapi_rtk/schemas.py:487
40
40
  msgid "Filter must be an object"
41
41
  msgstr "Filter must be an object"
42
42
 
43
- #: fastapi_rtk/schemas.py:495
43
+ #: fastapi_rtk/schemas.py:497
44
44
  msgid "Invalid filters: Not a valid JSON string"
45
45
  msgstr "Invalid filters: Not a valid JSON string"
46
46
 
47
- #: fastapi_rtk/schemas.py:520
47
+ #: fastapi_rtk/schemas.py:522
48
48
  #, fuzzy
49
49
  msgid "Opr Filters must be a list"
50
50
  msgstr "Opr Filters must be a list"
51
51
 
52
- #: fastapi_rtk/schemas.py:535
52
+ #: fastapi_rtk/schemas.py:537
53
53
  #, fuzzy
54
54
  msgid "Opr Filter must be an object"
55
55
  msgstr "Opr Filter must be an object"
56
56
 
57
- #: fastapi_rtk/schemas.py:545
57
+ #: fastapi_rtk/schemas.py:547
58
58
  #, fuzzy
59
59
  msgid "Invalid opr_filters: Not a valid JSON string"
60
60
  msgstr "Invalid opr_filters: Not a valid JSON string"
61
61
 
62
- #: fastapi_rtk/api/model_rest_api.py:476
62
+ #: fastapi_rtk/api/model_rest_api.py:485
63
63
  #, python-brace-format
64
64
  msgid "List {ModelName}"
65
65
  msgstr "List of {ModelName}"
66
66
 
67
- #: fastapi_rtk/api/model_rest_api.py:485
67
+ #: fastapi_rtk/api/model_rest_api.py:494
68
68
  #, python-brace-format
69
69
  msgid "Show {ModelName}"
70
70
  msgstr "Show {ModelName}"
71
71
 
72
- #: fastapi_rtk/api/model_rest_api.py:494
72
+ #: fastapi_rtk/api/model_rest_api.py:503
73
73
  #, python-brace-format
74
74
  msgid "Add {ModelName}"
75
75
  msgstr "Add {ModelName}"
76
76
 
77
- #: fastapi_rtk/api/model_rest_api.py:503
77
+ #: fastapi_rtk/api/model_rest_api.py:512
78
78
  #, python-brace-format
79
79
  msgid "Edit {ModelName}"
80
80
  msgstr "Edit {ModelName}"
81
81
 
82
- #: fastapi_rtk/api/model_rest_api.py:1395
82
+ #: fastapi_rtk/api/model_rest_api.py:1426
83
83
  msgid "OK"
84
84
  msgstr "OK"
85
85
 
86
- #: fastapi_rtk/api/model_rest_api.py:2411
87
- #: fastapi_rtk/api/model_rest_api.py:2810
86
+ #: fastapi_rtk/api/model_rest_api.py:2506
87
+ #: fastapi_rtk/api/model_rest_api.py:2926
88
88
  #, python-brace-format
89
89
  msgid "Number of items in '{column}' does not match the number of items found."
90
90
  msgstr "Number of items in '{column}' does not match the number of items found."
91
91
 
92
- #: fastapi_rtk/api/model_rest_api.py:2432
92
+ #: fastapi_rtk/api/model_rest_api.py:2527
93
93
  #, python-brace-format
94
94
  msgid "Could not find related item for column '{column}'"
95
95
  msgstr "Could not find related item for column '{column}'"
96
96
 
97
- #: fastapi_rtk/api/model_rest_api.py:2464
97
+ #: fastapi_rtk/api/model_rest_api.py:2559
98
98
  #, python-brace-format
99
99
  msgid "File type from '{filename}' is not allowed."
100
100
  msgstr "File type from '{filename}' is not allowed."
101
101
 
102
- #: fastapi_rtk/api/model_rest_api.py:2872
102
+ #: fastapi_rtk/api/model_rest_api.py:2571
103
+ #, fuzzy, python-brace-format
104
+ msgid "File size from '{filename}' exceeds the allowed limit {file_size_limit}."
105
+ msgstr "File size from '{filename}' exceeds the allowed limit {file_size_limit}."
106
+
107
+ #: fastapi_rtk/api/model_rest_api.py:2988
103
108
  #, fuzzy, python-brace-format
104
109
  msgid "Invalid column: {column}"
105
110
  msgstr "Invalid column: {column}"
106
111
 
107
- #: fastapi_rtk/api/model_rest_api.py:2882
112
+ #: fastapi_rtk/api/model_rest_api.py:2998
108
113
  #, python-brace-format
109
114
  msgid "Invalid filter: {column}"
110
115
  msgstr "Invalid filter: {column}"
111
116
 
112
- #: fastapi_rtk/backends/generic/db.py:66 fastapi_rtk/backends/sqla/db.py:163
117
+ #: fastapi_rtk/backends/generic/db.py:66 fastapi_rtk/backends/sqla/db.py:165
113
118
  #, python-brace-format
114
119
  msgid "Invalid filter operator: {operator}"
115
120
  msgstr "Invalid filter operator: {operator}"
116
121
 
117
- #: fastapi_rtk/backends/generic/db.py:90 fastapi_rtk/backends/sqla/db.py:194
122
+ #: fastapi_rtk/backends/generic/db.py:90 fastapi_rtk/backends/sqla/db.py:196
118
123
  #, fuzzy, python-brace-format
119
124
  msgid "Invalid opr_filter operator: {operator}"
120
125
  msgstr "Invalid opr_filter operator: {operator}"
@@ -229,16 +234,16 @@ msgstr "Overlaps"
229
234
  msgid "Not Overlaps"
230
235
  msgstr "Not Overlaps"
231
236
 
232
- #: fastapi_rtk/bases/db.py:463
237
+ #: fastapi_rtk/bases/db.py:481
233
238
  #, python-brace-format
234
239
  msgid "Invalid ID: {id}, expected {count} values"
235
240
  msgstr "Invalid ID: {id}, expected {count} values"
236
241
 
237
- #: fastapi_rtk/bases/db.py:476
242
+ #: fastapi_rtk/bases/db.py:494
238
243
  msgid "Invalid ID"
239
244
  msgstr "Invalid ID"
240
245
 
241
- #: fastapi_rtk/security/sqla/apis.py:299
246
+ #: fastapi_rtk/security/sqla/apis.py:314
242
247
  msgid "User updated successfully."
243
248
  msgstr "User updated successfully."
244
249
 
fastapi_rtk/setting.py CHANGED
@@ -127,12 +127,20 @@ class _Setting:
127
127
  def FILE_ALLOWED_EXTENSIONS(self) -> list[str] | None:
128
128
  return g.config.get("FILE_ALLOWED_EXTENSIONS")
129
129
 
130
+ @property
131
+ def FILE_MAX_SIZE(self) -> int | None:
132
+ return g.config.get("FILE_MAX_SIZE")
133
+
130
134
  @property
131
135
  def IMG_ALLOWED_EXTENSIONS(self) -> list[str]:
132
136
  return g.config.get(
133
137
  "IMG_ALLOWED_EXTENSIONS", ["gif", "jpg", "jpeg", "png", "tiff"]
134
138
  )
135
139
 
140
+ @property
141
+ def IMG_MAX_SIZE(self) -> int | None:
142
+ return g.config.get("IMG_MAX_SIZE", self.FILE_MAX_SIZE)
143
+
136
144
  @property
137
145
  def LANGUAGES(self) -> str:
138
146
  """
@@ -6,11 +6,11 @@ from .csv_json_converter import *
6
6
  from .deep_merge import *
7
7
  from .extender_mixin import *
8
8
  from .flask_appbuilder_utils import *
9
+ from .formatter import *
9
10
  from .hooks import *
10
11
  from .lazy import *
11
12
  from .merge_schema import *
12
13
  from .multiple_async_contexts import *
13
- from .prettify_dict import *
14
14
  from .pydantic import *
15
15
  from .run_utils import *
16
16
  from .self_dependencies import *
@@ -36,6 +36,9 @@ __all__ = [
36
36
  # .flask_appbuilder_utils
37
37
  "uuid_namegen",
38
38
  "secure_filename",
39
+ # .formatter
40
+ "prettify_dict",
41
+ "format_file_size",
39
42
  # .hooks
40
43
  "hooks",
41
44
  # .lazy
@@ -46,8 +49,6 @@ __all__ = [
46
49
  "merge_schema",
47
50
  # . multiple_async_contexts
48
51
  "multiple_async_contexts",
49
- # .prettify_dict
50
- "prettify_dict",
51
52
  # .pydantic
52
53
  "generate_schema_from_typed_dict",
53
54
  "get_pydantic_model_field",