Skip to content
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

Staging #706

Merged
merged 25 commits into from
Nov 7, 2024
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ba85bb2
feat: spatial coverage in search, admin
rdahis Nov 3, 2024
7f4cb48
feat: options for directory primary key
rdahis Nov 3, 2024
3752745
Merge pull request #700 from basedosdados/feat/spatial_coverage
rdahis Nov 3, 2024
5e0b08a
fix: area on_delete SET_NULL
rdahis Nov 3, 2024
e8f7eaa
fix: consistent on_delete SET_NULL throughout
rdahis Nov 3, 2024
7d331aa
feat: better area search admin page
rdahis Nov 3, 2024
b623524
fix: admin page for coverage was too slow
rdahis Nov 4, 2024
dfb4de4
feat: add admin support for polls
rdahis Nov 4, 2024
c1953ad
feat: observation_level.order; working except when editing metadata f…
rdahis Nov 4, 2024
f4129e0
feat: M2M dataset-organization, table-published_by,data_cleaned_by
rdahis Nov 5, 2024
f250fdb
Merge pull request #702 from basedosdados/feat/manytomany
rdahis Nov 5, 2024
3d0dab3
fix: optimize list of users in Table admin
rdahis Nov 5, 2024
2da1b69
fix: add cloud table through inline
rdahis Nov 5, 2024
be15bca
remove table.raw_data_url field
rdahis Nov 5, 2024
2e41ef0
feat: measurement unit, category, populate
rdahis Nov 6, 2024
de843a8
fix: cloud table inline
rdahis Nov 6, 2024
61eeb9e
Merge branch 'dev' into feat/observation_level_order
rdahis Nov 6, 2024
fc58d72
fix: observation level inline working after edits
rdahis Nov 6, 2024
cf0b995
Merge pull request #701 from basedosdados/feat/observation_level_order
rdahis Nov 6, 2024
93b1cd6
feat: add poll.pipeline and pipeline admin
rdahis Nov 6, 2024
970905d
feat: table.is_deprecated
rdahis Nov 6, 2024
0b85ede
Merge branch 'staging' into dev
rdahis Nov 6, 2024
79b6f48
Merge pull request #703 from basedosdados/dev
rdahis Nov 6, 2024
0c2fe51
fix: translated spatial coverage names
rdahis Nov 7, 2024
d664140
Merge pull request #704 from basedosdados/dev
rdahis Nov 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: admin page for coverage was too slow
rdahis committed Nov 4, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit b62352443a3bea4486dfd926dd9e9d58abf95d92
44 changes: 40 additions & 4 deletions backend/apps/api/v1/admin.py
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
from django.http import HttpRequest
from django.shortcuts import render
from django.utils.html import format_html
from django.urls import reverse
from modeltranslation.admin import TabbedTranslationAdmin, TranslationStackedInline
from ordered_model.admin import OrderedInlineModelAdminMixin, OrderedStackedInline

@@ -788,7 +789,7 @@ class DateTimeRangeAdmin(admin.ModelAdmin):


class CoverageAdmin(admin.ModelAdmin):
readonly_fields = ["id"]
readonly_fields = ["id", "datetime_ranges_display"]
list_display = [
"area",
"coverage_type",
@@ -812,9 +813,44 @@ class CoverageAdmin(admin.ModelAdmin):
"information_request__dataset__name",
"column__name",
]
inlines = [
DateTimeRangeInline,
]

def datetime_ranges_display(self, obj):
"""Display datetime ranges with links to their admin pages"""
ranges = obj.datetime_ranges.all()
links = []
for dt_range in ranges:
url = reverse('admin:v1_datetimerange_change', args=[dt_range.id])
links.append(
format_html('<a href="{}">{}</a>', url, str(dt_range))
)

# Add link to add new datetime range
add_url = reverse('admin:v1_datetimerange_add') + f'?coverage={obj.id}'
links.append(
format_html(
'<a class="addlink" href="{}">Add DateTime Range</a>',
add_url
)
)

return format_html('<br>'.join(links))

datetime_ranges_display.short_description = "DateTime Ranges"

def get_queryset(self, request):
"""Optimize queryset by prefetching related objects"""
qs = super().get_queryset(request).select_related(
'table',
'column',
'raw_data_source',
'information_request',
'area'
)
# Add prefetch for datetime_ranges and their units
return qs.prefetch_related(
'datetime_ranges',
'datetime_ranges__units'
)


class EntityCategoryAdmin(TabbedTranslationAdmin):