Skip to content
Snippets Groups Projects
Commit 6ec2cfec authored by Jörn Künsemöller's avatar Jörn Künsemöller
Browse files

TMSS-332: Add directory, archive_location, archive_subdirectory to filesystem and project models

parent f741270f
No related branches found
No related tags found
1 merge request!208Resolve TMSS-332 and TMSS-333
# Generated by Django 3.0.9 on 2020-08-19 13:24
# Generated by Django 3.0.8 on 2020-09-02 16:52
from django.conf import settings
import django.contrib.postgres.fields
......@@ -288,6 +288,7 @@ class Migration(migrations.Migration):
('name', models.CharField(help_text='Human-readable name of this object.', max_length=128)),
('description', models.CharField(help_text='A longer description of this object.', max_length=255)),
('capacity', models.BigIntegerField(help_text='Capacity in bytes')),
('directory', models.CharField(help_text='Root directory under which we are allowed to write our data.', max_length=1024)),
],
options={
'abstract': False,
......@@ -342,6 +343,7 @@ class Migration(migrations.Migration):
('private_data', models.BooleanField(default=True, help_text='True if data of this project is sensitive. Sensitive data is not made public.')),
('expert', models.BooleanField(default=False, help_text='Expert projects put more responsibility on the PI.')),
('filler', models.BooleanField(default=False, help_text='Use this project to fill up idle telescope time.')),
('archive_subdirectory', models.CharField(help_text='Subdirectory in which this project will store its data in the LTA. The full directory is constructed by prefixing with archive_location→directory.', max_length=1024)),
],
options={
'abstract': False,
......@@ -1044,6 +1046,11 @@ class Migration(migrations.Migration):
name='resource_type',
field=models.ForeignKey(help_text='Resource type.', on_delete=django.db.models.deletion.PROTECT, to='tmssapp.ResourceType'),
),
migrations.AddField(
model_name='project',
name='archive_location',
field=models.ForeignKey(help_text='Ingest data to this LTA cluster only (NULLable). NULL means: no preference.', null=True, on_delete=django.db.models.deletion.PROTECT, to='tmssapp.Filesystem'),
),
migrations.AddField(
model_name='project',
name='cycles',
......
......@@ -308,6 +308,13 @@ class DataproductTransform(BasicCommon):
class Filesystem(NamedCommon):
capacity = BigIntegerField(help_text='Capacity in bytes')
cluster = ForeignKey('Cluster', on_delete=PROTECT, help_text='Cluster hosting this filesystem.')
directory = CharField(max_length=1024, help_text='Root directory under which we are allowed to write our data.')
def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
if self.directory and not self.directory.endswith('/'):
raise ValueError('directory value must end with a trailing slash!') # todo: ...and needs to start with slash?
super().save(force_insert, force_update, using, update_fields)
class Cluster(NamedCommon):
......
......@@ -323,6 +323,16 @@ class Project(NamedCommonPK):
filler = BooleanField(default=False, help_text='Use this project to fill up idle telescope time.')
project_category = ForeignKey('ProjectCategory', null=True, on_delete=PROTECT, help_text='Project category.')
period_category = ForeignKey('PeriodCategory', null=True, on_delete=PROTECT, help_text='Period category.')
archive_location = ForeignKey('Filesystem', null=True, on_delete=PROTECT, help_text='Ingest data to this LTA cluster only (NULLable). NULL means: no preference.')
archive_subdirectory = CharField(max_length=1024, help_text='Subdirectory in which this project will store its data in the LTA. The full directory is constructed by prefixing with archive_location→directory.')
def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
if self.archive_subdirectory and not self.archive_subdirectory.endswith('/'):
raise ValueError('directory value must end with a trailing slash!')
if self.archive_subdirectory and self.archive_subdirectory.startswith('/'):
raise ValueError('directory value must be a relative path (and not start with a slash)!')
super().save(force_insert, force_update, using, update_fields)
# JK, 29/07/20 - after discussion with Sander, it turns out that the ticket TMSS-277 was a misunderstanding.
# 'default' does not refer to 'default values' that are supposed to be filled in by the backend.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment