Adam Goldsmith c8b3edcacf
All checks were successful
Ruff / ruff (push) Successful in 1m0s
Test / test (push) Successful in 8m52s
doorcontrol: Add report for assigned NFC cards
2025-01-03 21:26:51 -05:00

53 lines
1.5 KiB
Python

from django import forms
from django.db import models
from membershipworks.models import Member
from .models import AttributeScheduleRule, Door
class DoorAdminForm(forms.ModelForm):
access_field = forms.ChoiceField(
choices=[(None, "---------")]
+ [
(field.name, field.verbose_name)
for field in Member._meta.get_fields()
if (
isinstance(field, models.BooleanField)
and field.name.startswith("access_")
)
],
help_text=Door._meta.get_field("access_field").help_text,
)
class Meta:
model = Door
fields = "__all__"
class AttributeScheduleRuleForm(forms.ModelForm):
access_field = forms.ChoiceField(
choices=[(None, "---------")]
+ [
(field.name, field.verbose_name)
for field in Member._meta.get_fields()
if isinstance(field, models.BooleanField)
],
help_text=AttributeScheduleRule._meta.get_field("access_field").help_text,
)
class Meta:
model = AttributeScheduleRule
fields = "__all__"
class AssignedNfcCardsReportFilters(forms.Form):
has_mw_nfc_card = forms.NullBooleanField(
label="Has NFC card in MembershipWorks",
widget=forms.Select(choices=[("any", "Any"), (True, "Yes"), (False, "No")]),
)
has_access_nfc_card = forms.NullBooleanField(
label="Has NFC card in UniFi Access",
widget=forms.Select(choices=[("any", "Any"), (True, "Yes"), (False, "No")]),
)