GeneralManager 0.5.1__tar.gz → 0.5.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.
- {generalmanager-0.5.1 → generalmanager-0.5.2}/GeneralManager.egg-info/PKG-INFO +42 -42
- {generalmanager-0.5.1 → generalmanager-0.5.2}/GeneralManager.egg-info/SOURCES.txt +1 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/PKG-INFO +42 -42
- generalmanager-0.5.2/README.md +142 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/pyproject.toml +1 -1
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/interface/baseInterface.py +17 -4
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/interface/databaseInterface.py +8 -8
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/manager/groupManager.py +7 -4
- generalmanager-0.5.2/tests/test_baseInterface.py +604 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/tests/test_groupManager.py +4 -1
- generalmanager-0.5.1/README.md +0 -142
- {generalmanager-0.5.1 → generalmanager-0.5.2}/GeneralManager.egg-info/dependency_links.txt +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/GeneralManager.egg-info/requires.txt +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/GeneralManager.egg-info/top_level.txt +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/LICENSE +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/setup.cfg +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/__init__.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/api/graphql.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/api/mutation.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/api/property.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/apps.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/auxiliary/__init__.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/auxiliary/argsToKwargs.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/auxiliary/filterParser.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/auxiliary/jsonEncoder.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/auxiliary/makeCacheKey.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/auxiliary/noneToZero.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/auxiliary/pathMapping.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/cache/cacheDecorator.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/cache/cacheTracker.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/cache/dependencyIndex.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/cache/modelDependencyCollector.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/cache/signals.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/factory/__init__.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/factory/autoFactory.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/factory/factories.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/factory/factoryMethods.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/interface/__init__.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/interface/calculationInterface.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/manager/__init__.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/manager/generalManager.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/manager/input.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/manager/meta.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/measurement/__init__.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/measurement/measurement.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/measurement/measurementField.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/permission/__init__.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/permission/basePermission.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/permission/fileBasedPermission.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/permission/managerBasedPermission.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/permission/permissionChecks.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/permission/permissionDataManager.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/rule/__init__.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/rule/handler.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/rule/rule.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/tests/test_argsToKwargs.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/tests/test_autoFactory.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/tests/test_basePermission.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/tests/test_cacheDecorator.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/tests/test_cacheTracker.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/tests/test_dependencyIndex.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/tests/test_factories.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/tests/test_factoryMethods.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/tests/test_filterParser.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/tests/test_generalManager.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/tests/test_generalManagerMeta.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/tests/test_graph_ql.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/tests/test_input.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/tests/test_jsonEncoder.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/tests/test_makeCacheKey.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/tests/test_managerBasedPermission.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/tests/test_measurement.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/tests/test_measurement_field.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/tests/test_modelDependencyCollector.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/tests/test_noneToZero.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/tests/test_rule_handler.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/tests/test_rules.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/tests/test_settings.py +0 -0
- {generalmanager-0.5.1 → generalmanager-0.5.2}/tests/test_signals.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: GeneralManager
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.2
|
4
4
|
Summary: Kurzbeschreibung deines Pakets
|
5
5
|
Author-email: Tim Kleindick <tkleindick@yahoo.de>
|
6
6
|
License-Expression: MIT
|
@@ -37,51 +37,51 @@ Dynamic: license-file
|
|
37
37
|
|
38
38
|
# GeneralManager
|
39
39
|
|
40
|
-
##
|
40
|
+
## Overview
|
41
41
|
|
42
|
-
|
42
|
+
GeneralManager is a powerful and flexible framework designed for managing and processing data. It provides a modular structure that enables developers to implement complex business logic efficiently. The module is written entirely in Python and uses Django as the backend framework.
|
43
43
|
|
44
|
-
##
|
44
|
+
## Key Features
|
45
45
|
|
46
|
-
### 1. **
|
47
|
-
- **
|
48
|
-
- **
|
49
|
-
- **
|
46
|
+
### 1. **Data Management**
|
47
|
+
- **Flexibility**: Supports managing all kinds of data, not just projects and derivatives.
|
48
|
+
- **Database Integration**: Seamless integration with the Django ORM for database operations.
|
49
|
+
- **External Interfaces**: Support for interfaces to other programs, such as Excel.
|
50
50
|
|
51
|
-
### 2. **
|
52
|
-
- **Django
|
53
|
-
- **
|
51
|
+
### 2. **Data Modeling**
|
52
|
+
- **Django Models**: The data structure is based on Django models, extended by custom fields like `MeasurementField`.
|
53
|
+
- **Rules and Validations**: Define rules for data validation, e.g., ensuring that a project's start date is before its end date.
|
54
54
|
|
55
|
-
### 3. **GraphQL
|
56
|
-
-
|
57
|
-
-
|
55
|
+
### 3. **GraphQL Integration**
|
56
|
+
- Automatic generation of GraphQL interfaces for all models.
|
57
|
+
- Support for custom queries and mutations.
|
58
58
|
|
59
|
-
### 4. **
|
60
|
-
- **ManagerBasedPermission**:
|
61
|
-
-
|
59
|
+
### 4. **Permission System**
|
60
|
+
- **ManagerBasedPermission**: A flexible permission system based on user roles and attributes.
|
61
|
+
- Attribute-level CRUD permissions.
|
62
62
|
|
63
63
|
### 5. **Interfaces**
|
64
|
-
- **CalculationInterface**:
|
65
|
-
- **DatabaseInterface**:
|
66
|
-
- **ReadOnlyInterface**:
|
64
|
+
- **CalculationInterface**: Allows the implementation of calculation logic.
|
65
|
+
- **DatabaseInterface**: Provides a standardized interface for database operations.
|
66
|
+
- **ReadOnlyInterface**: For read-only data access.
|
67
67
|
|
68
|
-
### 6. **
|
69
|
-
- **
|
70
|
-
- **
|
68
|
+
### 6. **Data Distribution and Calculations**
|
69
|
+
- **Volume Distribution**: Automatically calculates and distributes volume over multiple years.
|
70
|
+
- **Commercial Calculations**: Calculates total volume, shipping costs, and revenue for projects.
|
71
71
|
|
72
|
-
##
|
72
|
+
## Usage
|
73
73
|
|
74
74
|
### Installation
|
75
75
|
|
76
|
-
|
76
|
+
Install the module via `pip`:
|
77
77
|
|
78
78
|
```bash
|
79
79
|
pip install GeneralManager
|
80
80
|
```
|
81
81
|
|
82
|
-
###
|
82
|
+
### Example Code
|
83
83
|
|
84
|
-
|
84
|
+
The following example demonstrates how to create a GeneralManager and generate sample data (in this case 10 projects):
|
85
85
|
|
86
86
|
```python
|
87
87
|
from general_manager import GeneralManager
|
@@ -134,11 +134,11 @@ class Project(GeneralManager):
|
|
134
134
|
Project.Factory.createBatch(10)
|
135
135
|
```
|
136
136
|
|
137
|
-
### GraphQL
|
137
|
+
### GraphQL Integration
|
138
138
|
|
139
|
-
|
139
|
+
The module automatically generates GraphQL endpoints for all models. You can run queries and mutations through the GraphQL URL defined in your Django settings.
|
140
140
|
|
141
|
-
|
141
|
+
Example of a GraphQL query:
|
142
142
|
|
143
143
|
```graphql
|
144
144
|
query {
|
@@ -154,26 +154,26 @@ query {
|
|
154
154
|
}
|
155
155
|
```
|
156
156
|
|
157
|
-
##
|
157
|
+
## Benefits
|
158
158
|
|
159
|
-
- **
|
160
|
-
- **
|
161
|
-
- **Integration**:
|
162
|
-
- **
|
163
|
-
- **
|
164
|
-
- **Caching**:
|
159
|
+
- **Modularity**: Easy to extend and adapt.
|
160
|
+
- **Flexibility**: Supports complex business logic and calculations.
|
161
|
+
- **Integration**: Seamless integration with Django and GraphQL.
|
162
|
+
- **Permissions**: Fine-grained permissions for users and attributes.
|
163
|
+
- **Data Validation**: Automatic validation of data through rules and constraints.
|
164
|
+
- **Caching**: Automatic cache generation with the `@cached` decorator to improve performance.
|
165
165
|
|
166
|
-
##
|
166
|
+
## Requirements
|
167
167
|
|
168
168
|
- Python >= 3.12
|
169
169
|
- Django >= 5.2
|
170
|
-
-
|
170
|
+
- Additional dependencies (see `requirements.txt`):
|
171
171
|
- `graphene`
|
172
172
|
- `numpy`
|
173
173
|
- `Pint`
|
174
174
|
- `factory_boy`
|
175
|
-
-
|
175
|
+
- and more.
|
176
176
|
|
177
|
-
##
|
177
|
+
## License
|
178
178
|
|
179
|
-
|
179
|
+
This project is distributed under the **Non-Commercial MIT License**. It may only be used for non-commercial purposes. For further details see the [LICENSE](./LICENSE) file.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: GeneralManager
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.2
|
4
4
|
Summary: Kurzbeschreibung deines Pakets
|
5
5
|
Author-email: Tim Kleindick <tkleindick@yahoo.de>
|
6
6
|
License-Expression: MIT
|
@@ -37,51 +37,51 @@ Dynamic: license-file
|
|
37
37
|
|
38
38
|
# GeneralManager
|
39
39
|
|
40
|
-
##
|
40
|
+
## Overview
|
41
41
|
|
42
|
-
|
42
|
+
GeneralManager is a powerful and flexible framework designed for managing and processing data. It provides a modular structure that enables developers to implement complex business logic efficiently. The module is written entirely in Python and uses Django as the backend framework.
|
43
43
|
|
44
|
-
##
|
44
|
+
## Key Features
|
45
45
|
|
46
|
-
### 1. **
|
47
|
-
- **
|
48
|
-
- **
|
49
|
-
- **
|
46
|
+
### 1. **Data Management**
|
47
|
+
- **Flexibility**: Supports managing all kinds of data, not just projects and derivatives.
|
48
|
+
- **Database Integration**: Seamless integration with the Django ORM for database operations.
|
49
|
+
- **External Interfaces**: Support for interfaces to other programs, such as Excel.
|
50
50
|
|
51
|
-
### 2. **
|
52
|
-
- **Django
|
53
|
-
- **
|
51
|
+
### 2. **Data Modeling**
|
52
|
+
- **Django Models**: The data structure is based on Django models, extended by custom fields like `MeasurementField`.
|
53
|
+
- **Rules and Validations**: Define rules for data validation, e.g., ensuring that a project's start date is before its end date.
|
54
54
|
|
55
|
-
### 3. **GraphQL
|
56
|
-
-
|
57
|
-
-
|
55
|
+
### 3. **GraphQL Integration**
|
56
|
+
- Automatic generation of GraphQL interfaces for all models.
|
57
|
+
- Support for custom queries and mutations.
|
58
58
|
|
59
|
-
### 4. **
|
60
|
-
- **ManagerBasedPermission**:
|
61
|
-
-
|
59
|
+
### 4. **Permission System**
|
60
|
+
- **ManagerBasedPermission**: A flexible permission system based on user roles and attributes.
|
61
|
+
- Attribute-level CRUD permissions.
|
62
62
|
|
63
63
|
### 5. **Interfaces**
|
64
|
-
- **CalculationInterface**:
|
65
|
-
- **DatabaseInterface**:
|
66
|
-
- **ReadOnlyInterface**:
|
64
|
+
- **CalculationInterface**: Allows the implementation of calculation logic.
|
65
|
+
- **DatabaseInterface**: Provides a standardized interface for database operations.
|
66
|
+
- **ReadOnlyInterface**: For read-only data access.
|
67
67
|
|
68
|
-
### 6. **
|
69
|
-
- **
|
70
|
-
- **
|
68
|
+
### 6. **Data Distribution and Calculations**
|
69
|
+
- **Volume Distribution**: Automatically calculates and distributes volume over multiple years.
|
70
|
+
- **Commercial Calculations**: Calculates total volume, shipping costs, and revenue for projects.
|
71
71
|
|
72
|
-
##
|
72
|
+
## Usage
|
73
73
|
|
74
74
|
### Installation
|
75
75
|
|
76
|
-
|
76
|
+
Install the module via `pip`:
|
77
77
|
|
78
78
|
```bash
|
79
79
|
pip install GeneralManager
|
80
80
|
```
|
81
81
|
|
82
|
-
###
|
82
|
+
### Example Code
|
83
83
|
|
84
|
-
|
84
|
+
The following example demonstrates how to create a GeneralManager and generate sample data (in this case 10 projects):
|
85
85
|
|
86
86
|
```python
|
87
87
|
from general_manager import GeneralManager
|
@@ -134,11 +134,11 @@ class Project(GeneralManager):
|
|
134
134
|
Project.Factory.createBatch(10)
|
135
135
|
```
|
136
136
|
|
137
|
-
### GraphQL
|
137
|
+
### GraphQL Integration
|
138
138
|
|
139
|
-
|
139
|
+
The module automatically generates GraphQL endpoints for all models. You can run queries and mutations through the GraphQL URL defined in your Django settings.
|
140
140
|
|
141
|
-
|
141
|
+
Example of a GraphQL query:
|
142
142
|
|
143
143
|
```graphql
|
144
144
|
query {
|
@@ -154,26 +154,26 @@ query {
|
|
154
154
|
}
|
155
155
|
```
|
156
156
|
|
157
|
-
##
|
157
|
+
## Benefits
|
158
158
|
|
159
|
-
- **
|
160
|
-
- **
|
161
|
-
- **Integration**:
|
162
|
-
- **
|
163
|
-
- **
|
164
|
-
- **Caching**:
|
159
|
+
- **Modularity**: Easy to extend and adapt.
|
160
|
+
- **Flexibility**: Supports complex business logic and calculations.
|
161
|
+
- **Integration**: Seamless integration with Django and GraphQL.
|
162
|
+
- **Permissions**: Fine-grained permissions for users and attributes.
|
163
|
+
- **Data Validation**: Automatic validation of data through rules and constraints.
|
164
|
+
- **Caching**: Automatic cache generation with the `@cached` decorator to improve performance.
|
165
165
|
|
166
|
-
##
|
166
|
+
## Requirements
|
167
167
|
|
168
168
|
- Python >= 3.12
|
169
169
|
- Django >= 5.2
|
170
|
-
-
|
170
|
+
- Additional dependencies (see `requirements.txt`):
|
171
171
|
- `graphene`
|
172
172
|
- `numpy`
|
173
173
|
- `Pint`
|
174
174
|
- `factory_boy`
|
175
|
-
-
|
175
|
+
- and more.
|
176
176
|
|
177
|
-
##
|
177
|
+
## License
|
178
178
|
|
179
|
-
|
179
|
+
This project is distributed under the **Non-Commercial MIT License**. It may only be used for non-commercial purposes. For further details see the [LICENSE](./LICENSE) file.
|
@@ -0,0 +1,142 @@
|
|
1
|
+
# GeneralManager
|
2
|
+
|
3
|
+
## Overview
|
4
|
+
|
5
|
+
GeneralManager is a powerful and flexible framework designed for managing and processing data. It provides a modular structure that enables developers to implement complex business logic efficiently. The module is written entirely in Python and uses Django as the backend framework.
|
6
|
+
|
7
|
+
## Key Features
|
8
|
+
|
9
|
+
### 1. **Data Management**
|
10
|
+
- **Flexibility**: Supports managing all kinds of data, not just projects and derivatives.
|
11
|
+
- **Database Integration**: Seamless integration with the Django ORM for database operations.
|
12
|
+
- **External Interfaces**: Support for interfaces to other programs, such as Excel.
|
13
|
+
|
14
|
+
### 2. **Data Modeling**
|
15
|
+
- **Django Models**: The data structure is based on Django models, extended by custom fields like `MeasurementField`.
|
16
|
+
- **Rules and Validations**: Define rules for data validation, e.g., ensuring that a project's start date is before its end date.
|
17
|
+
|
18
|
+
### 3. **GraphQL Integration**
|
19
|
+
- Automatic generation of GraphQL interfaces for all models.
|
20
|
+
- Support for custom queries and mutations.
|
21
|
+
|
22
|
+
### 4. **Permission System**
|
23
|
+
- **ManagerBasedPermission**: A flexible permission system based on user roles and attributes.
|
24
|
+
- Attribute-level CRUD permissions.
|
25
|
+
|
26
|
+
### 5. **Interfaces**
|
27
|
+
- **CalculationInterface**: Allows the implementation of calculation logic.
|
28
|
+
- **DatabaseInterface**: Provides a standardized interface for database operations.
|
29
|
+
- **ReadOnlyInterface**: For read-only data access.
|
30
|
+
|
31
|
+
### 6. **Data Distribution and Calculations**
|
32
|
+
- **Volume Distribution**: Automatically calculates and distributes volume over multiple years.
|
33
|
+
- **Commercial Calculations**: Calculates total volume, shipping costs, and revenue for projects.
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
|
37
|
+
### Installation
|
38
|
+
|
39
|
+
Install the module via `pip`:
|
40
|
+
|
41
|
+
```bash
|
42
|
+
pip install GeneralManager
|
43
|
+
```
|
44
|
+
|
45
|
+
### Example Code
|
46
|
+
|
47
|
+
The following example demonstrates how to create a GeneralManager and generate sample data (in this case 10 projects):
|
48
|
+
|
49
|
+
```python
|
50
|
+
from general_manager import GeneralManager
|
51
|
+
from general_manager.interface.database import DatabaseInterface
|
52
|
+
from general_manager.measurement import MeasurementField, Measurement
|
53
|
+
from general_manager.permission import ManagerBasedPermission
|
54
|
+
|
55
|
+
class Project(GeneralManager):
|
56
|
+
name: str
|
57
|
+
start_date: Optional[date]
|
58
|
+
end_date: Optional[date]
|
59
|
+
total_capex: Optional[Measurement]
|
60
|
+
derivative_list: DatabaseBucket[Derivative]
|
61
|
+
|
62
|
+
class Interface(DatabaseInterface):
|
63
|
+
name = CharField(max_length=50)
|
64
|
+
number = CharField(max_length=7, validators=[RegexValidator(r"^AP\d{4,5}$")])
|
65
|
+
description = TextField(null=True, blank=True)
|
66
|
+
start_date = DateField(null=True, blank=True)
|
67
|
+
end_date = DateField(null=True, blank=True)
|
68
|
+
total_capex = MeasurementField(base_unit="EUR", null=True, blank=True)
|
69
|
+
|
70
|
+
class Meta:
|
71
|
+
constraints = [
|
72
|
+
constraints.UniqueConstraint(
|
73
|
+
fields=["name", "number"], name="unique_booking"
|
74
|
+
)
|
75
|
+
]
|
76
|
+
|
77
|
+
rules = [
|
78
|
+
Rule["Project"](
|
79
|
+
lambda x: cast(date, x.start_date) < cast(date, x.end_date)
|
80
|
+
),
|
81
|
+
Rule["Project"](lambda x: cast(Measurement, x.total_capex) >= "0 EUR"),
|
82
|
+
]
|
83
|
+
|
84
|
+
class Factory:
|
85
|
+
name = LazyProjectName()
|
86
|
+
end_date = LazyDeltaDate(365 * 6, "start_date")
|
87
|
+
total_capex = LazyMeasurement(75_000, 1_000_000, "EUR")
|
88
|
+
|
89
|
+
class Permission(ManagerBasedPermission):
|
90
|
+
__read__ = ["ends_with:name:X-771", "public"]
|
91
|
+
__create__ = ["admin", "isMatchingKeyAccount"]
|
92
|
+
__update__ = ["admin", "isMatchingKeyAccount", "isProjectTeamMember"]
|
93
|
+
__delete__ = ["admin", "isMatchingKeyAccount", "isProjectTeamMember"]
|
94
|
+
|
95
|
+
total_capex = {"update": ["isSalesResponsible", "isProjectManager"]}
|
96
|
+
|
97
|
+
Project.Factory.createBatch(10)
|
98
|
+
```
|
99
|
+
|
100
|
+
### GraphQL Integration
|
101
|
+
|
102
|
+
The module automatically generates GraphQL endpoints for all models. You can run queries and mutations through the GraphQL URL defined in your Django settings.
|
103
|
+
|
104
|
+
Example of a GraphQL query:
|
105
|
+
|
106
|
+
```graphql
|
107
|
+
query {
|
108
|
+
projectList {
|
109
|
+
name
|
110
|
+
startDate
|
111
|
+
endDate
|
112
|
+
totalCapex {
|
113
|
+
value
|
114
|
+
unit
|
115
|
+
}
|
116
|
+
}
|
117
|
+
}
|
118
|
+
```
|
119
|
+
|
120
|
+
## Benefits
|
121
|
+
|
122
|
+
- **Modularity**: Easy to extend and adapt.
|
123
|
+
- **Flexibility**: Supports complex business logic and calculations.
|
124
|
+
- **Integration**: Seamless integration with Django and GraphQL.
|
125
|
+
- **Permissions**: Fine-grained permissions for users and attributes.
|
126
|
+
- **Data Validation**: Automatic validation of data through rules and constraints.
|
127
|
+
- **Caching**: Automatic cache generation with the `@cached` decorator to improve performance.
|
128
|
+
|
129
|
+
## Requirements
|
130
|
+
|
131
|
+
- Python >= 3.12
|
132
|
+
- Django >= 5.2
|
133
|
+
- Additional dependencies (see `requirements.txt`):
|
134
|
+
- `graphene`
|
135
|
+
- `numpy`
|
136
|
+
- `Pint`
|
137
|
+
- `factory_boy`
|
138
|
+
- and more.
|
139
|
+
|
140
|
+
## License
|
141
|
+
|
142
|
+
This project is distributed under the **Non-Commercial MIT License**. It may only be used for non-commercial purposes. For further details see the [LICENSE](./LICENSE) file.
|
{generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/interface/baseInterface.py
RENAMED
@@ -70,9 +70,17 @@ class InterfaceBase(ABC):
|
|
70
70
|
*args: Any,
|
71
71
|
**kwargs: dict[str, Any],
|
72
72
|
) -> dict[str, Any]:
|
73
|
+
"""
|
74
|
+
Parses and validates input arguments into a structured identification dictionary.
|
75
|
+
|
76
|
+
Converts positional and keyword arguments into a dictionary keyed by input field names, handling normalization of argument names and checking for unexpected or missing arguments. Processes input fields in dependency order, casting and validating each value. Raises a `TypeError` for unexpected or missing arguments and a `ValueError` if circular dependencies among input fields are detected.
|
77
|
+
|
78
|
+
Returns:
|
79
|
+
A dictionary mapping input field names to their validated and cast values.
|
80
|
+
"""
|
73
81
|
identification = {}
|
74
82
|
kwargs = args_to_kwargs(args, self.input_fields.keys(), kwargs)
|
75
|
-
#
|
83
|
+
# Check for extra arguments
|
76
84
|
extra_args = set(kwargs.keys()) - set(self.input_fields.keys())
|
77
85
|
if extra_args:
|
78
86
|
for extra_arg in extra_args:
|
@@ -85,7 +93,7 @@ class InterfaceBase(ABC):
|
|
85
93
|
if missing_args:
|
86
94
|
raise TypeError(f"Missing required arguments: {', '.join(missing_args)}")
|
87
95
|
|
88
|
-
#
|
96
|
+
# process input fields with dependencies
|
89
97
|
processed = set()
|
90
98
|
while len(processed) < len(self.input_fields):
|
91
99
|
progress_made = False
|
@@ -100,7 +108,7 @@ class InterfaceBase(ABC):
|
|
100
108
|
processed.add(name)
|
101
109
|
progress_made = True
|
102
110
|
if not progress_made:
|
103
|
-
#
|
111
|
+
# detect circular dependencies
|
104
112
|
unresolved = set(self.input_fields.keys()) - processed
|
105
113
|
raise ValueError(
|
106
114
|
f"Circular dependency detected among inputs: {', '.join(unresolved)}"
|
@@ -123,13 +131,18 @@ class InterfaceBase(ABC):
|
|
123
131
|
def _process_input(
|
124
132
|
self, name: str, value: Any, identification: dict[str, Any]
|
125
133
|
) -> None:
|
134
|
+
"""
|
135
|
+
Validates the type and allowed values of an input field.
|
136
|
+
|
137
|
+
Checks that the provided value matches the expected type for the input field and, in debug mode, verifies that the value is among the allowed possible values if specified. Raises a TypeError for invalid types or possible value definitions, and a ValueError if the value is not permitted.
|
138
|
+
"""
|
126
139
|
input_field = self.input_fields[name]
|
127
140
|
if not isinstance(value, input_field.type):
|
128
141
|
raise TypeError(
|
129
142
|
f"Invalid type for {name}: {type(value)}, expected: {input_field.type}"
|
130
143
|
)
|
131
144
|
if settings.DEBUG:
|
132
|
-
#
|
145
|
+
# `possible_values` can be a callable or an iterable
|
133
146
|
possible_values = input_field.possible_values
|
134
147
|
if possible_values is not None:
|
135
148
|
if callable(possible_values):
|
{generalmanager-0.5.1 → generalmanager-0.5.2}/src/general_manager/interface/databaseInterface.py
RENAMED
@@ -8,7 +8,6 @@ from typing import (
|
|
8
8
|
TYPE_CHECKING,
|
9
9
|
Generator,
|
10
10
|
TypeVar,
|
11
|
-
cast,
|
12
11
|
)
|
13
12
|
from django.db import models, transaction
|
14
13
|
from django.contrib.auth import get_user_model
|
@@ -646,13 +645,14 @@ class DatabaseBucket(Bucket[GeneralManagerType]):
|
|
646
645
|
self, basis: dict[str, list[Any]], **kwargs: Any
|
647
646
|
) -> dict[str, list[Any]]:
|
648
647
|
"""
|
649
|
-
|
648
|
+
Merges filter definitions by appending values from keyword arguments to the corresponding lists in the basis dictionary.
|
650
649
|
|
651
650
|
Args:
|
652
|
-
basis:
|
651
|
+
basis: A dictionary mapping filter keys to lists of values. Existing filter criteria.
|
652
|
+
**kwargs: Additional filter criteria to be merged, where each value is appended to the corresponding key's list.
|
653
653
|
|
654
654
|
Returns:
|
655
|
-
A dictionary
|
655
|
+
A dictionary with keys mapping to lists containing all values from both the original basis and the new keyword arguments.
|
656
656
|
"""
|
657
657
|
kwarg_filter: dict[str, list[Any]] = {}
|
658
658
|
for key, value in basis.items():
|
@@ -665,9 +665,9 @@ class DatabaseBucket(Bucket[GeneralManagerType]):
|
|
665
665
|
|
666
666
|
def filter(self, **kwargs: Any) -> DatabaseBucket[GeneralManagerType]:
|
667
667
|
"""
|
668
|
-
Returns a new bucket
|
668
|
+
Returns a new bucket containing manager instances matching the given filter criteria.
|
669
669
|
|
670
|
-
Additional filter keyword arguments are merged with
|
670
|
+
Additional filter keyword arguments are merged with existing filters to further restrict the queryset.
|
671
671
|
"""
|
672
672
|
merged_filter = self.__mergeFilterDefinitions(self.filters, **kwargs)
|
673
673
|
return self.__class__(
|
@@ -679,9 +679,9 @@ class DatabaseBucket(Bucket[GeneralManagerType]):
|
|
679
679
|
|
680
680
|
def exclude(self, **kwargs: Any) -> DatabaseBucket[GeneralManagerType]:
|
681
681
|
"""
|
682
|
-
Returns a new DatabaseBucket excluding items
|
682
|
+
Returns a new DatabaseBucket excluding items matching the given criteria.
|
683
683
|
|
684
|
-
Keyword arguments
|
684
|
+
Keyword arguments define field lookups to exclude from the queryset. The returned bucket contains only items that do not match these filters.
|
685
685
|
"""
|
686
686
|
merged_exclude = self.__mergeFilterDefinitions(self.excludes, **kwargs)
|
687
687
|
return self.__class__(
|
@@ -43,16 +43,19 @@ class GroupBucket(Bucket[GeneralManagerType]):
|
|
43
43
|
|
44
44
|
def __checkGroupByArguments(self, group_by_keys: tuple[str, ...]) -> None:
|
45
45
|
"""
|
46
|
-
|
47
|
-
|
46
|
+
Validates that all group-by keys are strings and valid attributes of the manager class.
|
47
|
+
|
48
|
+
Raises:
|
49
|
+
TypeError: If any group-by key is not a string.
|
50
|
+
ValueError: If any group-by key is not a valid attribute of the manager class.
|
48
51
|
"""
|
49
52
|
if not all(isinstance(arg, str) for arg in group_by_keys):
|
50
53
|
raise TypeError("groupBy() argument must be a string")
|
51
54
|
if not all(
|
52
|
-
arg in self._manager_class.Interface.getAttributes()
|
55
|
+
arg in self._manager_class.Interface.getAttributes()
|
53
56
|
for arg in group_by_keys
|
54
57
|
):
|
55
|
-
raise
|
58
|
+
raise ValueError(
|
56
59
|
f"groupBy() argument must be a valid attribute of {self._manager_class.__name__}"
|
57
60
|
)
|
58
61
|
|