42 lines
1.1 KiB
Python
42 lines
1.1 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__"
|