mirror of
https://github.com/Steffo99/sophon.git
synced 2024-12-22 06:44:21 +00:00
✨ Add DataFlow entity
This commit is contained in:
parent
7109224f2f
commit
f8e297e7f4
4 changed files with 81 additions and 0 deletions
24
sophon/core/migrations/0004_dataflow.py
Normal file
24
sophon/core/migrations/0004_dataflow.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
# Generated by Django 3.1.7 on 2021-04-06 20:55
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0003_auto_20210406_0044'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='DataFlow',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('sdmx_id', models.CharField(help_text='Internal string used in SDMX communication to identify the DataFlow.', max_length=64, verbose_name='SDMX id')),
|
||||
('last_update', models.DateTimeField(help_text='The datetime at which the properties of this DataFlow were last updated.', verbose_name='Last updated')),
|
||||
('description', models.CharField(help_text='Natural language description of the DataFlow.', max_length=8192, verbose_name='DataFlow description')),
|
||||
('datasource_id', models.ForeignKey(help_text='The DataSource this object belongs to.', on_delete=django.db.models.deletion.RESTRICT, to='core.datasource')),
|
||||
],
|
||||
),
|
||||
]
|
|
@ -35,6 +35,38 @@ class DataSource(models.Model):
|
|||
return self.pandasdmx_id
|
||||
|
||||
|
||||
class DataFlow(models.Model):
|
||||
"""
|
||||
A :class:`.DataFlow` is a object containing the metadata of a SDMX data set.
|
||||
|
||||
See `this page <https://ec.europa.eu/eurostat/online-help/redisstat-admin/en/TECH_A_main/>`_ for more details.
|
||||
"""
|
||||
|
||||
datasource_id = models.ForeignKey(
|
||||
DataSource,
|
||||
help_text="The DataSource this object belongs to.",
|
||||
on_delete=models.RESTRICT,
|
||||
)
|
||||
sdmx_id = models.CharField(
|
||||
"SDMX id",
|
||||
help_text="Internal string used in SDMX communication to identify the DataFlow.",
|
||||
max_length=64,
|
||||
)
|
||||
last_update = models.DateTimeField(
|
||||
"Last updated",
|
||||
help_text="The datetime at which the properties of this DataFlow were last updated.",
|
||||
)
|
||||
|
||||
description = models.CharField(
|
||||
"DataFlow description",
|
||||
help_text="Natural language description of the DataFlow.",
|
||||
max_length=8192,
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.datasource_id} | {self.sdmx_id} | {self.description}"
|
||||
|
||||
|
||||
class Project(models.Model):
|
||||
"""
|
||||
A research :class:`.Project` is a work which may use zero or more :class:`.DataSource`\\ s to prove or disprove an
|
||||
|
|
|
@ -16,6 +16,22 @@ class DataSourceSerializer(serializers.ModelSerializer):
|
|||
]
|
||||
|
||||
|
||||
class DataFlowSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
Serializer for :class:`.models.DataFlow` .
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
model = models.DataFlow
|
||||
fields = [
|
||||
"id",
|
||||
"datasource_id",
|
||||
"sdmx_id",
|
||||
"last_update",
|
||||
"description",
|
||||
]
|
||||
|
||||
|
||||
class ProjectSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
Serializer for :class:`.models.Project` .
|
||||
|
|
|
@ -11,6 +11,15 @@ class ProjectViewSet(viewsets.ModelViewSet):
|
|||
permission_classes = []
|
||||
|
||||
|
||||
class DataFlowViewSet(viewsets.ModelViewSet):
|
||||
"""
|
||||
Viewset for :class:`.models.DataFlow` instances.
|
||||
"""
|
||||
queryset = models.DataFlow.objects.all()
|
||||
serializer_class = serializers.DataFlowSerializer
|
||||
permission_classes = []
|
||||
|
||||
|
||||
class DataSourceViewSet(viewsets.ModelViewSet):
|
||||
"""
|
||||
Viewset for :class:`.models.DataSource` instances.
|
||||
|
|
Loading…
Reference in a new issue