ramifice 0.8.11__py3-none-any.whl → 0.8.13__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.
Files changed (84) hide show
  1. ramifice/__init__.py +16 -1
  2. ramifice/commons/__init__.py +2 -2
  3. ramifice/commons/general.py +11 -11
  4. ramifice/commons/indexes.py +8 -8
  5. ramifice/commons/many.py +10 -6
  6. ramifice/commons/one.py +13 -8
  7. ramifice/commons/tools.py +4 -4
  8. ramifice/commons/unit_manager.py +15 -5
  9. ramifice/fields/__init__.py +1 -1
  10. ramifice/fields/bool_field.py +26 -18
  11. ramifice/fields/choice_float_dyn_field.py +29 -21
  12. ramifice/fields/choice_float_field.py +41 -33
  13. ramifice/fields/choice_float_mult_dyn_field.py +29 -21
  14. ramifice/fields/choice_float_mult_field.py +48 -40
  15. ramifice/fields/choice_int_dyn_field.py +29 -21
  16. ramifice/fields/choice_int_field.py +41 -33
  17. ramifice/fields/choice_int_mult_dyn_field.py +29 -21
  18. ramifice/fields/choice_int_mult_field.py +48 -40
  19. ramifice/fields/choice_text_dyn_field.py +29 -21
  20. ramifice/fields/choice_text_field.py +47 -39
  21. ramifice/fields/choice_text_mult_dyn_field.py +29 -21
  22. ramifice/fields/choice_text_mult_field.py +48 -40
  23. ramifice/fields/color_field.py +40 -32
  24. ramifice/fields/date_field.py +49 -40
  25. ramifice/fields/date_time_field.py +49 -40
  26. ramifice/fields/email_field.py +42 -34
  27. ramifice/fields/file_field.py +45 -35
  28. ramifice/fields/float_field.py +56 -47
  29. ramifice/fields/general/__init__.py +1 -1
  30. ramifice/fields/general/choice_group.py +2 -2
  31. ramifice/fields/general/date_group.py +2 -2
  32. ramifice/fields/general/field.py +2 -2
  33. ramifice/fields/general/file_group.py +2 -2
  34. ramifice/fields/general/number_group.py +2 -2
  35. ramifice/fields/general/text_group.py +3 -3
  36. ramifice/fields/id_field.py +35 -28
  37. ramifice/fields/image_field.py +67 -57
  38. ramifice/fields/integer_field.py +56 -47
  39. ramifice/fields/ip_field.py +41 -34
  40. ramifice/fields/password_field.py +29 -22
  41. ramifice/fields/phone_field.py +44 -36
  42. ramifice/fields/slug_field.py +30 -22
  43. ramifice/fields/text_field.py +43 -35
  44. ramifice/fields/url_field.py +40 -33
  45. ramifice/models/__init__.py +1 -1
  46. ramifice/models/decorator.py +33 -11
  47. ramifice/models/model.py +16 -16
  48. ramifice/paladins/__init__.py +2 -2
  49. ramifice/paladins/check.py +8 -3
  50. ramifice/paladins/delete.py +9 -3
  51. ramifice/paladins/groups/__init__.py +1 -1
  52. ramifice/paladins/groups/bool_group.py +3 -3
  53. ramifice/paladins/groups/choice_group.py +3 -3
  54. ramifice/paladins/groups/date_group.py +3 -3
  55. ramifice/paladins/groups/file_group.py +3 -3
  56. ramifice/paladins/groups/id_group.py +3 -3
  57. ramifice/paladins/groups/img_group.py +3 -3
  58. ramifice/paladins/groups/num_group.py +3 -3
  59. ramifice/paladins/groups/pass_group.py +3 -3
  60. ramifice/paladins/groups/slug_group.py +8 -3
  61. ramifice/paladins/groups/text_group.py +3 -3
  62. ramifice/paladins/password.py +11 -4
  63. ramifice/paladins/refrash.py +7 -3
  64. ramifice/paladins/save.py +9 -3
  65. ramifice/paladins/tools.py +11 -6
  66. ramifice/paladins/validation.py +4 -4
  67. ramifice/utils/__init__.py +1 -1
  68. ramifice/utils/constants.py +1 -1
  69. ramifice/utils/errors.py +7 -7
  70. ramifice/utils/fixtures.py +7 -2
  71. ramifice/utils/migration.py +18 -9
  72. ramifice/utils/mixins/__init__.py +1 -1
  73. ramifice/utils/mixins/add_valid.py +3 -3
  74. ramifice/utils/mixins/hooks.py +8 -8
  75. ramifice/utils/mixins/indexing.py +3 -3
  76. ramifice/utils/mixins/json_converter.py +6 -6
  77. ramifice/utils/tools.py +12 -12
  78. ramifice/utils/translations.py +24 -8
  79. ramifice/utils/unit.py +8 -3
  80. {ramifice-0.8.11.dist-info → ramifice-0.8.13.dist-info}/METADATA +9 -5
  81. ramifice-0.8.13.dist-info/RECORD +84 -0
  82. ramifice-0.8.11.dist-info/RECORD +0 -84
  83. {ramifice-0.8.11.dist-info → ramifice-0.8.13.dist-info}/WHEEL +0 -0
  84. {ramifice-0.8.11.dist-info → ramifice-0.8.13.dist-info}/licenses/LICENSE +0 -0
