Add a setting for if a member is allowed entry

This commit is contained in:
Tanner Collin 2021-09-16 22:27:36 +00:00
parent b4cf41edff
commit 77ce7c0f9b
4 changed files with 17 additions and 3 deletions

View File

@ -57,6 +57,7 @@ class Member(models.Model):
trotec_cert_date = models.DateField(blank=True, null=True, default=None)
paused_date = models.DateField(blank=True, null=True)
monthly_fees = models.IntegerField(default=55, blank=True, null=True)
is_allowed_entry = models.BooleanField(default=True)
history = HistoricalRecords(excluded_fields=['member_forms'])

View File

@ -184,6 +184,7 @@ class MemberSerializer(serializers.ModelSerializer):
'precix_cnc_cert_date',
'rabbit_cert_date',
'trotec_cert_date',
'is_allowed_entry',
]
def update(self, instance, validated_data):

View File

@ -435,6 +435,7 @@ class DoorViewSet(viewsets.ViewSet, List):
except models.Member.DoesNotExist:
continue
if member.paused_date: continue
if not member.is_allowed_entry: continue
active_member_cards[card.card_number] = '{} ({})'.format(
member.first_name + ' ' + member.last_name[0],
@ -476,6 +477,7 @@ class LockoutViewSet(viewsets.ViewSet, List):
except models.Member.DoesNotExist:
continue
if member.paused_date: continue
if not member.is_allowed_entry: continue
authorization = {}
authorization['id'] = member.id

View File

@ -117,7 +117,7 @@ function AdminCardDetail(props) {
export function AdminMemberCards(props) {
const { token, result, refreshResult } = props;
const cards = result.cards;
const startDimmed = Boolean(result.member.paused_date && cards.length);
const startDimmed = Boolean((result.member.paused_date || !result.member.is_allowed_entry) && cards.length);
const [dimmed, setDimmed] = useState(startDimmed);
const [input, setInput] = useState({ active_status: 'card_active' });
const [error, setError] = useState(false);
@ -127,7 +127,7 @@ export function AdminMemberCards(props) {
const { id } = useParams();
useEffect(() => {
const startDimmed = Boolean(result.member.paused_date && cards.length);
const startDimmed = Boolean((result.member.paused_date || !result.member.is_allowed_entry) && cards.length);
setDimmed(startDimmed);
}, [result.member]);
@ -260,7 +260,7 @@ export function AdminMemberCards(props) {
<Dimmer active={dimmed}>
<p>
Member paused, {cards.length} card{cards.length === 1 ? '' : 's'} ignored anyway.
Member paused or not allowed entry, {cards.length} card{cards.length === 1 ? '' : 's'} ignored anyway.
</p>
<p>
<Button size='tiny' onClick={() => setDimmed(false)}>Close</Button>
@ -448,6 +448,16 @@ export function AdminMemberForm(props) {
/>
</Form.Field>
<Form.Field>
<label>Is the member allowed entry?</label>
<Checkbox
label='Yes'
name='is_allowed_entry'
onChange={handleCheck}
checked={input.is_allowed_entry}
/>
</Form.Field>
<Form.TextArea
label={'Private Notes (shared with ' + input.preferred_name + ')'}
{...makeProps('private_notes')}