2024-04-18 11:30:18 -04:00
|
|
|
import calendar
|
|
|
|
|
|
|
|
import django_tables2 as tables
|
|
|
|
|
|
|
|
from .models import HIDEvent
|
|
|
|
|
|
|
|
|
|
|
|
class UnitTimeTable(tables.Table):
|
|
|
|
members = tables.columns.Column()
|
|
|
|
members_delta = tables.columns.TemplateColumn(
|
|
|
|
"{{ value|floatformat:2}}%", verbose_name="Δ Members"
|
|
|
|
)
|
|
|
|
access_count = tables.columns.Column()
|
|
|
|
access_count_delta = tables.columns.TemplateColumn(
|
|
|
|
"{{ value|floatformat:2}}%", verbose_name="Δ Access Count"
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
fields = ("members", "members_delta", "access_count", "access_count_delta")
|
|
|
|
|
|
|
|
|
|
|
|
class DeniedAccessTable(tables.Table):
|
2024-08-26 23:23:53 -04:00
|
|
|
decoded_card_number = tables.Column(orderable=False)
|
2024-04-18 11:30:18 -04:00
|
|
|
name = tables.TemplateColumn(
|
|
|
|
"{{ record.forename|default:'' }} {{ record.surname|default:'' }}"
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = HIDEvent
|
|
|
|
|
|
|
|
fields = (
|
|
|
|
"timestamp",
|
|
|
|
"door",
|
|
|
|
"event_type",
|
|
|
|
"name",
|
|
|
|
"raw_card_number",
|
|
|
|
"decoded_card_number",
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class MostActiveMembersTable(tables.Table):
|
|
|
|
name = tables.Column()
|
|
|
|
access_count = tables.Column()
|
|
|
|
|
|
|
|
|
|
|
|
class DetailByDayTable(tables.Table):
|
|
|
|
timestamp__date = tables.DateColumn(verbose_name="Date")
|
|
|
|
name = tables.Column()
|
|
|
|
access_count = tables.Column()
|
2024-05-13 00:38:01 -04:00
|
|
|
granted_access_count = tables.Column()
|
2024-04-18 11:30:18 -04:00
|
|
|
|
|
|
|
|
|
|
|
class BusiestDayOfWeekTable(tables.Table):
|
|
|
|
timestamp__week_day = tables.Column("Week Day")
|
|
|
|
events = tables.Column()
|
|
|
|
members = tables.Column()
|
|
|
|
|
|
|
|
def render_timestamp__week_day(self, value):
|
|
|
|
return calendar.day_name[(value - 2) % 7]
|
|
|
|
|
|
|
|
|
|
|
|
class BusiestTimeOfDayTable(tables.Table):
|
|
|
|
timestamp__hour = tables.TemplateColumn("{{ value }}:00", verbose_name="Hour")
|
|
|
|
events = tables.Column()
|
|
|
|
members = tables.Column()
|
2025-01-03 21:21:31 -05:00
|
|
|
|
|
|
|
|
|
|
|
class AssignedNfcCardsTable(tables.Table):
|
|
|
|
member__account_name = tables.Column("Name")
|
|
|
|
member__nfc_card_number = tables.Column("MW NFC Card")
|
|
|
|
access_user__nfc_cards = tables.TemplateColumn(
|
|
|
|
"""
|
|
|
|
{% if value %}
|
|
|
|
<ul>
|
|
|
|
{% for card in value %}
|
|
|
|
<li>{{ card.type }}: {{ card.id }}</li>
|
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
|
|
|
{% else %}
|
|
|
|
???
|
|
|
|
{% endif %}
|
|
|
|
""",
|
|
|
|
empty_values=[[]],
|
|
|
|
verbose_name="UniFi Access Cards",
|
|
|
|
)
|
|
|
|
member__access_wood_shop = tables.BooleanColumn(verbose_name="Access Wood Shop")
|
|
|
|
member__access_metal_shop = tables.BooleanColumn(verbose_name="Access Metal Shop")
|