Add a setting for if a member is allowed entry
This commit is contained in:
parent
b4cf41edff
commit
77ce7c0f9b
|
@ -57,6 +57,7 @@ class Member(models.Model):
|
||||||
trotec_cert_date = models.DateField(blank=True, null=True, default=None)
|
trotec_cert_date = models.DateField(blank=True, null=True, default=None)
|
||||||
paused_date = models.DateField(blank=True, null=True)
|
paused_date = models.DateField(blank=True, null=True)
|
||||||
monthly_fees = models.IntegerField(default=55, 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'])
|
history = HistoricalRecords(excluded_fields=['member_forms'])
|
||||||
|
|
||||||
|
|
|
@ -184,6 +184,7 @@ class MemberSerializer(serializers.ModelSerializer):
|
||||||
'precix_cnc_cert_date',
|
'precix_cnc_cert_date',
|
||||||
'rabbit_cert_date',
|
'rabbit_cert_date',
|
||||||
'trotec_cert_date',
|
'trotec_cert_date',
|
||||||
|
'is_allowed_entry',
|
||||||
]
|
]
|
||||||
|
|
||||||
def update(self, instance, validated_data):
|
def update(self, instance, validated_data):
|
||||||
|
|
|
@ -435,6 +435,7 @@ class DoorViewSet(viewsets.ViewSet, List):
|
||||||
except models.Member.DoesNotExist:
|
except models.Member.DoesNotExist:
|
||||||
continue
|
continue
|
||||||
if member.paused_date: continue
|
if member.paused_date: continue
|
||||||
|
if not member.is_allowed_entry: continue
|
||||||
|
|
||||||
active_member_cards[card.card_number] = '{} ({})'.format(
|
active_member_cards[card.card_number] = '{} ({})'.format(
|
||||||
member.first_name + ' ' + member.last_name[0],
|
member.first_name + ' ' + member.last_name[0],
|
||||||
|
@ -476,6 +477,7 @@ class LockoutViewSet(viewsets.ViewSet, List):
|
||||||
except models.Member.DoesNotExist:
|
except models.Member.DoesNotExist:
|
||||||
continue
|
continue
|
||||||
if member.paused_date: continue
|
if member.paused_date: continue
|
||||||
|
if not member.is_allowed_entry: continue
|
||||||
|
|
||||||
authorization = {}
|
authorization = {}
|
||||||
authorization['id'] = member.id
|
authorization['id'] = member.id
|
||||||
|
|
|
@ -117,7 +117,7 @@ function AdminCardDetail(props) {
|
||||||
export function AdminMemberCards(props) {
|
export function AdminMemberCards(props) {
|
||||||
const { token, result, refreshResult } = props;
|
const { token, result, refreshResult } = props;
|
||||||
const cards = result.cards;
|
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 [dimmed, setDimmed] = useState(startDimmed);
|
||||||
const [input, setInput] = useState({ active_status: 'card_active' });
|
const [input, setInput] = useState({ active_status: 'card_active' });
|
||||||
const [error, setError] = useState(false);
|
const [error, setError] = useState(false);
|
||||||
|
@ -127,7 +127,7 @@ export function AdminMemberCards(props) {
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
|
|
||||||
useEffect(() => {
|
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);
|
setDimmed(startDimmed);
|
||||||
}, [result.member]);
|
}, [result.member]);
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ export function AdminMemberCards(props) {
|
||||||
|
|
||||||
<Dimmer active={dimmed}>
|
<Dimmer active={dimmed}>
|
||||||
<p>
|
<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>
|
||||||
<p>
|
<p>
|
||||||
<Button size='tiny' onClick={() => setDimmed(false)}>Close</Button>
|
<Button size='tiny' onClick={() => setDimmed(false)}>Close</Button>
|
||||||
|
@ -448,6 +448,16 @@ export function AdminMemberForm(props) {
|
||||||
/>
|
/>
|
||||||
</Form.Field>
|
</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
|
<Form.TextArea
|
||||||
label={'Private Notes (shared with ' + input.preferred_name + ')'}
|
label={'Private Notes (shared with ' + input.preferred_name + ')'}
|
||||||
{...makeProps('private_notes')}
|
{...makeProps('private_notes')}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user