diff --git a/docs/media_files_handling.md b/docs/media_files_handling.md index 40551bc9..c983101f 100644 --- a/docs/media_files_handling.md +++ b/docs/media_files_handling.md @@ -20,54 +20,10 @@ Visible in the django admin. Images that belong to the content and are managed by the content editors in the CMS. -### user images: - -Images that are uploaded by the users. Therefore not visible in the CMS. Visible in the django admin. - -## Static files - -These files are publicly served on S3. - -## Content documents - -These files are part of the content. Such as a pdf thas cointains additional information to a course. -These files are not publicly available. The content files are uploaded by the editors in the wagtail cms. - -https://www.hacksoft.io/blog/direct-to-s3-file-upload-with-django - -Django handles the permissions to these files. Via a view django checks if the user has permissions to access the file, -and gerates a temporary url that is valid for a limited time. Still the documents are served by django. This done for -usability reasons. The user sees the url mydomain.com/media/documents/ and not a url to S3. Therefore the -user can share the url with other users. (still they need to login and have the permissions to access the file) - -The downside of this is that the django server processes these files. (could be circumvented by django-sendfile). - -![](./assets/files-presign.png) - -- These Files are handled stored as wagtail documents. As a model and the file itself is stored in S3. - -### Frontend access to content documents - -For the frontend django generates a fixed url per file /media/documents/ - -When the frontend requests this file, django checks if the user has permissions to access the file. -If so, django generates a temporary url that is valid for a limited time. Then sends a redirect to the frontend. - -In this waz the frontend does not need to know about the permissions. Content grapql can be cached if needed and urls -can be shared by the users. - -content_documents -user_documents - -public files - ## User documents -- User uploaded files are stored in S3. but the permissions is handled by django. Same process as content files. - -Same process as content files. But the url is /media/user-uploads/ -And the files are not managed by Wagtail. Due to another model, they are not visible to the user in the CMS. +User documents and images hare handled by uploadcare. In the database we oly have the url. ## Content images -Content Images are served directly from S3. The permissions are handled by dja +Content Images are served directly from S3. The permissions are handled by django. Request to django are checked and redirected to the S3 bucket. diff --git a/local-setup-for-cypress-tests.sh b/local-setup-for-cypress-tests.sh deleted file mode 100755 index 43f4ca1f..00000000 --- a/local-setup-for-cypress-tests.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -#!/bin/bash -export SECRET_KEY=abcd1234 -export DATABASE_HOST=localhost -export DATABASE_USER=postgres -export PGPASSWORD=postgres -export DATABASE_NAME=skillbox_test_cypress -export DATABASE_PORT=5432 -export DATABASE_URL=postgres://$DATABASE_USER:$PGPASSWORD@$DATABASE_HOST:$DATABASE_PORT/$DATABASE_NAME -export DEBUG=True -export USE_AWS=False -export SERVE_VIA_WEBPACK=False -export OAUTH_CLIENT_ID=1111111-222222-333-3444444 -export OAUTH_CLIENT_SECRET=Abcd1234! -export OAUTH_ACCESS_TOKEN_URL=https://hepverlag-cms.grape.novu.ch/oauth/token -export OAUTH_AUTHORIZE_URL=https://hepverlag-cms.grape.novu.ch/oauth/authorize -export OAUTH_API_BASE_URL=https://hepverlag-cms.grape.novu.ch/ -export OAUTH_LOCAL_REDIRECT_URI=http://localhost:8000/api/oauth/callback/ -export NODE_OPTIONS=--max_old_space_size=3072 - -export DATABASE_HOST=localhost -export DATABASE_PORT=5432 -export DATABASE_URL=postgres://$DATABASE_USER:$PG_PASSWORD@$DATABASE_HOST:$DATABASE_PORT/$DATABASE_NAME -psql -U $DATABASE_USER -h $DATABASE_HOST -c "drop database $DATABASE_NAME" - -#npm install --prefix client -#npm run "install:cypress" --prefix client -psql -U $DATABASE_USER -h $DATABASE_HOST -c "create database $DATABASE_NAME" -python server/manage.py dummy_data -python server/manage.py runserver & -npm run dev --prefix client & -cd client -/node_modules/.bin/cypress run diff --git a/server/core/urls.py b/server/core/urls.py index 014892c5..9369a76a 100644 --- a/server/core/urls.py +++ b/server/core/urls.py @@ -1,14 +1,13 @@ from django.conf import settings -from django.urls import path, re_path, include from django.conf.urls.static import static from django.contrib import admin from django.contrib.auth.decorators import login_required +from django.urls import path, re_path, include from django.views.generic import RedirectView -from wagtail.admin import urls as wagtailadmin_urls from wagtail import urls as wagtail_urls +from wagtail.admin import urls as wagtailadmin_urls from wagtail.documents import urls as wagtaildocs_urls from wagtail.images.views.serve import ServeView - from wagtailautocomplete.urls.admin import urlpatterns as autocomplete_admin_urls from core import views @@ -19,14 +18,14 @@ urlpatterns = [ re_path(r"^guru/", admin.site.urls), re_path(r"^statistics/", include("statistics.urls", namespace="statistics")), # wagtail - re_path(r'^api/images/([^/]*)/(\d*)/([^/]*)/[^/]*$', login_required(ServeView.as_view(action='redirect')), name='wagtailimages_serve'), + re_path(r'^api/images/([^/]*)/(\d*)/([^/]*)/[^/]*$', login_required(ServeView.as_view(action='redirect')), + name='wagtailimages_serve'), re_path(r"^cms/autocomplete/", include(autocomplete_admin_urls)), re_path(r"^cms/pages/(\d+)/$", override_wagtailadmin_explore_default_ordering), re_path(r"^cms/", include(wagtailadmin_urls)), re_path(r"^documents/", include(wagtaildocs_urls)), - # graphql backend re_path(r"^api/", include("api.urls", namespace="api")),