Skip to content

Commit

Permalink
Remove reverse_lazy helper function
Browse files Browse the repository at this point in the history
We can now use django's
  • Loading branch information
johannaengland committed Aug 28, 2024
1 parent 47001ac commit 13579df
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 37 deletions.
16 changes: 0 additions & 16 deletions python/nav/web/seeddb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,10 @@
# along with NAV. If not, see <http://www.gnu.org/licenses/>.
#

from django.urls import reverse

from nav.web.seeddb.constants import TITLE_DEFAULT, NAVPATH_DEFAULT


def reverse_lazy(*args, **kwargs):
# Lazy reverse will become part of the Django framework in future releases.
class Proxy(object):
def __init__(self, *args, **kwargs):
self.args = args
self.kwargs = kwargs

def __str__(self):
if not hasattr(self, 'reverse_url'):
self.reverse_url = reverse(*self.args, **self.kwargs)
return self.reverse_url

return Proxy(*args, **kwargs)


class SeeddbInfo(object):
active = {'index': True}
active_page = ''
Expand Down
4 changes: 3 additions & 1 deletion python/nav/web/seeddb/page/cabling.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
# along with NAV. If not, see <http://www.gnu.org/licenses/>.
#

from django.urls import reverse_lazy

from nav.models.cabling import Cabling
from nav.models.manage import Room
from nav.bulkparse import CablingBulkParser
from nav.bulkimport import CablingImporter

from nav.web.seeddb import SeeddbInfo, reverse_lazy
from nav.web.seeddb import SeeddbInfo
from nav.web.seeddb.constants import SEEDDB_EDITABLE_MODELS
from nav.web.seeddb.page import view_switcher, not_implemented
from nav.web.seeddb.utils.list import render_list
Expand Down
3 changes: 2 additions & 1 deletion python/nav/web/seeddb/page/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
#

from django.shortcuts import render
from django.urls import reverse_lazy

from nav.models.manage import Location
from nav.bulkparse import LocationBulkParser
from nav.bulkimport import LocationImporter

from nav.web.seeddb import SeeddbInfo, reverse_lazy
from nav.web.seeddb import SeeddbInfo
from nav.web.seeddb.constants import SEEDDB_EDITABLE_MODELS
from nav.web.seeddb.forms import LocationForm
from nav.web.seeddb.page import view_switcher, not_implemented
Expand Down
2 changes: 1 addition & 1 deletion python/nav/web/seeddb/page/management_profile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from nav.bulkimport import ManagementProfileImporter
from nav.web.message import new_message, Messages

from nav.web.seeddb import SeeddbInfo, reverse_lazy
from nav.web.seeddb import SeeddbInfo
from nav.web.seeddb.constants import SEEDDB_EDITABLE_MODELS
from nav.web.seeddb.page import view_switcher
from nav.web.seeddb.utils.list import render_list
Expand Down
3 changes: 2 additions & 1 deletion python/nav/web/seeddb/page/netbox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
import datetime
from django.db import transaction
from django.contrib.postgres.aggregates import ArrayAgg
from django.urls import reverse_lazy

from nav.models.manage import Netbox
from nav.bulkparse import NetboxBulkParser
from nav.bulkimport import NetboxImporter

from nav.web.seeddb import SeeddbInfo, reverse_lazy
from nav.web.seeddb import SeeddbInfo
from nav.web.seeddb.constants import SEEDDB_EDITABLE_MODELS
from nav.web.seeddb.page import view_switcher
from nav.web.seeddb.utils.list import render_list
Expand Down
7 changes: 3 additions & 4 deletions python/nav/web/seeddb/page/netbox/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
from socket import error as SocketError
import logging

from django.urls import reverse
from django.http import HttpResponse, JsonResponse, Http404
from django.shortcuts import get_object_or_404, redirect, render
from django.db import transaction
from django.contrib import messages
from django.http import HttpResponse, JsonResponse, Http404
from django.shortcuts import get_object_or_404, redirect, render
from django.urls import reverse, reverse_lazy

from nav.auditlog.models import LogEntry
from nav.models.manage import Netbox, NetboxCategory, NetboxType, NetboxProfile
Expand All @@ -37,7 +37,6 @@
from nav.Snmp.profile import get_snmp_session_for_profile
from nav import napalm
from nav.util import is_valid_ip
from nav.web.seeddb import reverse_lazy
from nav.web.seeddb.utils.edit import resolve_ip_and_sysname
from nav.web.seeddb.page.netbox import NetboxInfo as NI
from nav.web.seeddb.page.netbox.forms import NetboxModelForm
Expand Down
6 changes: 4 additions & 2 deletions python/nav/web/seeddb/page/netboxgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@
#

import logging
from django.http import JsonResponse

from django.urls import reverse_lazy

from nav.models.manage import NetboxGroup, Netbox
from nav.bulkparse import NetboxGroupBulkParser
from nav.bulkimport import NetboxGroupImporter

from nav.web.seeddb import SeeddbInfo, reverse_lazy
from nav.web.seeddb import SeeddbInfo
from nav.web.seeddb.constants import SEEDDB_EDITABLE_MODELS
from nav.web.seeddb.page import view_switcher, not_implemented
from nav.web.seeddb.utils.list import render_list
Expand Down
4 changes: 3 additions & 1 deletion python/nav/web/seeddb/page/netboxtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
# along with NAV. If not, see <http://www.gnu.org/licenses/>.
#

from django.urls import reverse_lazy

from nav.models.manage import NetboxType
from nav.bulkparse import NetboxTypeBulkParser
from nav.bulkimport import NetboxTypeImporter

