-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(histories): added WalletHistories
- Loading branch information
1 parent
4c8168a
commit a659172
Showing
35 changed files
with
682 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .history_data_point import HistoryDataPointManager |
25 changes: 25 additions & 0 deletions
25
django_napse/core/models/histories/managers/history_data_point.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from typing import TYPE_CHECKING, Optional | ||
|
||
from django.apps import apps | ||
from django.db import models | ||
|
||
if TYPE_CHECKING: | ||
from django_napse.core.models.histories.history import History, HistoryDataPoint | ||
|
||
|
||
class HistoryDataPointManager(models.Manager): | ||
"""The manager for the HistoryDataPoint model.""" | ||
|
||
def create( | ||
self, | ||
history: "History", | ||
points: Optional[dict] = None, | ||
) -> "HistoryDataPoint": | ||
"""Create a new data point for the history.""" | ||
HistoryDataPointField = apps.get_model("django_napse_core", "HistoryDataPointField") | ||
points = points or {} | ||
data_point = self.model(history=history) | ||
data_point.save() | ||
for key, value in points.items(): | ||
HistoryDataPointField.objects.create(history_data_point=data_point, key=key, value=value) | ||
return data_point |
21 changes: 21 additions & 0 deletions
21
django_napse/core/models/histories/managers/history_data_point_field.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from typing import TYPE_CHECKING | ||
|
||
from django.db import models | ||
|
||
if TYPE_CHECKING: | ||
from django_napse.core.models.histories.history import HistoryDataPoint, HistoryDataPointField | ||
|
||
|
||
class HistoryDataPointFieldManager(models.Manager): | ||
"""The manager for the HistoryDataPointField model.""" | ||
|
||
def create( | ||
self, | ||
history_data_point: "HistoryDataPoint", | ||
key: str, | ||
value: str, | ||
) -> "HistoryDataPointField": | ||
"""Create a new data point field for a data point.""" | ||
data_point_field = self.model(history_data_point=history_data_point, key=key, value=str(value), target_type=type(value).__name__) | ||
data_point_field.save() | ||
return data_point_field |
Oops, something went wrong.