Skip to content

Commit

Permalink
rozsireni modelu pro record
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-dvorak committed Mar 29, 2024
1 parent 628b7b2 commit e3024f1
Show file tree
Hide file tree
Showing 27 changed files with 322 additions and 230 deletions.
2 changes: 1 addition & 1 deletion DOSPORTAL/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def user_count(self, obj):
admin.site.register(measurement)
admin.site.register(Organization, OrganizationAdmin)
#admin.site.register(OrganizationUser)
admin.site.register(record)
admin.site.register(Record)
admin.site.register(Detector)
admin.site.register(DetectorLogbook)
admin.site.register(DetectorType)
Expand Down
8 changes: 4 additions & 4 deletions DOSPORTAL/forms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django import forms
from .models import Detector, record, Profile, Organization
from .models import Detector, Record, Profile, Organization

from django import forms
from django.contrib.auth.models import User
Expand Down Expand Up @@ -70,7 +70,7 @@ def __init__(self,*args, user=None, **kwargs):
)

record_type = forms.ChoiceField(
choices=record.RECORD_TYPES
choices=Record.RECORD_TYPES
)

belongs = forms.ModelChoiceField(
Expand All @@ -81,8 +81,8 @@ def __init__(self,*args, user=None, **kwargs):
)

class Meta:
model = record
exclude = ("time_end", "measurement", "log_original_filename", "metadata", "duration", "time_start", "record_duration")
model = Record
exclude = ("time_end", "measurement", "log_original_filename", "metadata", "duration", "time_start", "record_duration", "author", 'data_file')


class DetectorEditForm(forms.ModelForm):
Expand Down
40 changes: 29 additions & 11 deletions DOSPORTAL/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Generated by Django 4.2.11 on 2024-03-27 09:18
# Generated by Django 4.2.11 on 2024-03-28 14:34

import DOSPORTAL.models
from django.conf import settings
import django.contrib.gis.db.models.fields
import django.contrib.postgres.fields
from django.db import migrations, models
import django.db.models.deletion
import martor.models
Expand Down Expand Up @@ -128,6 +129,26 @@ class Migration(migrations.Migration):
'abstract': False,
},
),
migrations.CreateModel(
name='Record',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)),
('log_file', models.FileField(blank=True, upload_to=DOSPORTAL.models.Record.user_directory_path, verbose_name='File log')),
('log_original_filename', models.CharField()),
('time_start', models.DateTimeField(null=True, verbose_name='Measurement beginning time')),
('record_duration', models.DurationField(help_text='Duration of record', null=True, verbose_name='Record duration')),
('record_type', models.CharField(choices=[('U', 'Unknown'), ('S', 'Spectral measurements'), ('E', 'Event measurements'), ('L', 'Location')], default='U', help_text='Type of log file', verbose_name='Certain record type, enum')),
('metadata', models.JSONField(default='[{}]', help_text='record metadata, used for advanced data processing and maintaining', verbose_name='record_metadata')),
('text', models.TextField()),
('data_policy', models.CharField(choices=[('PR', 'Private'), ('PU', 'Public'), ('NV', 'Non-public')], default='PU', max_length=2)),
('author', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
('belongs', models.ForeignKey(help_text='Organization, which owns this record', null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='records_owning', to='DOSPORTAL.organization')),
('detector', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='records', to='DOSPORTAL.detector')),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='Trajectory',
fields=[
Expand All @@ -149,18 +170,15 @@ class Migration(migrations.Migration):
],
),
migrations.CreateModel(
name='record',
name='SpectrumData',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)),
('log_file', models.FileField(blank=True, upload_to=DOSPORTAL.models.record.user_directory_path, verbose_name='File log')),
('log_original_filename', models.CharField()),
('time_start', models.DateTimeField(null=True, verbose_name='Measurement beginning time')),
('record_duration', models.DurationField(help_text='Duration of record', null=True, verbose_name='Record duration')),
('record_type', models.CharField(choices=[('U', 'Unknown'), ('S', 'Spectral measurements'), ('E', 'Event measurements'), ('L', 'Location')], default='U', help_text='Type of log file', verbose_name='Certain record type, enum')),
('metadata', models.JSONField(help_text='record metadata, used for advanced data processing and maintaining', null=True, verbose_name='record_metadata')),
('data_policy', models.CharField(choices=[('PR', 'Private'), ('PU', 'Public'), ('NV', 'Non-public')], default='PU', max_length=2)),
('belongs', models.ForeignKey(help_text='Organization, which owns this record', null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='records_owning', to='DOSPORTAL.organization')),
('detector', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='records', to='DOSPORTAL.detector')),
('spectrum', django.contrib.postgres.fields.ArrayField(base_field=models.IntegerField(), blank=True, null=True, size=None)),
('integration', models.FloatField(blank=True, help_text='Duration of last exposition', null=True, verbose_name='Integration time')),
('particles', models.IntegerField(blank=True, help_text='Particles detected in the spectrum', null=True, verbose_name='Particles')),
('time', models.DurationField(help_text='Time difference from the start of the measurement', null=True, verbose_name='Time difference')),
('location', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='spectrum_data', to='DOSPORTAL.trajectorypoint')),
('record', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='spectrum_data', to='DOSPORTAL.record', verbose_name='Record')),
],
options={
'abstract': False,
Expand Down
18 changes: 18 additions & 0 deletions DOSPORTAL/migrations/0002_rename_metadata_record_metadatar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.11 on 2024-03-28 17:22

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('DOSPORTAL', '0001_initial'),
]

