1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Merge branch 'develop' into feature

This commit is contained in:
jeremystretch
2021-05-25 13:19:17 -04:00
37 changed files with 220 additions and 93 deletions

View File

@@ -130,22 +130,24 @@ class ColorChoices(ChoiceSet):
class ButtonColorChoices(ChoiceSet):
"""
Map standard button color choices to Bootstrap color classes
Map standard button color choices to Bootstrap 3 button classes
"""
DEFAULT = 'outline-dark'
BLUE = 'primary'
GREY = 'secondary'
CYAN = 'info'
GREEN = 'success'
RED = 'danger'
YELLOW = 'warning'
GREY = 'secondary'
BLACK = 'dark'
CHOICES = (
(DEFAULT, 'Default'),
(BLUE, 'Blue'),
(GREY, 'Grey'),
(CYAN, 'Cyan'),
(GREEN, 'Green'),
(RED, 'Red'),
(YELLOW, 'Yellow'),
(GREY, 'Grey'),
(BLACK, 'Black')
)

View File

@@ -4,7 +4,9 @@ from django.core.paginator import Paginator, Page
class EnhancedPaginator(Paginator):
def __init__(self, object_list, per_page, **kwargs):
def __init__(self, object_list, per_page, orphans=None, **kwargs):
# Determine the page size
try:
per_page = int(per_page)
if per_page < 1:
@@ -12,7 +14,13 @@ class EnhancedPaginator(Paginator):
except ValueError:
per_page = settings.PAGINATE_COUNT
super().__init__(object_list, per_page, **kwargs)
# Set orphans count based on page size
if orphans is None and per_page <= 50:
orphans = 5
elif orphans is None:
orphans = 10
super().__init__(object_list, per_page, orphans=orphans, **kwargs)
def _get_page(self, *args, **kwargs):
return EnhancedPage(*args, **kwargs)

View File

@@ -5,7 +5,6 @@ from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import FieldDoesNotExist
from django.db.models.fields.related import RelatedField
from django.urls import reverse
from django.utils.html import strip_tags
from django.utils.safestring import mark_safe
from django_tables2 import RequestConfig
from django_tables2.data import TableQuerysetData
@@ -15,19 +14,6 @@ from extras.models import CustomField
from .paginator import EnhancedPaginator, get_paginate_count
def stripped_value(self, **kwargs):
"""
Replaces TemplateColumn's value() method to both strip HTML tags and remove any leading/trailing whitespace.
"""
html = super(tables.TemplateColumn, self).value(**kwargs)
return strip_tags(html).strip() if isinstance(html, str) else html
# TODO: We're monkey-patching TemplateColumn here to strip leading/trailing whitespace. This will no longer
# be necessary under django-tables2 v2.3.5+. (See #5926)
tables.TemplateColumn.value = stripped_value
class BaseTable(tables.Table):
"""
Default table for object lists