@@ -1,15 +1,20 @@
1
- """Field of Model for enter (float) number."""
1
+ """Ramifice - Field of Model for enter (float) number."""
2
2
 
3
3
  __all__ = ("FloatField",)
4
4
 
5
+ import logging
6
+ from typing import Literal
7
+
5
8
  from ramifice.fields.general.field import Field
6
9
  from ramifice.fields.general.number_group import NumberGroup
7
10
  from ramifice.utils import constants
8
11
  from ramifice.utils.mixins.json_converter import JsonMixin
9
12
 
13
+ logger = logging.getLogger(__name__)
14
+
10
15
 
11
16
  class FloatField(Field, NumberGroup, JsonMixin):
12
- """Field of Model for enter (float) number."""
17
+ """Ramifice - Field of Model for enter (float) number."""
13
18
 
14
19
  def __init__( # noqa: D107
15
20
  self,
@@ -27,53 +32,57 @@ class FloatField(Field, NumberGroup, JsonMixin):
27
32
  max_number: float | None = None,
28
33
  min_number: float | None = None,
29
34
  step: float = 1.0,
30
- input_type: str = "number", # number | range
35
+ input_type: Literal["number", "range"] = "number",
31
36
  ):
32
37
  if constants.DEBUG:
33
- if input_type not in ["number", "range"]:
34
- raise AssertionError(
35
- "Parameter `input_type` - Invalid input type! "
36
- + "The permissible value of `number` or `range`."
37
- )
38
- if max_number is not None and not isinstance(max_number, float):
39
- raise AssertionError("Parameter `max_number` - Not а number `float` type!")
40
- if min_number is not None and not isinstance(min_number, float):
41
- raise AssertionError("Parameter `min_number` - Not а number `float` type!")
42
- if not isinstance(step, float):
43
- raise AssertionError("Parameter `step` - Not а number `float` type!")
44
- if max_number is not None and min_number is not None and max_number <= min_number:
45
- raise AssertionError(
46
- "The `max_number` parameter should be more than the `min_number`!"
47
- )
48
- if default is not None:
49
- if not isinstance(default, float):
50
- raise AssertionError("Parameter `default` - Not а number `float` type!")
51
- if max_number is not None and default > max_number:
52
- raise AssertionError("Parameter `default` is more `max_number`!")
53
- if max_number is not None and default < min_number: # type: ignore
54
- raise AssertionError("Parameter `default` is less `min_number`!")
55
- if not isinstance(label, str):
56
- raise AssertionError("Parameter `default` - Not а `str` type!")
57
- if not isinstance(disabled, bool):
58
- raise AssertionError("Parameter `disabled` - Not а `bool` type!")
59
- if not isinstance(hide, bool):
60
- raise AssertionError("Parameter `hide` - Not а `bool` type!")
61
- if not isinstance(ignored, bool):
62
- raise AssertionError("Parameter `ignored` - Not а `bool` type!")
63
- if not isinstance(ignored, bool):
64
- raise AssertionError("Parameter `ignored` - Not а `bool` type!")
65
- if not isinstance(hint, str):
66
- raise AssertionError("Parameter `hint` - Not а `str` type!")
67
- if warning is not None and not isinstance(warning, list):
68
- raise AssertionError("Parameter `warning` - Not а `list` type!")
69
- if not isinstance(placeholder, str):
70
- raise AssertionError("Parameter `placeholder` - Not а `str` type!")
71
- if not isinstance(required, bool):
72
- raise AssertionError("Parameter `required` - Not а `bool` type!")
73
- if not isinstance(readonly, bool):
74
- raise AssertionError("Parameter `readonly` - Not а `bool` type!")
75
- if not isinstance(unique, bool):
76
- raise AssertionError("Parameter `unique` - Not а `bool` type!")
38
+ try:
39
+ if input_type not in ["number", "range"]:
40
+ raise AssertionError(
41
+ "Parameter `input_type` - Invalid input type! "
42
+ + "The permissible value of `number` or `range`."
43
+ )
44
+ if max_number is not None and not isinstance(max_number, float):
45
+ raise AssertionError("Parameter `max_number` - Not а number `float` type!")
46
+ if min_number is not None and not isinstance(min_number, float):
47
+ raise AssertionError("Parameter `min_number` - Not а number `float` type!")
48
+ if not isinstance(step, float):
49
+ raise AssertionError("Parameter `step` - Not а number `float` type!")
50
+ if max_number is not None and min_number is not None and max_number <= min_number:
51
+ raise AssertionError(
52
+ "The `max_number` parameter should be more than the `min_number`!"
53
+ )
54
+ if default is not None:
55
+ if not isinstance(default, float):
56
+ raise AssertionError("Parameter `default` - Not а number `float` type!")
57
+ if max_number is not None and default > max_number:
58
+ raise AssertionError("Parameter `default` is more `max_number`!")
59
+ if max_number is not None and default < min_number: # type: ignore
60
+ raise AssertionError("Parameter `default` is less `min_number`!")
61
+ if not isinstance(label, str):
62
+ raise AssertionError("Parameter `default` - Not а `str` type!")
63
+ if not isinstance(disabled, bool):
64
+ raise AssertionError("Parameter `disabled` - Not а `bool` type!")
65
+ if not isinstance(hide, bool):
66
+ raise AssertionError("Parameter `hide` - Not а `bool` type!")
67
+ if not isinstance(ignored, bool):
68
+ raise AssertionError("Parameter `ignored` - Not а `bool` type!")
69
+ if not isinstance(ignored, bool):
70
+ raise AssertionError("Parameter `ignored` - Not а `bool` type!")
71
+ if not isinstance(hint, str):
72
+ raise AssertionError("Parameter `hint` - Not а `str` type!")
73
+ if warning is not None and not isinstance(warning, list):
74
+ raise AssertionError("Parameter `warning` - Not а `list` type!")
75
+ if not isinstance(placeholder, str):
76
+ raise AssertionError("Parameter `placeholder` - Not а `str` type!")
77
+ if not isinstance(required, bool):
78
+ raise AssertionError("Parameter `required` - Not а `bool` type!")
79
+ if not isinstance(readonly, bool):
80
+ raise AssertionError("Parameter `readonly` - Not а `bool` type!")
81
+ if not isinstance(unique, bool):
82
+ raise AssertionError("Parameter `unique` - Not а `bool` type!")
83
+ except AssertionError as err:
84
+ logger.error(str(err))
85
+ raise err
77
86
 
