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

Uses Django Public Admin package #524

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 12 additions & 4 deletions jarbas/dashboard/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from django.db.models import Count, F, Sum
from django.db.models.functions import Concat
from django.utils.safestring import mark_safe
from public_admin.admin import PublicModelAdmin
from public_admin.sites import PublicAdminSite, PublicApp

from jarbas.chamber_of_deputies.models import (
Reimbursement,
Expand All @@ -18,16 +20,14 @@
from jarbas.dashboard.admin import list_filters, widgets
from jarbas.dashboard.admin.paginators import CachedCountPaginator
from jarbas.dashboard.admin.subquotas import Subquotas
from jarbas.public_admin.admin import PublicAdminModelAdmin
from jarbas.public_admin.sites import public_admin


ALL_FIELDS = sorted(Reimbursement._meta.fields, key=lambda f: f.verbose_name)
CUSTOM_WIDGETS = ('receipt_url', 'subquota_description', 'suspicions')
READONLY_FIELDS = (f.name for f in ALL_FIELDS if f.name not in CUSTOM_WIDGETS)


class ReimbursementModelAdmin(PublicAdminModelAdmin):
class ReimbursementModelAdmin(PublicModelAdmin):

list_display = (
'short_document_id',
Expand Down Expand Up @@ -183,7 +183,7 @@ def get_search_results(self, request, queryset, search_term):
return queryset, distinct


class ReimbursementSummaryModelAdmin(PublicAdminModelAdmin):
class ReimbursementSummaryModelAdmin(PublicModelAdmin):
change_list_template = 'dashboard/reimbursement_summary_change_list.html'
list_filter = (
list_filters.SuspiciousListFilter,
Expand Down Expand Up @@ -307,5 +307,13 @@ def changelist_view(self, request, extra=None):
return response


class JarbasPublicAdminSite(PublicAdminSite):
site_title = 'Dashboard'
site_header = 'Jarbas Dashboard'
index_title = 'Jarbas'


public_app = PublicApp('chamber_of_deputies', ('reimbursement',))
public_admin = JarbasPublicAdminSite("dashboard", public_app)
public_admin.register(Reimbursement, ReimbursementModelAdmin)
public_admin.register(ReimbursementSummary, ReimbursementSummaryModelAdmin)
2 changes: 1 addition & 1 deletion jarbas/dashboard/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.urls import path

from jarbas.public_admin.sites import public_admin
from jarbas.dashboard.admin import public_admin


urlpatterns = [
Expand Down
Empty file removed jarbas/public_admin/__init__.py
Empty file.
30 changes: 0 additions & 30 deletions jarbas/public_admin/admin.py

This file was deleted.

61 changes: 0 additions & 61 deletions jarbas/public_admin/sites.py

This file was deleted.

Empty file.
21 changes: 0 additions & 21 deletions jarbas/public_admin/tests/test_dummy_user.py

This file was deleted.

44 changes: 0 additions & 44 deletions jarbas/public_admin/tests/test_public_admin_site.py

This file was deleted.

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ django-bulk-update==2.2.0
django-cors-middleware==1.3.1
django-debug-toolbar==1.11
django-extensions==2.1.6
django-public-admin==0.0.2
django-test-without-migrations==0.6
djangorestframework==3.9.1
freezegun==0.3.11
Expand Down