Compare commits
4 Commits
5830318992
...
75871afb1e
Author | SHA1 | Date |
---|---|---|
Arthur Hanson | 75871afb1e | |
Arthur | 835012f2ed | |
Arthur | d3c77fc67f | |
Arthur | fde580807b |
|
@ -0,0 +1,29 @@
|
|||
# Generated by Django 5.0.4 on 2024-04-24 20:09
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def update_dashboard_widgets(apps, schema_editor):
|
||||
Dashboard = apps.get_model('extras', 'Dashboard')
|
||||
|
||||
for dashboard in Dashboard.objects.all():
|
||||
for key, widget in dashboard.config.items():
|
||||
if models := widget['config'].get('models'):
|
||||
models = list(map(lambda x: x.replace('users.netboxgroup', 'users.group'), models))
|
||||
models = list(map(lambda x: x.replace('users.netboxuser', 'users.user'), models))
|
||||
dashboard.config[key]['config']['models'] = models
|
||||
dashboard.save()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('extras', '0114_customfield_add_comments'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(
|
||||
code=update_dashboard_widgets,
|
||||
reverse_code=migrations.RunPython.noop
|
||||
),
|
||||
]
|
|
@ -5,7 +5,7 @@ import re
|
|||
import yaml
|
||||
from django import template
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.contrib.humanize.templatetags.humanize import naturaltime
|
||||
from django.contrib.humanize.templatetags.humanize import naturalday, naturaltime
|
||||
from django.utils.html import escape
|
||||
from django.utils.safestring import mark_safe
|
||||
from markdown import markdown
|
||||
|
@ -216,11 +216,12 @@ def render_yaml(value):
|
|||
def isodate(value):
|
||||
if type(value) is datetime.date:
|
||||
text = value.isoformat()
|
||||
return mark_safe(f'<span title="{naturalday(value)}">{text}</span>')
|
||||
elif type(value) is datetime.datetime:
|
||||
text = value.date().isoformat()
|
||||
return mark_safe(f'<span title="{naturaltime(value)}">{text}</span>')
|
||||
else:
|
||||
return ''
|
||||
return mark_safe(f'<span title="{naturaltime(value)}">{text}</span>')
|
||||
|
||||
|
||||
@register.filter()
|
||||
|
|
Loading…
Reference in New Issue