diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..cf39121 --- /dev/null +++ b/.env.example @@ -0,0 +1,2 @@ +DOMAIN=localhost +DEMO=false diff --git a/api/views.py b/api/views.py index 057ede2..0175917 100644 --- a/api/views.py +++ b/api/views.py @@ -34,14 +34,14 @@ def NewSnapshot(request): return JsonResponse({'error': 'Invalid request method'}, status=400) # Authentication - # auth_header = request.headers.get('Authorization') - # if not auth_header or not auth_header.startswith('Bearer '): - # return JsonResponse({'error': 'Invalid or missing token'}, status=401) + auth_header = request.headers.get('Authorization') + if not auth_header or not auth_header.startswith('Bearer '): + return JsonResponse({'error': 'Invalid or missing token'}, status=401) - # token = auth_header.split(' ')[1] - # tk = Token.objects.filter(token=token).first() - # if not tk: - # return JsonResponse({'error': 'Invalid or missing token'}, status=401) + token = auth_header.split(' ')[1] + tk = Token.objects.filter(token=token).first() + if not tk: + return JsonResponse({'error': 'Invalid or missing token'}, status=401) # Validation snapshot try: @@ -65,9 +65,7 @@ def NewSnapshot(request): # save_in_disk(data, tk.user) try: - # Build(data, tk.user) - user = User.objects.get(email="user@example.org") - Build(data, user) + Build(data, tk.user) except Exception: return JsonResponse({'status': 'fail'}, status=200) diff --git a/dashboard/templates/dashboard.html-bk b/dashboard/templates/dashboard.html-bk deleted file mode 100644 index 47289f0..0000000 --- a/dashboard/templates/dashboard.html-bk +++ /dev/null @@ -1,213 +0,0 @@ -{% load i18n static %} - - - -
- {% block head %} - {% block meta %} - - - - - - {% endblock %} -
- {{ c.manufacturer }}
- {{ c.model }}
- {{ c.serialNumber }}
+ {% for k, v in c.items %}
+ {% if k not in "actions,type" %}
+ {{ k }}: {{ v }}
+ {% endif %}
+ {% endfor %}
+