diff --git a/.gitignore b/.gitignore index b6edfe9..aa6d288 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -/static/ +settings.yml +static/ +server/__pycache__ diff --git a/settings.yml b/example-settings.yml similarity index 86% rename from settings.yml rename to example-settings.yml index 0e2918b..a76c992 100644 --- a/settings.yml +++ b/example-settings.yml @@ -1,6 +1,11 @@ dependencies: - djangoldp_notifications + - djangoldp_account + - djangoldp_notification + - django-webpush + ldppackages: + - djangoldp_account + - djangoldp_notification server: DEBUG: true @@ -11,6 +16,7 @@ server: default: ENGINE: django.db.backends.postgresql_psycopg2 NAME: djangoldp + USER: postgres LDP_RDF_CONTEXT: https://cdn.happy-dev.fr/owl/hdcontext.jsonld ROOT_URLCONF: server.urls STATIC_ROOT: static diff --git a/server/__pycache__/__init__.cpython-37.pyc b/server/__pycache__/__init__.cpython-37.pyc deleted file mode 100644 index abe0f43..0000000 Binary files a/server/__pycache__/__init__.cpython-37.pyc and /dev/null differ diff --git a/server/__pycache__/__init__.cpython-39.pyc b/server/__pycache__/__init__.cpython-39.pyc deleted file mode 100644 index b995e70..0000000 Binary files a/server/__pycache__/__init__.cpython-39.pyc and /dev/null differ diff --git a/server/__pycache__/admin.cpython-37.pyc b/server/__pycache__/admin.cpython-37.pyc deleted file mode 100644 index 907f3d0..0000000 Binary files a/server/__pycache__/admin.cpython-37.pyc and /dev/null differ diff --git a/server/__pycache__/admin.cpython-39.pyc b/server/__pycache__/admin.cpython-39.pyc deleted file mode 100644 index 0de04df..0000000 Binary files a/server/__pycache__/admin.cpython-39.pyc and /dev/null differ diff --git a/server/__pycache__/models.cpython-37.pyc b/server/__pycache__/models.cpython-37.pyc deleted file mode 100644 index cda65b6..0000000 Binary files a/server/__pycache__/models.cpython-37.pyc and /dev/null differ diff --git a/server/__pycache__/models.cpython-39.pyc b/server/__pycache__/models.cpython-39.pyc deleted file mode 100644 index 8ccbc06..0000000 Binary files a/server/__pycache__/models.cpython-39.pyc and /dev/null differ diff --git a/server/__pycache__/urls.cpython-37.pyc b/server/__pycache__/urls.cpython-37.pyc deleted file mode 100644 index 9244a65..0000000 Binary files a/server/__pycache__/urls.cpython-37.pyc and /dev/null differ diff --git a/server/__pycache__/urls.cpython-39.pyc b/server/__pycache__/urls.cpython-39.pyc deleted file mode 100644 index 7282c4e..0000000 Binary files a/server/__pycache__/urls.cpython-39.pyc and /dev/null differ diff --git a/server/__pycache__/views.cpython-37.pyc b/server/__pycache__/views.cpython-37.pyc deleted file mode 100644 index 966eb14..0000000 Binary files a/server/__pycache__/views.cpython-37.pyc and /dev/null differ diff --git a/server/__pycache__/wsgi.cpython-37.pyc b/server/__pycache__/wsgi.cpython-37.pyc deleted file mode 100644 index ba8cd31..0000000 Binary files a/server/__pycache__/wsgi.cpython-37.pyc and /dev/null differ diff --git a/server/__pycache__/wsgi.cpython-39.pyc b/server/__pycache__/wsgi.cpython-39.pyc deleted file mode 100644 index 0301e00..0000000 Binary files a/server/__pycache__/wsgi.cpython-39.pyc and /dev/null differ diff --git a/server/migrations/__pycache__/0001_initial.cpython-39.pyc b/server/migrations/__pycache__/0001_initial.cpython-39.pyc index 3223ca9..af2ad08 100644 Binary files a/server/migrations/__pycache__/0001_initial.cpython-39.pyc and b/server/migrations/__pycache__/0001_initial.cpython-39.pyc differ diff --git a/server/migrations/__pycache__/0002_auto_20210315_1108.cpython-39.pyc b/server/migrations/__pycache__/0002_auto_20210315_1108.cpython-39.pyc index 72cf4a6..c9321a7 100644 Binary files a/server/migrations/__pycache__/0002_auto_20210315_1108.cpython-39.pyc and b/server/migrations/__pycache__/0002_auto_20210315_1108.cpython-39.pyc differ diff --git a/server/migrations/__pycache__/0003_delete_todo.cpython-39.pyc b/server/migrations/__pycache__/0003_delete_todo.cpython-39.pyc index 39d2337..8fe62ba 100644 Binary files a/server/migrations/__pycache__/0003_delete_todo.cpython-39.pyc and b/server/migrations/__pycache__/0003_delete_todo.cpython-39.pyc differ diff --git a/server/migrations/__pycache__/__init__.cpython-39.pyc b/server/migrations/__pycache__/__init__.cpython-39.pyc index 6a40b74..56863a5 100644 Binary files a/server/migrations/__pycache__/__init__.cpython-39.pyc and b/server/migrations/__pycache__/__init__.cpython-39.pyc differ diff --git a/server/views.py b/server/views.py index 2a434f6..c51797f 100644 --- a/server/views.py +++ b/server/views.py @@ -3,7 +3,7 @@ from django.views.decorators.http import require_GET from django.http.response import JsonResponse, HttpResponse from django.views.decorators.http import require_GET, require_POST from django.shortcuts import render, get_object_or_404 -from django.contrib.auth.models import User +from djangoldp_account.models import LDPUser from django.views.decorators.csrf import csrf_exempt from webpush import send_user_notification from django.conf import settings @@ -27,10 +27,10 @@ def send_push(request): return JsonResponse(status=400, data={"message": "Invalid data format"}) user_id = data['id'] - user = get_object_or_404(User, pk=user_id) + user = get_object_or_404(LDPUser, pk=user_id) payload = {'head': data['head'], 'body': data['body']} send_user_notification(user=user, payload=payload, ttl=1000) return JsonResponse(status=200, data={"message": "Web push successful"}) except TypeError: - return JsonResponse(status=500, data={"message": "An error occurred"}) \ No newline at end of file + return JsonResponse(status=500, data={"message": "An error occurred"})