Skip to content

Commit

Permalink
Merge pull request #4207 from unicef/fix/rdi-admin
Browse files Browse the repository at this point in the history
Remove invalid redirect
  • Loading branch information
patryk-dabrowski authored Sep 9, 2024
2 parents 2a5a6c7 + 1e53adb commit 7c4a808
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions backend/hct_mis_api/apps/registration_data/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from django.utils.safestring import mark_safe

from admin_extra_buttons.api import confirm_action
from admin_extra_buttons.decorators import button, link
from admin_extra_buttons.decorators import button
from adminfilters.autocomplete import AutoCompleteFilter
from adminfilters.filters import ChoicesFieldComboFilter, ValueFilter
from adminfilters.mixin import AdminAutoCompleteSearchMixin
Expand Down Expand Up @@ -65,19 +65,6 @@ class RegistrationDataImportAdmin(AdminAutoCompleteSearchMixin, HOPEModelAdminBa
def get_queryset(self, request: HttpRequest) -> QuerySet:
return super().get_queryset(request).select_related("business_area")

@link(
label="HUB RDI",
# permission=lambda r, o: r.user.is_superuser,
# visible=lambda btn: btn.original.status == RegistrationDataImport.IMPORT_ERROR,
)
def hub(self, button: button) -> Optional[str]:
obj = button.context.get("original")
if obj:
return reverse("admin:registration_data_registrationdataimportdatahub_change", args=[obj.datahub_id])

button.visible = False
return None

@button(
label="Re-run RDI",
permission=lambda r, o, handler: r.user.is_superuser,
Expand Down Expand Up @@ -269,12 +256,6 @@ def households(self, request: HttpRequest, pk: UUID) -> HttpResponseRedirect:
url = reverse("admin:household_household_changelist")
return HttpResponseRedirect(f"{url}?&qs=registration_data_import__exact={obj.id}")

@button()
def hub_rdi(self, request: HttpRequest, pk: UUID) -> HttpResponseRedirect:
obj = self.get_object(request, str(pk))
url = reverse("admin:registration_datahub_registrationdataimportdatahub_change", args=[obj.datahub_id])
return HttpResponseRedirect(url)

@button(permission="program.enroll_beneficiaries")
def enroll_to_program(self, request: HttpRequest, pk: UUID) -> Optional[HttpResponse]:
url = reverse("admin:registration_data_registrationdataimport_change", args=[pk])
Expand Down

0 comments on commit 7c4a808

Please sign in to comment.