from nav.web.seeddb import SeeddbInfo, reverse_lazy
from nav.web.seeddb import SeeddbInfo
from nav.web.seeddb.constants import SEEDDB_EDITABLE_MODELS
from nav.web.seeddb.page import view_switcher, not_implemented
from nav.web.seeddb.utils.list import render_list
Expand Down
3 changes: 2 additions & 1 deletion python/nav/web/seeddb/page/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
#

from django.shortcuts import render
from django.urls import reverse_lazy

from nav.models.manage import Organization
from nav.bulkparse import OrgBulkParser
from nav.bulkimport import OrgImporter

from nav.web.seeddb import SeeddbInfo, reverse_lazy
from nav.web.seeddb import SeeddbInfo
from nav.web.seeddb.constants import SEEDDB_EDITABLE_MODELS
from nav.web.seeddb.page import view_switcher
from nav.web.seeddb.utils.edit import render_edit
Expand Down
3 changes: 2 additions & 1 deletion python/nav/web/seeddb/page/patch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@
from django import forms
from django.http import HttpResponse
from django.shortcuts import render, get_object_or_404
from django.urls import reverse_lazy
from django.views.decorators.http import require_POST

from nav.models.cabling import Patch, Cabling
from nav.models.manage import Netbox, Interface, Room
from nav.bulkparse import PatchBulkParser
from nav.bulkimport import PatchImporter

from nav.web.seeddb import SeeddbInfo, reverse_lazy
from nav.web.seeddb import SeeddbInfo
from nav.web.seeddb.constants import SEEDDB_EDITABLE_MODELS
from nav.web.seeddb.page import view_switcher, not_implemented
from nav.web.seeddb.utils.list import render_list
Expand Down
4 changes: 2 additions & 2 deletions python/nav/web/seeddb/page/prefix.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from django.db import transaction
from django.shortcuts import render
from django.http import HttpResponseRedirect
from django.urls import reverse
from django.urls import reverse, reverse_lazy

from nav.web.message import new_message, Messages

Expand All @@ -32,7 +32,7 @@
from nav.bulkparse import PrefixBulkParser
from nav.bulkimport import PrefixImporter

from nav.web.seeddb import SeeddbInfo, reverse_lazy
from nav.web.seeddb import SeeddbInfo
from nav.web.seeddb.constants import SEEDDB_EDITABLE_MODELS
from nav.web.seeddb.page import view_switcher, not_implemented
from nav.web.seeddb.utils.list import render_list
Expand Down
4 changes: 2 additions & 2 deletions python/nav/web/seeddb/page/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
#
"""Forms and view functions for SeedDB's Room view"""

from django.urls import reverse
from django.urls import reverse_lazy

from nav.models.manage import Room
from nav.bulkparse import RoomBulkParser
from nav.bulkimport import RoomImporter

from nav.web.seeddb import SeeddbInfo, reverse_lazy
from nav.web.seeddb import SeeddbInfo
from nav.web.seeddb.constants import SEEDDB_EDITABLE_MODELS
from nav.web.seeddb.page import view_switcher
from nav.web.seeddb.utils.list import render_list
Expand Down
4 changes: 3 additions & 1 deletion python/nav/web/seeddb/page/service/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
# along with NAV. If not, see <http://www.gnu.org/licenses/>.
#

from django.urls import reverse_lazy

from nav.models.service import Service
from nav.bulkparse import ServiceBulkParser
from nav.bulkimport import ServiceImporter

from nav.web.seeddb import SeeddbInfo, reverse_lazy
from nav.web.seeddb import SeeddbInfo
from nav.web.seeddb.constants import SEEDDB_EDITABLE_MODELS
from nav.web.seeddb.page import view_switcher, not_implemented
from nav.web.seeddb.utils.list import render_list
Expand Down
3 changes: 2 additions & 1 deletion python/nav/web/seeddb/page/usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
"""Module containing all things regarding usages in seeddb"""

from django import forms
from django.urls import reverse_lazy

from nav.models.manage import Usage
from nav.bulkparse import UsageBulkParser
from nav.bulkimport import UsageImporter

from nav.web.seeddb import SeeddbInfo, reverse_lazy
from nav.web.seeddb import SeeddbInfo
from nav.web.seeddb.constants import SEEDDB_EDITABLE_MODELS
from nav.web.seeddb.page import view_switcher, not_implemented
from nav.web.seeddb.utils.list import render_list
Expand Down
3 changes: 2 additions & 1 deletion python/nav/web/seeddb/page/vendor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
"""Module containing everything regarding vendors in SeedDB"""

from django import forms
from django.urls import reverse_lazy

from nav.models.manage import Vendor
from nav.bulkparse import VendorBulkParser
from nav.bulkimport import VendorImporter

from nav.web.seeddb import SeeddbInfo, reverse_lazy
from nav.web.seeddb import SeeddbInfo
from nav.web.seeddb.constants import SEEDDB_EDITABLE_MODELS
from nav.web.seeddb.page import view_switcher, not_implemented
from nav.web.seeddb.utils.list import render_list
Expand Down
3 changes: 2 additions & 1 deletion python/nav/web/seeddb/page/vlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
#

from django import forms
from django.urls import reverse_lazy

from crispy_forms.helper import FormHelper
from crispy_forms_foundation.layout import Layout, Row, Column, Fieldset
from nav.web.crispyforms import LabelSubmit

from nav.models.manage import Vlan, NetType, Organization, Usage

from nav.web.seeddb import SeeddbInfo, reverse_lazy
from nav.web.seeddb import SeeddbInfo
from nav.web.seeddb.utils.list import render_list
from nav.web.seeddb.utils.edit import render_edit

Expand Down

0 comments on commit 13579df

Please sign in to comment.