-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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,7 @@ | ||
from django.contrib import admin | ||
from .models import Measurement | ||
|
||
# Register your models here. | ||
admin.site.register(Measurement) | ||
|
||
|
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,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class MeasureConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'measures' |
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,42 @@ | ||
# Generated by Django 4.2.16 on 2024-10-03 16:36 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import uuid | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
('devices', '0001_initial'), | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Measurement', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('latitude', models.FloatField()), | ||
('longitude', models.FloatField()), | ||
('altitude', models.FloatField(blank=True, null=True)), | ||
('values', models.JSONField()), | ||
('dateTime', models.DateTimeField()), | ||
('accuracy', models.FloatField(blank=True, help_text='Accuracy of the measurement', null=True)), | ||
('unit', models.CharField(blank=True, help_text='Unit of measurement (e.g., Sieverts)', max_length=20, null=True)), | ||
('notes', models.TextField(blank=True, help_text='Optional notes or comments on the measurement', null=True)), | ||
('weather', models.JSONField(blank=True, help_text='Weather conditions during the measurement (if available)', null=True)), | ||
('measurement_id', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)), | ||
('device', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='devices.device')), | ||
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)), | ||
], | ||
options={ | ||
'verbose_name': 'Measurement', | ||
'verbose_name_plural': 'Measurements', | ||
'ordering': ['-dateTime'], | ||
}, | ||
), | ||
] |
Empty file.
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,29 @@ | ||
from django.db import models | ||
from django.contrib.auth.models import User | ||
from devices.models import Device | ||
import uuid | ||
|
||
class Measurement(models.Model): | ||
""" | ||
Represents a measurement of gamma radiation performed by a device. | ||
""" | ||
device = models.ForeignKey('devices.Device', on_delete=models.CASCADE) # Link to the device used for the measurement | ||
user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True) # User who performed the measurement | ||
latitude = models.FloatField() # Latitude of the measurement | ||
longitude = models.FloatField() # Longitude of the measurement | ||
altitude = models.FloatField(blank=True, null=True) # Optional: Altitude of the measurement (if relevant) | ||
values = models.JSONField() # JSON field to store radiation measurement values | ||
dateTime = models.DateTimeField() # Time the measurement was taken | ||
accuracy = models.FloatField(blank=True, null=True, help_text="Accuracy of the measurement") # Optional: Accuracy of the measurement | ||
unit = models.CharField(max_length=20, blank=True, null=True, help_text="Unit of measurement (e.g., Sieverts)") # Optional: Unit of measurement | ||
notes = models.TextField(blank=True, null=True, help_text="Optional notes or comments on the measurement") # Optional: Additional notes | ||
weather = models.JSONField(blank=True, null=True, help_text="Weather conditions during the measurement (if available)") # Optional: Weather info | ||
measurement_id = models.UUIDField(default=uuid.uuid4, editable=False, unique=True) # Unique ID for tracking the measurement | ||
|
||
def __str__(self): | ||
return f"Measurement by {self.device} at {self.dateTime}" | ||
|
||
class Meta: | ||
verbose_name = "Measurement" | ||
verbose_name_plural = "Measurements" | ||
ordering = ['-dateTime'] |
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,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
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,3 @@ | ||
from django.shortcuts import render | ||
|
||
# Create your views here. |
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 |
---|---|---|
|
@@ -49,6 +49,7 @@ | |
|
||
# Custom apps | ||
'devices', | ||
'measures', | ||
] | ||
|
||
MIDDLEWARE = [ | ||
|