From 2fd1d52a71af336dcdcbed5ff95986d31d67d0ae Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Fri, 7 Feb 2020 09:53:39 +0000 Subject: [PATCH] Simplify /door/ route card listing --- apiserver/apiserver/api/views.py | 8 +++----- apiserver/docs/source/api.rst | 19 +++---------------- apiserver/docs/source/dev.rst | 1 - 3 files changed, 6 insertions(+), 22 deletions(-) diff --git a/apiserver/apiserver/api/views.py b/apiserver/apiserver/api/views.py index 36520c8..70cf224 100644 --- a/apiserver/apiserver/api/views.py +++ b/apiserver/apiserver/api/views.py @@ -288,15 +288,13 @@ class DoorViewSet(viewsets.ViewSet, List): cards = models.Card.objects.filter(active_status='card_active') active_member_cards = {} - # format cards to match Emrah's conversion script, fix later for card in cards: member = get_object_or_404(models.Member, id=card.member_id) if member.paused_date: continue - active_member_cards[card.card_number] = dict( - name=member.first_name + ' ' + member.last_name[0], - id=member.id, - enabled=True, + active_member_cards[card.card_number] = '{} ({})'.format( + member.first_name + ' ' + member.last_name[0], + member.id, ) return Response(active_member_cards) diff --git a/apiserver/docs/source/api.rst b/apiserver/docs/source/api.rst index abccbdf..4461559 100644 --- a/apiserver/docs/source/api.rst +++ b/apiserver/docs/source/api.rst @@ -855,9 +855,6 @@ Door List all active cards of unpaused members. - The json dict format is to match the current front door controller's script - and will likely be changed in the future. - No authentication required. **Example response** @@ -867,22 +864,12 @@ Door .. sourcecode:: json { - "0000001234": { - "name": "Tanner C", - "id": 1685, - "enabled": true - }, - "000000ABCD": { - "name": "Tanner C", - "id": 1685, - "enabled": true - } + "0000001234": "Tanner C (1685)", + "000000ABCD": "Tanner C (1685)", } :json key: The dict keys are the card numbers. - :json int id: Member's ID. - :json name: Member's name. - :json boolean enabled: Always true. + :json value: Member's name and ID. .. http:post:: /door/(card_number)/seen/ diff --git a/apiserver/docs/source/dev.rst b/apiserver/docs/source/dev.rst index 2664128..d18b1e4 100644 --- a/apiserver/docs/source/dev.rst +++ b/apiserver/docs/source/dev.rst @@ -9,7 +9,6 @@ Install dependencies: .. sourcecode:: bash - # Misc: $ sudo apt update $ sudo apt install memcached