GET authorized cards for each MAC
This commit is contained in:
parent
790725c29e
commit
bd44438277
|
@ -124,6 +124,24 @@ Example response:
|
|||
}
|
||||
```
|
||||
|
||||
#### GET `/cards/[MAC]/`
|
||||
|
||||
Returns all card numbers authorized to use a machine based on MAC address.
|
||||
|
||||
Card numbers are on one line separated by a comma.
|
||||
|
||||
Example request:
|
||||
|
||||
```
|
||||
curl http://tools-auth.protospace.ca/cards/2C3AE843A15F/
|
||||
```
|
||||
|
||||
Example response:
|
||||
|
||||
```
|
||||
"00000B8567,00000A4123,00000C9999"
|
||||
```
|
||||
|
||||
### For authenticated users
|
||||
|
||||
#### GET `/user/`
|
||||
|
|
|
@ -76,6 +76,13 @@ def login(request):
|
|||
|
||||
return Response({'token': token.key}, status=status.HTTP_200_OK)
|
||||
|
||||
@api_view(["GET"])
|
||||
def cards(request, mac):
|
||||
cards = models.Card.objects.all().filter(profile__authorized_tools__mac=mac)
|
||||
card_numbers = [card.number for card in cards]
|
||||
|
||||
return Response(','.join(card_numbers), status=status.HTTP_200_OK)
|
||||
|
||||
@api_view(["PUT"])
|
||||
@permission_classes((IsLockoutAdmin,))
|
||||
def update_cards(request):
|
||||
|
|
|
@ -34,6 +34,7 @@ urlpatterns = [
|
|||
url(r'^admin/', admin.site.urls),
|
||||
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
|
||||
url(r'^login/', views.login),
|
||||
url(r'^cards/(?P<mac>.*)/', views.cards),
|
||||
url(r'^update-cards/', views.update_cards)
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user