diff --git a/tom_dataproducts/admin.py b/tom_dataproducts/admin.py index 1f78419c3..2cdcb3f87 100644 --- a/tom_dataproducts/admin.py +++ b/tom_dataproducts/admin.py @@ -1,6 +1,7 @@ from django.contrib import admin -from tom_dataproducts.models import DataProduct, DataProductGroup +from tom_dataproducts.models import DataProduct, DataProductGroup, ReducedDatum admin.site.register(DataProduct) admin.site.register(DataProductGroup) +admin.site.register(ReducedDatum) diff --git a/tom_dataproducts/migrations/0012_alter_reduceddatum_data_product_and_more.py b/tom_dataproducts/migrations/0012_alter_reduceddatum_data_product_and_more.py new file mode 100644 index 000000000..5696653f4 --- /dev/null +++ b/tom_dataproducts/migrations/0012_alter_reduceddatum_data_product_and_more.py @@ -0,0 +1,29 @@ +# Generated by Django 4.2.1 on 2023-10-23 22:03 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('tom_dataproducts', '0011_reduceddatum_message'), + ] + + operations = [ + migrations.AlterField( + model_name='reduceddatum', + name='data_product', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='tom_dataproducts.dataproduct'), + ), + migrations.AlterField( + model_name='reduceddatum', + name='source_location', + field=models.CharField(blank=True, default='', max_length=200), + ), + migrations.AlterField( + model_name='reduceddatum', + name='source_name', + field=models.CharField(blank=True, default='', max_length=100), + ), + ] diff --git a/tom_dataproducts/models.py b/tom_dataproducts/models.py index 6e2664471..1aa3da09f 100644 --- a/tom_dataproducts/models.py +++ b/tom_dataproducts/models.py @@ -336,8 +336,8 @@ class ReducedDatum(models.Model): max_length=100, default='' ) - source_name = models.CharField(max_length=100, default='') - source_location = models.CharField(max_length=200, default='') + source_name = models.CharField(max_length=100, default='', blank=True) + source_location = models.CharField(max_length=200, default='', blank=True) timestamp = models.DateTimeField(null=False, blank=False, default=datetime.now, db_index=True) value = models.JSONField(null=False, blank=False) message = models.ManyToManyField(AlertStreamMessage) diff --git a/tom_dataproducts/sharing.py b/tom_dataproducts/sharing.py index d85c3524c..ae9d23980 100644 --- a/tom_dataproducts/sharing.py +++ b/tom_dataproducts/sharing.py @@ -144,10 +144,11 @@ def share_data_with_tom(share_destination, form_data, product_id=None, target_id serialized_data['data_product'] = '' if not serialized_data['source_name']: serialized_data['source_name'] = settings.TOM_NAME - serialized_data['source_location'] = "TOM-TOM Direct Sharing" + serialized_data['source_location'] = f"ReducedDatum shared from " \ + f"<{settings.TOM_NAME}.url>/api/reduceddatums/{datum.id}/" response = requests.post(reduced_datums_url, json=serialized_data, headers=headers, auth=auth) response_codes.append(response.status_code) - failed_data_count = response_codes.count(500) + failed_data_count = len([rc for rc in response_codes if rc >= 300]) if failed_data_count < len(response_codes): return {'message': f'{len(response_codes)-failed_data_count} of {len(response_codes)} ' 'datums successfully saved.'} diff --git a/tom_dataproducts/templates/tom_dataproducts/partials/dataproduct_list_for_target.html b/tom_dataproducts/templates/tom_dataproducts/partials/dataproduct_list_for_target.html index eb119fd8a..4c7331e5c 100644 --- a/tom_dataproducts/templates/tom_dataproducts/partials/dataproduct_list_for_target.html +++ b/tom_dataproducts/templates/tom_dataproducts/partials/dataproduct_list_for_target.html @@ -31,7 +31,7 @@
Not Configured
{% endif %} diff --git a/tom_dataproducts/templates/tom_dataproducts/partials/share_target_data.html b/tom_dataproducts/templates/tom_dataproducts/partials/share_target_data.html index bcccaabc4..33d8deffe 100644 --- a/tom_dataproducts/templates/tom_dataproducts/partials/share_target_data.html +++ b/tom_dataproducts/templates/tom_dataproducts/partials/share_target_data.html @@ -3,7 +3,7 @@ {% load tom_common_extras %}