-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue1 gcmd short names #52
Changes from all commits
c892f8a
ff12aec
61ae0ec
b145dfa
d894b51
9ad8686
dabc835
c8c020f
3f90889
52cbc74
09dee8d
4cc45ee
ad7bd0b
b266add
d0d7eb4
ed2eb04
e38423b
eb4e9ea
ef136a7
4b97b52
8a15d6c
c88c01d
2e05634
6e853d4
b3ff98b
6208a4b
ebe676a
a83c862
ee30d85
78d0ca1
3e44f5b
7d6a45d
1401922
8fe4d11
822a589
ada572d
8be4bd2
03ada4d
37048b1
e5b22b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 2.1.5 on 2019-02-04 10:25 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('catalog', '0006_auto_20190130_1442'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='dataset', | ||
name='sources', | ||
field=models.ManyToManyField(to='catalog.Source'), | ||
), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from django.db import migrations | ||
|
||
def copy_source(apps, schema_editor): | ||
Dataset = apps.get_model('catalog', 'Dataset') | ||
for ds in Dataset.objects.all(): | ||
ds.sources.add(ds.source) | ||
|
||
def copy_source_backwards(apps, schema_editor): | ||
Dataset = apps.get_model('catalog', 'Dataset') | ||
for ds in Dataset.objects.all(): | ||
src = ds.sources.all()[0] | ||
ds.source = src | ||
ds.save() | ||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('catalog', '0007a_add_sources_field'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(copy_source, copy_source_backwards), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Generated by Django 2.1.5 on 2019-02-04 10:25 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('catalog', '0007b_migrate_source_data'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='dataset', | ||
name='source', | ||
), | ||
migrations.RemoveField( | ||
model_name='source', | ||
name='specs', | ||
), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Generated by Django 2.1.5 on 2019-02-04 18:01 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('vocabularies', '0001_initial'), | ||
('catalog', '0007c_remove_source_and_specs_fields'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='dataset', | ||
name='newparameters', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you squash these migrations? You added |
||
field=models.ManyToManyField(to='vocabularies.Parameter'), | ||
), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Generated by Django 2.1.5 on 2019-02-05 12:18 | ||
|
||
from django.db import migrations | ||
|
||
def forward(apps, schema_editor): | ||
Dataset = apps.get_model('catalog', 'Dataset') | ||
DatasetParameter = apps.get_model('catalog', 'DatasetParameter') | ||
for ds in Dataset.objects.all(): | ||
dataset_params = DatasetParameter.objects.filter(dataset=ds) | ||
for dp in dataset_params: | ||
ds.newparameters.add(dp.parameter) | ||
|
||
def backward(apps, schema_editor): | ||
Dataset = apps.get_model('catalog', 'Dataset') | ||
DatasetParameter = apps.get_model('catalog', 'DatasetParameter') | ||
for ds in Dataset.objects.all(): | ||
for pp in ds.newparameters.all(): | ||
dp, created = DatasetParameter.objects.get_or_create(dataset=ds, parameter=pp) | ||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('catalog', '0008a_add_newparameters_field'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(forward, backward), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 2.1.5 on 2019-02-04 18:01 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('vocabularies', '0001_initial'), | ||
('catalog', '0008b_migrate_parameters_data'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='dataset', | ||
name='parameters', | ||
), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 2.1.5 on 2019-02-04 18:02 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('catalog', '0008c_remove_parameters_field'), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameField( | ||
model_name='dataset', | ||
old_name='newparameters', | ||
new_name='parameters', | ||
), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,24 +32,21 @@ def __str__(self): | |
|
||
|
||
class Source(models.Model): | ||
# Consider updating to follow https://gcmd.nasa.gov/DocumentBuilder/defaultDif10/guide/platform.html | ||
platform = models.ForeignKey(Platform, on_delete=models.CASCADE) | ||
instrument = models.ForeignKey(Instrument, on_delete=models.CASCADE) | ||
specs = models.CharField(max_length=50, default='', | ||
help_text=_('Further specifications of the source.')) | ||
|
||
objects = SourceManager() | ||
|
||
class Meta: | ||
unique_together = (("platform", "instrument"),) | ||
|
||
def __str__(self): | ||
if not self.platform and not self.instrument: | ||
return '%s' % self.specs | ||
else: | ||
return '%s/%s' % (self.platform, self.instrument) | ||
return 'Platform: (%s) / Instrument: (%s)' % (self.platform.__str__(), | ||
self.instrument.__str__()) | ||
|
||
def natural_key(self): | ||
return (self.platform.short_name, self.instrument.short_name) | ||
return (self.platform.natural_key(), self.instrument.natural_key()) | ||
|
||
class Personnel(models.Model): | ||
''' | ||
|
@@ -103,8 +100,8 @@ class Dataset(models.Model): | |
In addition to some general information, the summary should also | ||
contain information about the project from/for which the data was | ||
collected/created | ||
source : ForeignKey to Source | ||
Contains information about the instrument and platform by which the | ||
sources : ManyToMany relation to Source | ||
Contains information about the instruments and platforms by which the | ||
data was collected | ||
time_coverage_start : DateTimeField | ||
time_coverage_end : DateTimeField | ||
|
@@ -131,13 +128,14 @@ class Dataset(models.Model): | |
] | ||
) | ||
entry_title = models.CharField(max_length=220) | ||
parameters = models.ManyToManyField(Parameter, through='DatasetParameter') | ||
#parameters = models.ManyToManyField(Parameter, through='DatasetParameter') | ||
parameters = models.ManyToManyField(Parameter) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also remove the model DatasetParameter if it is not used anymore? |
||
ISO_topic_category = models.ForeignKey(ISOTopicCategory, on_delete=models.CASCADE) | ||
data_center = models.ForeignKey(DataCenter, on_delete=models.CASCADE) | ||
summary = models.TextField() | ||
|
||
# DIF highly recommended fields | ||
source = models.ForeignKey(Source, blank=True, null=True, on_delete=models.CASCADE) | ||
sources = models.ManyToManyField(Source) | ||
time_coverage_start = models.DateTimeField(blank=True, null=True) | ||
time_coverage_end = models.DateTimeField(blank=True, null=True) | ||
geographic_location = models.ForeignKey(GeographicLocation, blank=True, null=True, on_delete=models.CASCADE) | ||
|
@@ -146,8 +144,7 @@ class Dataset(models.Model): | |
choices=ACCESS_CHOICES, blank=True, null=True) | ||
|
||
def __str__(self): | ||
return '%s/%s/%s' % (self.source.platform, self.source.instrument, | ||
self.time_coverage_start.isoformat()) | ||
return self.entry_title | ||
|
||
# Keep this for reference if we want to add it | ||
#class DataResolution(models.Model): | ||
|
@@ -179,7 +176,7 @@ class Meta: | |
unique_together = (('uri', 'dataset'),) | ||
|
||
def __str__(self): | ||
return '%s: %s'%(self.dataset, os.path.split(self.uri)[1]) | ||
return str(self.uri) | ||
|
||
def protocol(self): | ||
return self.uri.split(':')[0] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed. In fact it can conflict with other VMs for other projects. If not specified, vagrant allocates free IP to the VM without conflicts.