78
87
  Field.__init__(
79
88
  self,
@@ -1 +1 @@
1
- """Abstract classes for the fields."""
1
+ """Ramifice - Abstract classes for the fields."""
@@ -1,4 +1,4 @@
1
- """General additional parameters for choice fields."""
1
+ """Ramifice - General additional parameters for choice fields."""
2
2
 
3
3
  __all__ = ("ChoiceGroup",)
4
4
 
@@ -6,7 +6,7 @@ from abc import ABCMeta
6
6
 
7
7
 
8
8
  class ChoiceGroup(metaclass=ABCMeta):
9
- """General additional parameters for choice fields.
9
+ """Ramifice - General additional parameters for choice fields.
10
10
 
11
11
  Attributes:
12
12
  input_type -- Input type for a web form field.
@@ -1,4 +1,4 @@
1
- """General additional parameters for date|datetime fields."""
1
+ """Ramifice - General additional parameters for date|datetime fields."""
2
2
 
3
3
  __all__ = ("DateGroup",)
4
4
 
@@ -7,7 +7,7 @@ from datetime import datetime
7
7
 
8
8
 
9
9
  class DateGroup(metaclass=ABCMeta):
10
- """General additional parameters for date|datetime fields.
10
+ """Ramifice - General additional parameters for date|datetime fields.
11
11
 
12
12
  Attributes:
13
13
  input_type -- Input type for a web form field.
@@ -1,4 +1,4 @@
1
- """General parameters for all types fields of Model."""
1
+ """Ramifice - General parameters for all types fields of Model."""
2
2
 
3
3
  __all__ = ("Field",)
4
4
 
@@ -6,7 +6,7 @@ from abc import ABCMeta
6
6
 
7
7
 
8
8
  class Field(metaclass=ABCMeta):
9
- """General parameters for all types fields of Model.
9
+ """Ramifice - General parameters for all types fields of Model.
10
10
 
11
11
  Attributes:
12
12
  label -- Text label for a web form field.
@@ -1,4 +1,4 @@
1
- """General additional parameters for file fields."""
1
+ """Ramifice - General additional parameters for file fields."""
2
2
 
3
3
  __all__ = ("FileGroup",)
4
4
 
@@ -6,7 +6,7 @@ from abc import ABCMeta
6
6
 
7
7
 
8
8
  class FileGroup(metaclass=ABCMeta):
9
- """General additional parameters for file fields.
9
+ """Ramifice - General additional parameters for file fields.
10
10
 
11
11
  Attributes:
12
12
  placeholder -- Displays prompt text.
@@ -1,4 +1,4 @@
1
- """General additional parameters for number fields."""
1
+ """Ramifice - General additional parameters for number fields."""
2
2
 
3
3
  __all__ = ("NumberGroup",)
4
4
 
@@ -6,7 +6,7 @@ from abc import ABCMeta
6
6
 
7
7
 
8
8
  class NumberGroup(metaclass=ABCMeta):
9
- """General additional parameters for number fields.
9
+ """Ramifice - General additional parameters for number fields.
10
10
 
11
11
  Attributes:
12
12
  placeholder -- Displays prompt text.
@@ -1,4 +1,4 @@
1
- """General additional parameters for text fields."""
1
+ """Ramifice - General additional parameters for text fields."""
2
2
 
3
3
  __all__ = ("TextGroup",)
4
4
 
@@ -6,7 +6,7 @@ from abc import ABCMeta
6
6
 
7
7
 
8
8
  class TextGroup(metaclass=ABCMeta):
9
- """General additional parameters for text fields.
9
+ """Ramifice - General additional parameters for text fields.
10
10
 
11
11
  Attributes:
12
12
  input_type -- Input type for a web form field.
@@ -32,7 +32,7 @@ class TextGroup(metaclass=ABCMeta):
32
32
  self.unique = unique
33
33
 
34
34
  def __len__(self) -> int:
35
- """Return length of field `value`."""
35
+ """Ramifice - Return length of field `value`."""
36
36
  value = self.value
37
37
  if value is None:
38
38
  return 0
@@ -1,7 +1,8 @@
1
- """Field of Model for enter identifier of document."""
1
+ """Ramifice - Field of Model for enter identifier of document."""
2
2
 
3
3
  __all__ = ("IDField",)
4
4
 
5
+ import logging
5
6
  from typing import Any
6
7
 
7
8
  import orjson
@@ -10,9 +11,11 @@ from bson.objectid import ObjectId
10
11
  from ramifice.fields.general.field import Field
11
12
  from ramifice.utils import constants
12
13
 
14
+ logger = logging.getLogger(__name__)
15
+
13
16
 
14
17
  class IDField(Field):
15
- """Field of Model for enter identifier of document.
18
+ """Ramifice - Field of Model for enter identifier of document.
16
19
 
17
20
  Attributes:
18
21
  input_type -- Input type for a web form field.
@@ -36,28 +39,32 @@ class IDField(Field):
36
39
  unique: bool = False,
37
40
  ):
