Skip to content

Commit

Permalink
[fix] Show reversion button to operators too
Browse files Browse the repository at this point in the history
For some obscure reasons the django-reversion button
was not being shown to operators.

I concluded this was not done on purpose and proceeded
to remove the bogus code.
  • Loading branch information
nemesifier committed May 17, 2022
1 parent ea86343 commit 8d02ab4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 20 deletions.
3 changes: 1 addition & 2 deletions openwisp_controller/config/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
)

from ..admin import MultitenantAdminMixin
from ..pki.base import PkiReversionTemplatesMixin
from . import settings as app_settings
from .base.vpn import AbstractVpn
from .utils import send_file
Expand Down Expand Up @@ -69,7 +68,7 @@ def system_context(self, obj):
system_context.short_description = _('System Defined Variables')


class BaseAdmin(TimeReadonlyAdminMixin, PkiReversionTemplatesMixin, ModelAdmin):
class BaseAdmin(TimeReadonlyAdminMixin, ModelAdmin):
history_latest_first = True


Expand Down
9 changes: 2 additions & 7 deletions openwisp_controller/pki/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@
from openwisp_users.multitenancy import MultitenantOrgFilter

from ..admin import MultitenantAdminMixin
from .base import PkiReversionTemplatesMixin

Ca = load_model('django_x509', 'Ca')
Cert = load_model('django_x509', 'Cert')


@admin.register(Ca)
class CaAdmin(
MultitenantAdminMixin, PkiReversionTemplatesMixin, AbstractCaAdmin, VersionAdmin
):
class CaAdmin(MultitenantAdminMixin, AbstractCaAdmin, VersionAdmin):
history_latest_first = True


Expand All @@ -26,9 +23,7 @@ class CaAdmin(


@admin.register(Cert)
class CertAdmin(
MultitenantAdminMixin, PkiReversionTemplatesMixin, AbstractCertAdmin, VersionAdmin
):
class CertAdmin(MultitenantAdminMixin, AbstractCertAdmin, VersionAdmin):
multitenant_shared_relations = ('ca',)
history_latest_first = True

Expand Down
2 changes: 0 additions & 2 deletions openwisp_controller/pki/base/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
class PkiReversionTemplatesMixin(object):
change_list_template = 'pki/change_list.html'
9 changes: 0 additions & 9 deletions openwisp_controller/pki/templates/pki/change_list.html

This file was deleted.

8 changes: 8 additions & 0 deletions openwisp_controller/tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
from django.contrib.auth import get_user_model
from django.urls import reverse

from openwisp_users.tests.utils import TestMultitenantAdminMixin

user_model = get_user_model()


class TestAdminMixin(TestMultitenantAdminMixin):
def _test_changelist_recover_deleted(self, app_label, model_label):
self._test_multitenant_admin(
url=reverse('admin:{0}_{1}_changelist'.format(app_label, model_label)),
visible=[],
hidden=[],
)

def _login(self, username='admin', password='tester'):
self.client.force_login(user_model.objects.get(username=username))

Expand Down

0 comments on commit 8d02ab4

Please sign in to comment.