2024-02-23 15:55:16 -05:00
|
|
|
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__"
|
2025-01-03 21:21:31 -05:00
|
|
|
|
|
|
|
|
|
|
|
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")]),
|
|
|
|
)
|