Merge branch 'develop' into 17117-safari

This commit is contained in:
Jeremy Stretch 2024-08-26 15:22:07 -04:00
commit ae0b372128
11 changed files with 243 additions and 221 deletions

View File

@ -195,7 +195,7 @@ class LocationFilterForm(TenancyFilterForm, ContactModelFilterForm, NetBoxModelF
model = Location model = Location
fieldsets = ( fieldsets = (
FieldSet('q', 'filter_id', 'tag'), FieldSet('q', 'filter_id', 'tag'),
FieldSet('region_id', 'site_group_id', 'site_id', 'parent_id', 'status', name=_('Attributes')), FieldSet('region_id', 'site_group_id', 'site_id', 'parent_id', 'status', 'facility', name=_('Attributes')),
FieldSet('tenant_group_id', 'tenant_id', name=_('Tenant')), FieldSet('tenant_group_id', 'tenant_id', name=_('Tenant')),
FieldSet('contact', 'contact_role', 'contact_group', name=_('Contacts')), FieldSet('contact', 'contact_role', 'contact_group', name=_('Contacts')),
) )
@ -232,6 +232,10 @@ class LocationFilterForm(TenancyFilterForm, ContactModelFilterForm, NetBoxModelF
choices=LocationStatusChoices, choices=LocationStatusChoices,
required=False required=False
) )
facility = forms.CharField(
label=_('Facility'),
required=False
)
tag = TagFilterField(model) tag = TagFilterField(model)

View File

@ -99,6 +99,11 @@ class SiteTable(TenancyColumnsMixin, ContactsColumnMixin, NetBoxTable):
url_params={'site_id': 'pk'}, url_params={'site_id': 'pk'},
verbose_name=_('ASN Count') verbose_name=_('ASN Count')
) )
device_count = columns.LinkedCountColumn(
viewname='dcim:device_list',
url_params={'site_id': 'pk'},
verbose_name=_('Devices')
)
comments = columns.MarkdownColumn( comments = columns.MarkdownColumn(
verbose_name=_('Comments'), verbose_name=_('Comments'),
) )

View File

@ -380,7 +380,9 @@ class SiteGroupContactsView(ObjectContactsView):
# #
class SiteListView(generic.ObjectListView): class SiteListView(generic.ObjectListView):
queryset = Site.objects.all() queryset = Site.objects.annotate(
device_count=count_related(Device, 'site')
)
filterset = filtersets.SiteFilterSet filterset = filtersets.SiteFilterSet
filterset_form = forms.SiteFilterForm filterset_form = forms.SiteFilterForm
table = tables.SiteTable table = tables.SiteTable

View File

@ -19,6 +19,8 @@ class ImageAttachmentSerializer(ValidatedModelSerializer):
queryset=ObjectType.objects.all() queryset=ObjectType.objects.all()
) )
parent = serializers.SerializerMethodField(read_only=True) parent = serializers.SerializerMethodField(read_only=True)
image_width = serializers.IntegerField(read_only=True)
image_height = serializers.IntegerField(read_only=True)
class Meta: class Meta:
model = ImageAttachment model = ImageAttachment

View File

@ -31,7 +31,7 @@ class ReportForm(forms.Form):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
# Annotate the current system time for reference # Annotate the current system time for reference
now = local_now().strftime('%Y-%m-%d %H:%M:%S') now = local_now().strftime('%Y-%m-%d %H:%M:%S %Z')
self.fields['schedule_at'].help_text += _(' (current time: <strong>{now}</strong>)').format(now=now) self.fields['schedule_at'].help_text += _(' (current time: <strong>{now}</strong>)').format(now=now)
# Remove scheduling fields if scheduling is disabled # Remove scheduling fields if scheduling is disabled

View File

@ -37,7 +37,7 @@ class ScriptForm(forms.Form):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
# Annotate the current system time for reference # Annotate the current system time for reference
now = local_now().strftime('%Y-%m-%d %H:%M:%S') now = local_now().strftime('%Y-%m-%d %H:%M:%S %Z')
self.fields['_schedule_at'].help_text += _(' (current time: <strong>{now}</strong>)').format(now=now) self.fields['_schedule_at'].help_text += _(' (current time: <strong>{now}</strong>)').format(now=now)
# Remove scheduling fields if scheduling is disabled # Remove scheduling fields if scheduling is disabled

Binary file not shown.

View File

@ -30,6 +30,9 @@
// Remove the bottom margin of <p> elements inside a table cell // Remove the bottom margin of <p> elements inside a table cell
td > .rendered-markdown { td > .rendered-markdown {
max-height: 200px;
overflow-y: scroll;
p:last-of-type { p:last-of-type {
margin-bottom: 0; margin-bottom: 0;
} }

View File

@ -113,11 +113,12 @@ class ContactAssignmentTable(NetBoxTable):
) )
contact_phone = tables.Column( contact_phone = tables.Column(
accessor=Accessor('contact__phone'), accessor=Accessor('contact__phone'),
verbose_name=_('Contact Phone') verbose_name=_('Contact Phone'),
linkify=linkify_phone,
) )
contact_email = tables.Column( contact_email = tables.EmailColumn(
accessor=Accessor('contact__email'), accessor=Accessor('contact__email'),
verbose_name=_('Contact Email') verbose_name=_('Contact Email'),
) )
contact_address = tables.Column( contact_address = tables.Column(
accessor=Accessor('contact__address'), accessor=Accessor('contact__address'),

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,7 @@ from django.contrib.contenttypes.models import ContentType
from django.contrib.humanize.templatetags.humanize import naturalday, naturaltime from django.contrib.humanize.templatetags.humanize import naturalday, naturaltime
from django.utils.html import escape from django.utils.html import escape
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from django.utils.timezone import localtime
from markdown import markdown from markdown import markdown
from markdown.extensions.tables import TableExtension from markdown.extensions.tables import TableExtension
@ -218,7 +219,8 @@ def isodate(value):
text = value.isoformat() text = value.isoformat()
return mark_safe(f'<span title="{naturalday(value)}">{text}</span>') return mark_safe(f'<span title="{naturalday(value)}">{text}</span>')
elif type(value) is datetime.datetime: elif type(value) is datetime.datetime:
text = value.date().isoformat() local_value = localtime(value) if value.tzinfo else value
text = local_value.date().isoformat()
return mark_safe(f'<span title="{naturaltime(value)}">{text}</span>') return mark_safe(f'<span title="{naturaltime(value)}">{text}</span>')
else: else:
return '' return ''
@ -229,7 +231,8 @@ def isotime(value, spec='seconds'):
if type(value) is datetime.time: if type(value) is datetime.time:
return value.isoformat(timespec=spec) return value.isoformat(timespec=spec)
if type(value) is datetime.datetime: if type(value) is datetime.datetime:
return value.time().isoformat(timespec=spec) local_value = localtime(value) if value.tzinfo else value
return local_value.time().isoformat(timespec=spec)
return '' return ''