-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: history tracking, some API shape tweaks
- Loading branch information
Showing
6 changed files
with
224 additions
and
80 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
69 changes: 69 additions & 0 deletions
69
terraso_backend/apps/soil_id/migrations/0019_soildatahistory.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,69 @@ | ||
# Copyright © 2024 Technology Matters | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published | ||
# by the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see https://www.gnu.org/licenses/. | ||
|
||
# Generated by Django 5.1.1 on 2024-10-01 20:04 | ||
|
||
import uuid | ||
|
||
import django.db.models.deletion | ||
import rules.contrib.models | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("project_management", "0029_alter_projectsettings_options"), | ||
("soil_id", "0018_alter_projectsoilsettings_options_and_more"), | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="SoilDataHistory", | ||
fields=[ | ||
("deleted_at", models.DateTimeField(db_index=True, editable=False, null=True)), | ||
("deleted_by_cascade", models.BooleanField(default=False, editable=False)), | ||
( | ||
"id", | ||
models.UUIDField( | ||
default=uuid.uuid4, editable=False, primary_key=True, serialize=False | ||
), | ||
), | ||
("created_at", models.DateTimeField(auto_now_add=True)), | ||
("updated_at", models.DateTimeField(auto_now=True)), | ||
("soil_data_changes", models.JSONField()), | ||
( | ||
"changed_by", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL | ||
), | ||
), | ||
( | ||
"site", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, to="project_management.site" | ||
), | ||
), | ||
], | ||
options={ | ||
"ordering": ["created_at"], | ||
"get_latest_by": "-created_at", | ||
"abstract": False, | ||
}, | ||
bases=(rules.contrib.models.RulesModelMixin, models.Model), | ||
), | ||
] |
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,37 @@ | ||
# Copyright © 2024 Technology Matters | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published | ||
# by the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see https://www.gnu.org/licenses/. | ||
|
||
from django.db import models | ||
|
||
from apps.core.models import User | ||
from apps.core.models.commons import BaseModel | ||
from apps.project_management.models.sites import Site | ||
|
||
|
||
class SoilDataHistory(BaseModel): | ||
site = models.ForeignKey(Site, on_delete=models.CASCADE) | ||
changed_by = models.ForeignKey(User, on_delete=models.CASCADE) | ||
|
||
# intended JSON schema: { | ||
# ...soilDataInputs, | ||
# "depth_intervals": [{ | ||
# "depth_interval": { | ||
# "start": number, | ||
# "end": number | ||
# }, | ||
# ...depthIntervalInputs, | ||
# }] | ||
# } | ||
soil_data_changes = models.JSONField() |
Oops, something went wrong.