operations = [
migrations.RenameField(
model_name='record',
old_name='metadata',
new_name='metadatar',
),
]
27 changes: 0 additions & 27 deletions DOSPORTAL/migrations/0002_spectrumdata.py

This file was deleted.

18 changes: 18 additions & 0 deletions DOSPORTAL/migrations/0003_rename_metadatar_record_metadata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.11 on 2024-03-28 17:22

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('DOSPORTAL', '0002_rename_metadata_record_metadatar'),
]

operations = [
migrations.RenameField(
model_name='record',
old_name='metadatar',
new_name='metadata',
),
]
19 changes: 0 additions & 19 deletions DOSPORTAL/migrations/0003_spectrumdata_spectrum.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.11 on 2024-03-29 20:32

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('DOSPORTAL', '0003_rename_metadatar_record_metadata'),
]

operations = [
migrations.AlterField(
model_name='record',
name='log_original_filename',
field=models.CharField(blank=True, max_length=150, null=True, verbose_name='Original filename of log file'),
),
migrations.AlterField(
model_name='record',
name='text',
field=models.TextField(help_text='Text log from detector', verbose_name='Text log'),
),
]

This file was deleted.

32 changes: 32 additions & 0 deletions DOSPORTAL/migrations/0005_alter_record_text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 4.2.11 on 2024-03-29 20:33

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('DOSPORTAL', '0004_alter_record_log_original_filename_alter_record_text'),
]

#operations = [
# migrations.AlterField(
# model_name='record',
# name='text',
# field=models.TextField(blank=True, help_text='Text log from detector', null=True, verbose_name='Text log'),
# ),
#]


operations = [
migrations.AddField(
model_name='record',
name='text',
field=models.TextField(blank=True, null=True),
),
migrations.AlterField(
model_name='record',
name='text',
field=models.TextField(blank=True, help_text='Text log from detector', null=True, verbose_name='Text log'),
),
]
24 changes: 0 additions & 24 deletions DOSPORTAL/migrations/0005_alter_spectrumdata_metadata_and_more.py

This file was deleted.

17 changes: 17 additions & 0 deletions DOSPORTAL/migrations/0006_remove_record_text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.11 on 2024-03-29 20:41

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('DOSPORTAL', '0005_alter_record_text'),
]

operations = [
migrations.RemoveField(
model_name='record',
name='text',
),
]

This file was deleted.

21 changes: 0 additions & 21 deletions DOSPORTAL/migrations/0007_record_author.py

This file was deleted.

18 changes: 18 additions & 0 deletions DOSPORTAL/migrations/0007_record_data_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.11 on 2024-03-29 21:04

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('DOSPORTAL', '0006_remove_record_text'),
]

operations = [
migrations.AddField(
model_name='record',
name='data_file',
field=models.FileField(blank=True, help_text='Processed spectral file', null=True, upload_to='', verbose_name='Log file'),
),
]
Loading

0 comments on commit e3024f1

Please sign in to comment.