Added basic user authentication.

This commit is contained in:
2023-08-23 17:45:39 -04:00
parent 511acab59c
commit bac5437e7e
8 changed files with 95 additions and 13 deletions

View File

@@ -6,11 +6,15 @@ from math import ceil
import filetype
# Django imports.
from django.http import HttpResponseNotFound
from django.conf import settings
from django.utils.http import urlencode
from django.shortcuts import (render,
redirect)
from django.http import HttpResponseNotFound
from django.conf import settings
from django.utils.http import urlencode
from django.contrib.auth.decorators import login_required
from django.contrib.auth import (authenticate,
login,
logout)
from django.shortcuts import (render,
redirect)
# Project imports.
from .utils import make_thumbnail
@@ -24,12 +28,9 @@ ROWS_PER_PAGE = 4
IMAGES_PER_PAGE = CELLS_PER_ROW * ROWS_PER_PAGE
###########################################################################################
# View functions. #
# Helper functions. #
###########################################################################################
def index(request):
return redirect('gallery_view_root')
def do_recursive_search(start_path, query):
"""
Gets all images and sub-directories inside the start_path whose name matches the given query,
@@ -56,6 +57,11 @@ def do_recursive_search(start_path, query):
# View functions. #
###########################################################################################
@login_required
def index(request):
return redirect('gallery_view_root')
@login_required
def gallery_view(request, path = None):
"""
Shows a list of subdirectories and image files inside the given path.