mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Merge branch 'develop' into 451-devicetype-import
This commit is contained in:
@@ -6,10 +6,9 @@ from rest_framework.relations import ManyRelatedField
|
||||
from taggit_serializer.serializers import TagListSerializerField
|
||||
|
||||
from dcim.api.serializers import InterfaceSerializer as DeviceInterfaceSerializer
|
||||
from virtualization.api.serializers import InterfaceSerializer as VirtualMachineInterfaceSerializer
|
||||
from extras.api.customfields import CustomFieldsSerializer
|
||||
from utilities.api import ChoiceField, SerializedPKRelatedField, WritableNestedSerializer
|
||||
|
||||
from virtualization.api.serializers import InterfaceSerializer as VirtualMachineInterfaceSerializer
|
||||
|
||||
# this might be ugly, but it limits drf_yasg-specific code to this file
|
||||
DeviceInterfaceSerializer.Meta.ref_name = 'DeviceInterface'
|
||||
|
@@ -1,4 +1,5 @@
|
||||
from django.db.models import Manager
|
||||
from django.db.models.expressions import RawSQL
|
||||
|
||||
NAT1 = r"CAST(SUBSTRING({}.{} FROM '^(\d{{1,9}})') AS integer)"
|
||||
NAT2 = r"SUBSTRING({}.{} FROM '^\d*(.*?)\d*$')"
|
||||
@@ -21,11 +22,11 @@ class NaturalOrderingManager(Manager):
|
||||
db_field = self.natural_order_field
|
||||
|
||||
# Append the three subfields derived from the designated natural ordering field
|
||||
queryset = queryset.extra(select={
|
||||
'_nat1': NAT1.format(db_table, db_field),
|
||||
'_nat2': NAT2.format(db_table, db_field),
|
||||
'_nat3': NAT3.format(db_table, db_field),
|
||||
})
|
||||
queryset = (
|
||||
queryset.annotate(_nat1=RawSQL(NAT1.format(db_table, db_field), ()))
|
||||
.annotate(_nat2=RawSQL(NAT2.format(db_table, db_field), ()))
|
||||
.annotate(_nat3=RawSQL(NAT3.format(db_table, db_field), ()))
|
||||
)
|
||||
|
||||
# Replace any instance of the designated natural ordering field with its three subfields
|
||||
ordering = []
|
||||
|
@@ -1,8 +1,9 @@
|
||||
from urllib import parse
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import ProgrammingError
|
||||
from django.http import Http404, HttpResponseRedirect
|
||||
from django.urls import reverse
|
||||
import urllib
|
||||
|
||||
from .views import server_error
|
||||
|
||||
@@ -26,7 +27,7 @@ class LoginRequiredMiddleware(object):
|
||||
return HttpResponseRedirect(
|
||||
'{}?next={}'.format(
|
||||
settings.LOGIN_URL,
|
||||
urllib.parse.quote(request.get_full_path_info())
|
||||
parse.quote(request.get_full_path_info())
|
||||
)
|
||||
)
|
||||
return self.get_response(request)
|
||||
|
@@ -26,6 +26,12 @@ class ToggleColumn(tables.CheckBoxColumn):
|
||||
def __init__(self, *args, **kwargs):
|
||||
default = kwargs.pop('default', '')
|
||||
visible = kwargs.pop('visible', False)
|
||||
if 'attrs' not in kwargs:
|
||||
kwargs['attrs'] = {
|
||||
'td': {
|
||||
'class': 'min-width'
|
||||
}
|
||||
}
|
||||
super().__init__(*args, default=default, visible=visible, **kwargs)
|
||||
|
||||
@property
|
||||
|
@@ -3,6 +3,7 @@ import json
|
||||
import re
|
||||
|
||||
from django import template
|
||||
from django.utils.html import strip_tags
|
||||
from django.utils.safestring import mark_safe
|
||||
from markdown import markdown
|
||||
|
||||
@@ -58,7 +59,12 @@ def gfm(value):
|
||||
"""
|
||||
Render text as GitHub-Flavored Markdown
|
||||
"""
|
||||
# Strip HTML tags
|
||||
value = strip_tags(value)
|
||||
|
||||
# Render Markdown with GFM extension
|
||||
html = markdown(value, extensions=['mdx_gfm'])
|
||||
|
||||
return mark_safe(html)
|
||||
|
||||
|
||||
|
@@ -1,7 +1,6 @@
|
||||
from collections import OrderedDict
|
||||
|
||||
import datetime
|
||||
import json
|
||||
from collections import OrderedDict
|
||||
|
||||
from django.core.serializers import serialize
|
||||
from django.db.models import Count, OuterRef, Subquery
|
||||
|
Reference in New Issue
Block a user