Skip to content

Commit

Permalink
Merge pull request #117 from basedosdados/missing_empty_models
Browse files Browse the repository at this point in the history
New models: `analysis`, `quality_check`
  • Loading branch information
mfagundes authored May 8, 2023
2 parents 892bee8 + e99f11c commit 644a6b5
Show file tree
Hide file tree
Showing 11 changed files with 777 additions and 38 deletions.
77 changes: 75 additions & 2 deletions basedosdados_api/api/v1/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@
EntityCategory,
Dictionary,
Pipeline,
Analysis,
AnalysisType,
DateTimeRange,
Key,
QualityCheck,
UUIDHIddenIdForm,
)

Expand Down Expand Up @@ -526,7 +528,77 @@ class StatusAdmin(TabbedTranslationAdmin):
]


admin.site.register(AnalysisType)
class AnalysisTypeAdmin(TabbedTranslationAdmin):
readonly_fields = [
"id",
]
list_display = [
"name",
"slug",
]
search_fields = [
"name",
"slug",
]


class AnalysisAdmin(TabbedTranslationAdmin):
readonly_fields = [
"id",
]
list_display = [
"name",
"analysis_type",
]
search_fields = [
"name",
"description",
]
autocomplete_fields = ["analysis_type", "datasets", "themes", "tags"]
filter_horizontal = ["datasets", "themes", "tags"]


class KeyAdmin(admin.ModelAdmin):
readonly_fields = [
"id",
]
list_display = [
"name",
"value",
]
search_fields = [
"name",
"value",
]


class QualityCheckAdmin(TabbedTranslationAdmin):
readonly_fields = [
"id",
]
list_display = [
"name",
"analysis",
"dataset",
"passed",
]
search_fields = [
"name",
"descriptiion",
]
autocomplete_fields = [
"analysis",
"dataset",
"table",
"column",
"key",
"raw_data_source",
"information_request",
]


admin.site.register(Analysis, AnalysisAdmin)
admin.site.register(AnalysisType, AnalysisTypeAdmin)
admin.site.register(Area, AreaAdmin)
admin.site.register(Availability, AvailabilityAdmin)
admin.site.register(BigQueryType)
Expand All @@ -539,7 +611,7 @@ class StatusAdmin(TabbedTranslationAdmin):
admin.site.register(Entity, EntityAdmin)
admin.site.register(EntityCategory, EntityCategoryAdmin)
admin.site.register(InformationRequest, InformationRequestAdmin)
admin.site.register(Key)
admin.site.register(Key, KeyAdmin)
admin.site.register(Language, LanguageAdmin)
admin.site.register(License, LicenseAdmin)
admin.site.register(ObservationLevel, ObservationLevelAdmin)
Expand All @@ -551,3 +623,4 @@ class StatusAdmin(TabbedTranslationAdmin):
admin.site.register(Tag, TagAdmin)
admin.site.register(Theme, ThemeAdmin)
admin.site.register(Update, UpdateAdmin)
admin.site.register(QualityCheck, QualityCheckAdmin)
41 changes: 41 additions & 0 deletions basedosdados_api/api/v1/migrations/0008_analysis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
# Generated by Django 4.2.1 on 2023-05-06 18:26

from django.db import migrations, models
import django.db.models.deletion
import uuid


class Migration(migrations.Migration):

dependencies = [
("v1", "0007_alter_entitycategory_options_and_more"),
]

operations = [
migrations.CreateModel(
name="Analysis",
fields=[
(
"id",
models.UUIDField(
default=uuid.uuid4, primary_key=True, serialize=False
),
),
(
"analysis_type",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="analyses",
to="v1.analysistype",
),
),
],
options={
"verbose_name": "Analysis",
"verbose_name_plural": "Analyses",
"db_table": "analysis",
"ordering": ["id"],
},
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# Generated by Django 4.2.1 on 2023-05-06 18:38

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("v1", "0008_analysis"),
]

operations = [
migrations.RemoveField(
model_name="analysistype",
name="tag",
),
migrations.RemoveField(
model_name="analysistype",
name="tag_en",
),
migrations.RemoveField(
model_name="analysistype",
name="tag_es",
),
migrations.RemoveField(
model_name="analysistype",
name="tag_pt",
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# -*- coding: utf-8 -*-
# Generated by Django 4.2.1 on 2023-05-06 19:00

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
("v1", "0009_remove_analysistype_tag_remove_analysistype_tag_en_and_more"),
]

operations = [
migrations.AddField(
model_name="analysis",
name="tags",
field=models.ManyToManyField(
blank=True,
help_text="Tags are used to group analyses by topic",
related_name="analyses",
to="v1.tag",
),
),
migrations.AddField(
model_name="analysis",
name="themes",
field=models.ManyToManyField(
help_text="Themes are used to group analyses by topic",
related_name="analyses",
to="v1.theme",
),
),
migrations.AddField(
model_name="analysis",
name="url",
field=models.URLField(blank=True, max_length=255, null=True),
),
migrations.AddField(
model_name="coverage",
name="analysis",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="coverages",
to="v1.analysis",
),
),
migrations.AddField(
model_name="observationlevel",
name="analysis",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="observation_levels",
to="v1.analysis",
),
),
]
Loading

0 comments on commit 644a6b5

Please sign in to comment.