Skip to content

Commit

Permalink
Merge branch 'master' of github.com:roman-dvorak/DOSPORTAL
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-dvorak committed Mar 17, 2024
2 parents d749cd7 + d357cb8 commit b0139bf
Show file tree
Hide file tree
Showing 23 changed files with 818 additions and 177 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/docker_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
on:
push:
# branches: ['release']
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: roman-dvorak/DOSPORTAL/web

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
file: Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Empty file added DOSPORTAL/detectors/__init__.py
Empty file.
53 changes: 53 additions & 0 deletions DOSPORTAL/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from django import forms
from .models import Detector, record


class DetectorLogblogForm(forms.Form):
text = forms.CharField(
widget=forms.Textarea(
attrs={
'class': 'form-control'
}
)
)



class RecordForm(forms.ModelForm):
log_file = forms.FileField(
required=False,
widget=forms.widgets.FileInput(attrs={
'class': 'form-control',
}),
label="Log file",
#widget=forms.FileInput(attrs={
# 'class': 'form-control',
#})
)

detector = forms.ModelChoiceField(
queryset=Detector.objects.all(),
widget=forms.Select(attrs={
'class': 'form-control',
}),
required=False
)

record_type = forms.ChoiceField(
choices=record.RECORD_TYPES,
widget=forms.Select(attrs={
'class': 'form-control',
})
)

time_start = forms.DateTimeField(
widget=forms.DateTimeInput(attrs={
'type': "datetime-local",
'class': 'form-control datetimepicker-input',
})
)


class Meta:
model = record
exclude = ("time_end", "measurement", "log_filename", "metadata", "duration")
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2.5 on 2023-09-25 07:29
# Generated by Django 4.2.7 on 2023-12-03 10:54

from django.db import migrations, models
import django.db.models.deletion
Expand Down
18 changes: 18 additions & 0 deletions DOSPORTAL/migrations/0031_detectorlogbook_public.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.7 on 2023-12-03 16:09

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('DOSPORTAL', '0030_alter_flight_cari_alter_measurement_flight'),
]

operations = [
migrations.AddField(
model_name='detectorlogbook',
name='public',
field=models.BooleanField(default=True),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by Django 4.2.7 on 2023-12-03 17:21

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('DOSPORTAL', '0031_detectorlogbook_public'),
]

operations = [
migrations.AddField(
model_name='detector',
name='data',
field=models.JSONField(default={}, help_text='Detector metadata, used for advanced data processing and maintaining', verbose_name='Detector data'),
preserve_default=False,
),
migrations.AlterField(
model_name='detectorlogbook',
name='public',
field=models.BooleanField(default=True, help_text='Private logbook will be visible for maintainers of detector and for dosportal admins.', verbose_name='Wish to be visible to everyone?'),
),
migrations.AlterField(
model_name='detectorlogbook',
name='text',
field=models.TextField(help_text='Detailed description of activity made on the detector.', verbose_name='Logbook text'),
),
]
18 changes: 18 additions & 0 deletions DOSPORTAL/migrations/0033_detector_manufactured_date.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.7 on 2023-12-03 17:23

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('DOSPORTAL', '0032_detector_data_alter_detectorlogbook_public_and_more'),
]

operations = [
migrations.AddField(
model_name='detector',
name='manufactured_date',
field=models.DateField(blank=True, help_text='Date when detector was manufactured', null=True, verbose_name='Manufactured date'),
),
]
23 changes: 23 additions & 0 deletions DOSPORTAL/migrations/0034_record_metadata_alter_detector_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.7 on 2023-12-03 20:03

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('DOSPORTAL', '0033_detector_manufactured_date'),
]

operations = [
migrations.AddField(
model_name='record',
name='metadata',
field=models.JSONField(help_text='record metadata, used for advanced data processing and maintaining', null=True, verbose_name='record_metadata'),
),
migrations.AlterField(
model_name='detector',
name='data',
field=models.JSONField(help_text='Detector metadata, used for advanced data processing and maintaining', verbose_name='Detector metadata'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.2.7 on 2023-12-03 21:17

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('DOSPORTAL', '0034_record_metadata_alter_detector_data'),
]

operations = [
migrations.RemoveField(
model_name='record',
name='time_end',
),
migrations.AddField(
model_name='record',
name='record_duration',
field=models.DurationField(help_text='Duration of record', null=True, verbose_name='Record duration'),
),
]
37 changes: 29 additions & 8 deletions DOSPORTAL/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,19 @@ class Detector(UUIDMixin):
related_name="detectors"
)

manufactured_date = models.DateField(
_("Manufactured date"),
help_text=_("Date when detector was manufactured"),
null=True, blank=True
)

data = models.JSONField(
_("Detector metadata"),
help_text="Detector metadata, used for advanced data processing and maintaining"
)

def __str__(self) -> str:
return "Detector {} ({})".format(self.name, self.type.manufacturer.name)
return "Detector {} ({}), SN:{}".format(self.name, self.type.manufacturer.name, self.sn)

class DetectorLogbook(UUIDMixin):

Expand All @@ -210,8 +221,13 @@ class DetectorLogbook(UUIDMixin):
created = models.DateTimeField(auto_now_add=True)

text = models.TextField(
_("Description zásahu")
_("Logbook text"),
help_text="Detailed description of activity made on the detector."
)
public = models.BooleanField(
_("Wish to be visible to everyone?"),
help_text=_("Private logbook will be visible for maintainers of detector and for dosportal admins."),
default=True)

class measurement_campaign(UUIDMixin):

Expand Down Expand Up @@ -342,9 +358,6 @@ class record(UUIDMixin):
)

def user_directory_path(instance, filename):
# return "data/user_records/{0}/{1}".format(instance.user.id, filename)
print(".....")
print(instance.measurement.author.pk)
return "data/user_records/log_{1}".format(instance.measurement.author.pk, instance.pk)

log_file = models.FileField(
Expand All @@ -361,9 +374,11 @@ def user_directory_path(instance, filename):
null=True,
)

time_end = models.DateTimeField(
verbose_name = _("Measurement beginning time"),
null=True,

record_duration = models.DurationField(
verbose_name = _("Record duration"),
help_text=_("Duration of record"),
null=True
)


Expand All @@ -380,6 +395,12 @@ def user_directory_path(instance, filename):
help_text=_("Type of log file")
)

metadata = models.JSONField(
_("record_metadata"),
help_text=_("record metadata, used for advanced data processing and maintaining"),
null=True
)

def __str__(self) -> str:
return "record ({}, {}, start {}, {})".format( get_enum_dsc(self.RECORD_TYPES, self.record_type), self.id, self.time_start, 0)

Expand Down
3 changes: 3 additions & 0 deletions DOSPORTAL/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,17 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.postgres',
'bootstrap5',
#'background_task',
'django_json_widget',
'rest_framework',
'corsheaders',
'jquery',
'import_export',
'django_select2',
'martor',
'django_tables2',

'DOSPORTAL',
'django_q',
Expand Down
Loading

0 comments on commit b0139bf

Please sign in to comment.