38
41
  if constants.DEBUG:
39
- if not isinstance(label, str):
40
- raise AssertionError("Parameter `default` - Not а `str` type!")
41
- if not isinstance(disabled, bool):
42
- raise AssertionError("Parameter `disabled` - Not а `bool` type!")
43
- if not isinstance(hide, bool):
44
- raise AssertionError("Parameter `hide` - Not а `bool` type!")
45
- if not isinstance(ignored, bool):
46
- raise AssertionError("Parameter `ignored` - Not а `bool` type!")
47
- if not isinstance(ignored, bool):
48
- raise AssertionError("Parameter `ignored` - Not а `bool` type!")
49
- if not isinstance(hint, str):
50
- raise AssertionError("Parameter `hint` - Not а `str` type!")
51
- if warning is not None and not isinstance(warning, list):
52
- raise AssertionError("Parameter `warning` - Not а `list` type!")
53
- if not isinstance(placeholder, str):
54
- raise AssertionError("Parameter `placeholder` - Not а `str` type!")
55
- if not isinstance(required, bool):
56
- raise AssertionError("Parameter `required` - Not а `bool` type!")
57
- if not isinstance(readonly, bool):
58
- raise AssertionError("Parameter `readonly` - Not а `bool` type!")
59
- if not isinstance(unique, bool):
60
- raise AssertionError("Parameter `unique` - Not а `bool` type!")
42
+ try:
43
+ if not isinstance(label, str):
44
+ raise AssertionError("Parameter `default` - Not а `str` type!")
45
+ if not isinstance(disabled, bool):
46
+ raise AssertionError("Parameter `disabled` - Not а `bool` type!")
47
+ if not isinstance(hide, bool):
48
+ raise AssertionError("Parameter `hide` - Not а `bool` type!")
49
+ if not isinstance(ignored, bool):
50
+ raise AssertionError("Parameter `ignored` - Not а `bool` type!")
51
+ if not isinstance(ignored, bool):
52
+ raise AssertionError("Parameter `ignored` - Not а `bool` type!")
53
+ if not isinstance(hint, str):
54
+ raise AssertionError("Parameter `hint` - Not а `str` type!")
55
+ if warning is not None and not isinstance(warning, list):
56
+ raise AssertionError("Parameter `warning` - Not а `list` type!")
57
+ if not isinstance(placeholder, str):
58
+ raise AssertionError("Parameter `placeholder` - Not а `str` type!")
59
+ if not isinstance(required, bool):
60
+ raise AssertionError("Parameter `required` - Not а `bool` type!")
61
+ if not isinstance(readonly, bool):
62
+ raise AssertionError("Parameter `readonly` - Not а `bool` type!")
63
+ if not isinstance(unique, bool):
64
+ raise AssertionError("Parameter `unique` - Not а `bool` type!")
65
+ except AssertionError as err:
66
+ logger.error(str(err))
67
+ raise err
61
68
 
