Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.4.2 Release #27

Merged
merged 2 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 0.4.2 (2024-09-29)

* Adding Maintenance calendar widget
* Fix #26 - f string quote issue with NB 4.1

## 0.4.1 (2024-09-19)

* Adding Maintenance Schedule calendar


## 0.4.0 (2024-09-19)

Expand Down
2 changes: 1 addition & 1 deletion netbox_circuitmaintenance/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__author__ = """Jason Yates"""
__email__ = 'me@jasonyates.co.uk'
__version__ = '0.4.0'
__version__ = '0.4.2'


from netbox.plugins import PluginConfig
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{% load helpers %}
{{ calendar }}
4 changes: 2 additions & 2 deletions netbox_circuitmaintenance/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ def formatday(self, day, weekday, events):

# Format time of the event
if self.custom_strftime('SU', event.start) == self.custom_strftime('SU', event.end):
event_time = f'{self.custom_strftime('%H:%M', event.start)} - {self.custom_strftime('%H:%M', event.end)}'
event_time = f'{self.custom_strftime("%H:%M", event.start)} - {self.custom_strftime("%H:%M", event.end)}'
else:
event_time = f'{self.custom_strftime('SU %H:%M', event.start)} - {self.custom_strftime('SU %H:%M', event.end)}'
event_time = f'{self.custom_strftime("SU %H:%M", event.start)} - {self.custom_strftime("SU %H:%M", event.end)}'

# Add the event to the day
events_html += f'<span class="badge text-bg-{event.get_status_color()}"><a href="{event.get_absolute_url()}">{event_time}<br>{event.name} <br>{event.provider} - {event.status}<br>{event.impact_count} Impacted</a></span>'
Expand Down
24 changes: 23 additions & 1 deletion netbox_circuitmaintenance/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
from django.template.loader import render_to_string
from .models import CircuitMaintenance
from django.db.models import Count
from .views import Calendar
import datetime
from django.utils.safestring import mark_safe

@register_widget
class ReminderWidget(DashboardWidget):
class UpcomingMaintenanceWidget(DashboardWidget):
default_title = 'Upcoming Circuit Maintenance Events'
description = 'Show a list of upcoming circuit maintenance events'
template_name = 'netbox_circuitmaintenance/widget.html'
Expand All @@ -20,3 +23,22 @@ def render(self, request):
impact_count=Count('impact')
),
})

@register_widget
class MaintenanceCalendarWidget(DashboardWidget):
default_title = 'Upcoming Circuit Maintenance Calendar'
description = 'Show a simplified calendar view showing upcoming maintenance events this month'
template_name = 'netbox_circuitmaintenance/calendar_widget.html'
width = 8
height = 8

def render(self, request):

curr_month = datetime.date.today()

# Load calendar
cal = Calendar()
html_calendar = cal.formatmonth(curr_month.year, curr_month.month)
html_calendar = html_calendar.replace('<td ', '<td width="100" height="100"')

return render_to_string(self.template_name, {"calendar": mark_safe(html_calendar)})
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ python =
3.8: py38, format, lint, build

[bumpversion]
current_version = 0.4.0
current_version = 0.4.2
commit = True
tag = True

Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@
],
description="NetBox plugin for circuitmaintenance.",
install_requires=requirements,
long_description=readme + '\n\n',
include_package_data=True,
keywords='netbox_circuitmaintenance',
name='netbox_circuitmaintenance',
packages=find_packages(include=['netbox_circuitmaintenance', 'netbox_circuitmaintenance.*']),
test_suite='tests',
url='https://github.com/jasonyates/netbox-circuitmaintenance',
version='0.4.0',
version='0.4.2',
zip_safe=False,
)