diff --git a/apiserver/apiserver/api/models.py b/apiserver/apiserver/api/models.py index 14a3cb3..4d987c2 100644 --- a/apiserver/apiserver/api/models.py +++ b/apiserver/apiserver/api/models.py @@ -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']) diff --git a/apiserver/apiserver/api/serializers.py b/apiserver/apiserver/api/serializers.py index c3fb24d..bd4bbbe 100644 --- a/apiserver/apiserver/api/serializers.py +++ b/apiserver/apiserver/api/serializers.py @@ -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): diff --git a/apiserver/apiserver/api/views.py b/apiserver/apiserver/api/views.py index ac98466..9f2e1e3 100644 --- a/apiserver/apiserver/api/views.py +++ b/apiserver/apiserver/api/views.py @@ -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 diff --git a/webclient/src/AdminMembers.js b/webclient/src/AdminMembers.js index fc6ed4f..27dddf0 100644 --- a/webclient/src/AdminMembers.js +++ b/webclient/src/AdminMembers.js @@ -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) {

- 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.

@@ -448,6 +448,16 @@ export function AdminMemberForm(props) { /> + + + + +