62
69
  Field.__init__(
63
70
  self,
@@ -80,7 +87,7 @@ class IDField(Field):
80
87
  self.alerts: list[str] = []
81
88
 
82
89
  def to_dict(self) -> dict[str, Any]:
83
- """Convert object instance to a dictionary."""
90
+ """Ramifice - Convert object instance to a dictionary."""
84
91
  json_dict: dict[str, Any] = {}
85
92
  for name, data in self.__dict__.items():
86
93
  if not callable(data):
@@ -91,12 +98,12 @@ class IDField(Field):
91
98
  return json_dict
92
99
 
93
100
  def to_json(self) -> str:
94
- """Convert object instance to a JSON string."""
101
+ """Ramifice - Convert object instance to a JSON string."""
95
102
  return orjson.dumps(self.to_dict()).decode("utf-8")
96
103
 
97
104
  @classmethod
98
105
  def from_dict(cls, json_dict: dict[str, Any]) -> Any:
99
- """Convert JSON string to a object instance."""
106
+ """Ramifice - Convert JSON string to a object instance."""
100
107
  obj = cls()
101
108
  for name, data in json_dict.items():
102
109
  if name == "value" and data is not None:
@@ -107,6 +114,6 @@ class IDField(Field):
107
114
 
108
115
  @classmethod
109
116
  def from_json(cls, json_str: str) -> Any:
110
- """Convert JSON string to a object instance."""
117
+ """Ramifice - Convert JSON string to a object instance."""
111
118
  json_dict = orjson.loads(json_str)
112
119
  return cls.from_dict(json_dict)
@@ -1,7 +1,8 @@
1
- """Field of Model for upload image."""
1
+ """Ramifice - Field of Model for upload image."""
2
2
 
3
3
  __all__ = ("ImageField",)
4
4
 
5
+ import logging
5
6
  import uuid
6
7
  from base64 import b64decode
7
8
  from datetime import date
@@ -18,9 +19,11 @@ from ramifice.utils.constants import MEDIA_ROOT, MEDIA_URL
18
19
  from ramifice.utils.errors import FileHasNoExtensionError
19
20
  from ramifice.utils.mixins.json_converter import JsonMixin
20
21
 
22
+ logger = logging.getLogger(__name__)
23
+
21
24
 
22
25
  class ImageField(Field, FileGroup, JsonMixin):
23
- """Field of Model for upload image."""
26
+ """Ramifice - Field of Model for upload image."""
24
27
 
25
28
  def __init__( # noqa: D107
26
29
  self,
@@ -42,62 +45,66 @@ class ImageField(Field, FileGroup, JsonMixin):
42
45
  thumbnails: dict[str, int] | None = None,
43
46
  ):
44
47
  if constants.DEBUG:
45
- if default is not None:
46
- if not isinstance(default, str):
47
- raise AssertionError("Parameter `default` - Not а `str` type!")
48
- if len(default) == 0:
49
- raise AssertionError(
50
- "The `default` parameter should not contain an empty string!"
51
- )
52
- if thumbnails is not None:
53
- if not isinstance(thumbnails, dict):
54
- raise AssertionError("Parameter `thumbnails` - Not а `dict` type!")
55
- if len(thumbnails) == 0:
56
- raise AssertionError(
57
- "The `thumbnails` parameter should not contain an empty dictionary!"
58
- )
59
- size_name_list = ["lg", "md", "sm", "xs"]
60
- curr_size_thumb: int = 0
61
- for size_name in thumbnails.keys():
62
- if size_name not in size_name_list:
48
+ try:
49
+ if default is not None:
50
+ if not isinstance(default, str):
51
+ raise AssertionError("Parameter `default` - Not а `str` type!")
52
+ if len(default) == 0:
53
+ raise AssertionError(
54
+ "The `default` parameter should not contain an empty string!"
55
+ )
56
+ if thumbnails is not None:
57
+ if not isinstance(thumbnails, dict):
58
+ raise AssertionError("Parameter `thumbnails` - Not а `dict` type!")
59
+ if len(thumbnails) == 0:
63
60
  raise AssertionError(
64
- f"The `thumbnails` parameter contains an unacceptable size name `{size_name}`!\n"
65
- + " Allowed names: lg, md, sm, xs.\n"
66
- + " Use all sizes is not necessary.",
61
+ "The `thumbnails` parameter should not contain an empty dictionary!"
67
62
  )
68
- max_size_thumb: int | None = thumbnails.get(size_name)
69
- if max_size_thumb is not None:
70
- if curr_size_thumb > 0 and max_size_thumb >= curr_size_thumb:
63
+ size_name_list = ["lg", "md", "sm", "xs"]
64
+ curr_size_thumb: int = 0
65
+ for size_name in thumbnails.keys():
66
+ if size_name not in size_name_list:
71
67
  raise AssertionError(
72
- "The `thumbnails` parameter -> "
73
- + f"The `{size_name}` key should be less than a previous size!"
74
- + 'Example: {"lg": 1200, "md": 600, "sm": 300, "xs": 150 }'
68
+ f"The `thumbnails` parameter contains an unacceptable size name `{size_name}`!\n"
69
+ + " Allowed names: lg, md, sm, xs.\n"
70
+ + " Use all sizes is not necessary.",
75
71
  )
76
- curr_size_thumb = max_size_thumb
77
- if not isinstance(label, str):
78
- raise AssertionError("Parameter `default` - Not а `str` type!")
79
- if not isinstance(disabled, bool):
80
- raise AssertionError("Parameter `disabled` - Not а `bool` type!")
81
- if not isinstance(hide, bool):
82
- raise AssertionError("Parameter `hide` - Not а `bool` type!")
83
- if not isinstance(ignored, bool):
84
- raise AssertionError("Parameter `ignored` - Not а `bool` type!")
85
- if not isinstance(ignored, bool):
86
- raise AssertionError("Parameter `ignored` - Not а `bool` type!")
87
- if not isinstance(hint, str):
88
- raise AssertionError("Parameter `hint` - Not а `str` type!")
89
- if warning is not None and not isinstance(warning, list):
90
- raise AssertionError("Parameter `warning` - Not а `list` type!")
91
- if not isinstance(placeholder, str):
92
- raise AssertionError("Parameter `placeholder` - Not а `str` type!")
93
- if not isinstance(required, bool):
94
- raise AssertionError("Parameter `required` - Not а `bool` type!")
95
- if not isinstance(max_size, int):
96
- raise AssertionError("Parameter `max_size` - Not а `int` type!")
97
- if not isinstance(target_dir, str):
98
- raise AssertionError("Parameter `target_dir` - Not а `str` type!")
99
- if not isinstance(accept, str):
100
- raise AssertionError("Parameter `accept` - Not а `str` type!")
72
+ max_size_thumb: int | None = thumbnails.get(size_name)
73
+ if max_size_thumb is not None:
74
+ if curr_size_thumb > 0 and max_size_thumb >= curr_size_thumb:
75
+ raise AssertionError(
76
+ "The `thumbnails` parameter -> "
77
+ + f"The `{size_name}` key should be less than a previous size!"
78
+ + 'Example: {"lg": 1200, "md": 600, "sm": 300, "xs": 150 }'
79
+ )
80
+ curr_size_thumb = max_size_thumb
81
+ if not isinstance(label, str):
82
+ raise AssertionError("Parameter `default` - Not а `str` type!")
83
+ if not isinstance(disabled, bool):
84
+ raise AssertionError("Parameter `disabled` - Not а `bool` type!")
85
+ if not isinstance(hide, bool):
86
+ raise AssertionError("Parameter `hide` - Not а `bool` type!")
87
+ if not isinstance(ignored, bool):
88
+ raise AssertionError("Parameter `ignored` - Not а `bool` type!")
89
+ if not isinstance(ignored, bool):
90
+ raise AssertionError("Parameter `ignored` - Not а `bool` type!")
91
+ if not isinstance(hint, str):
92
+ raise AssertionError("Parameter `hint` - Not а `str` type!")
93
+ if warning is not None and not isinstance(warning, list):
94
+ raise AssertionError("Parameter `warning` - Not а `list` type!")
95
+ if not isinstance(placeholder, str):
96
+ raise AssertionError("Parameter `placeholder` - Not а `str` type!")
97
+ if not isinstance(required, bool):
98
+ raise AssertionError("Parameter `required` - Not а `bool` type!")
99
+ if not isinstance(max_size, int):
100
+ raise AssertionError("Parameter `max_size` - Not а `int` type!")
101
+ if not isinstance(target_dir, str):
102
+ raise AssertionError("Parameter `target_dir` - Not а `str` type!")
103
+ if not isinstance(accept, str):
104
+ raise AssertionError("Parameter `accept` - Not а `str` type!")
105
+ except AssertionError as err:
106
+ logger.error(str(err))
107
+ raise err
101
108
 
102
109
  Field.__init__(
103
110
  self,
@@ -132,7 +139,7 @@ class ImageField(Field, FileGroup, JsonMixin):
132
139
  filename: str | None = None,
133
140
  is_delete: bool = False,
134
141
  ) -> None:
135
- """Convert base64 to a image,
142
+ """Ramifice - Convert base64 to a image,
136
143
  get image information and save in the target directory.
137
144
  """ # noqa: D205
138
145
  base64_str = base64_str or None
@@ -145,7 +152,9 @@ class ImageField(Field, FileGroup, JsonMixin):
145
152
  # Get file extension.
146
153
  extension = Path(filename).suffix
147
154
  if len(extension) == 0:
148
- raise FileHasNoExtensionError(f"The image `{filename}` has no extension.")
155
+ msg = f"The image `{filename}` has no extension."
156
+ logger.error(msg)
157
+ raise FileHasNoExtensionError(msg)
149
158
  # Prepare Base64 content.
150
159
  for item in enumerate(base64_str):
151
160
  if item[1] == ",":
@@ -199,7 +208,7 @@ class ImageField(Field, FileGroup, JsonMixin):
199
208
  src_path: str | None = None,
200
209
  is_delete: bool = False,
201
210
  ) -> None:
202
- """Get image information and copy the image to the target directory."""
211
+ """Ramifice - Get image information and copy the image to the target directory."""
203
212
  src_path = src_path or None
204
213
  img_info: dict[str, str | int | bool] = {"save_as_is": False}
205
214
  img_info["is_new_img"] = True
@@ -210,6 +219,7 @@ class ImageField(Field, FileGroup, JsonMixin):
210
219
  extension = Path(src_path).suffix
211
220
  if len(extension) == 0:
212
221
  msg = f"The image `{src_path}` has no extension."
222
+ logger.error(msg)
213
223
  raise FileHasNoExtensionError(msg)
214
224
  # Create the current date for the directory name.
215
225
  date_str: str = str(date.today())