diff --git a/backend/apps/api/v1/admin.py b/backend/apps/api/v1/admin.py index bd34b8cf..693fd77c 100644 --- a/backend/apps/api/v1/admin.py +++ b/backend/apps/api/v1/admin.py @@ -304,9 +304,11 @@ class PollInline(admin.StackedInline): "entity", "frequency", "latest", + "pipeline", ] autocomplete_fields = [ "entity", + "pipeline", ] @@ -1287,6 +1289,7 @@ class PollAdmin(admin.ModelAdmin): ] autocomplete_fields = [ "entity", + "pipeline", "raw_data_source", "information_request", ] @@ -1299,6 +1302,19 @@ class PollAdmin(admin.ModelAdmin): "information_request", ] +class PipelineAdmin(admin.ModelAdmin): + readonly_fields = [ + "id", + ] + search_fields = [ + "id", + "github_url", + ] + list_display = [ + "id", + "github_url", + ] + admin.site.register(Analysis, AnalysisAdmin) admin.site.register(AnalysisType, AnalysisTypeAdmin) @@ -1322,7 +1338,7 @@ class PollAdmin(admin.ModelAdmin): admin.site.register(MeasurementUnitCategory, MeasurementUnitCategoryAdmin) admin.site.register(ObservationLevel, ObservationLevelAdmin) admin.site.register(Organization, OrganizationAdmin) -admin.site.register(Pipeline) +admin.site.register(Pipeline, PipelineAdmin) admin.site.register(RawDataSource, RawDataSourceAdmin) admin.site.register(Status, StatusAdmin) admin.site.register(Table, TableAdmin) diff --git a/backend/apps/api/v1/migrations/0049_poll_pipeline.py b/backend/apps/api/v1/migrations/0049_poll_pipeline.py new file mode 100644 index 00000000..2dc4b07d --- /dev/null +++ b/backend/apps/api/v1/migrations/0049_poll_pipeline.py @@ -0,0 +1,19 @@ +# Generated by Django 4.2.16 on 2024-11-06 04:14 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('v1', '0048_alter_observationlevel_options_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='poll', + name='pipeline', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='polls', to='v1.pipeline'), + ), + ] diff --git a/backend/apps/api/v1/models.py b/backend/apps/api/v1/models.py index 4d56a08b..cbf60544 100644 --- a/backend/apps/api/v1/models.py +++ b/backend/apps/api/v1/models.py @@ -814,6 +814,13 @@ class Poll(BaseModel): ) frequency = models.IntegerField(blank=True, null=True) latest = models.DateTimeField(blank=True, null=True) + pipeline = models.ForeignKey( + "Pipeline", + blank=True, + null=True, + on_delete=models.SET_NULL, + related_name="polls", + ) raw_data_source = models.ForeignKey( "RawDataSource", blank=True,