use proper url naming instead of hardcoding paths

This commit is contained in:
Nick Sweeting 2020-07-27 23:56:35 -04:00
parent b8c8c4a599
commit d70bb7980e
5 changed files with 42 additions and 22 deletions

View file

@ -6,7 +6,7 @@ from contextlib import redirect_stdout
from django.contrib import admin
from django.urls import path
from django.utils.html import format_html
from django.shortcuts import render
from django.shortcuts import render, redirect
from django.contrib.auth import get_user_model
from core.models import Snapshot
@ -103,10 +103,13 @@ class ArchiveBoxAdmin(admin.AdminSite):
def get_urls(self):
return [
path('core/snapshot/add/', self.add_view, name='add'),
path('core/snapshot/add/', self.add_view, name='Add'),
] + super().get_urls()
def add_view(self, request):
if not request.user.is_authenticated:
return redirect(f'/admin/login/?next={request.path}')
request.current_app = self.name
context = {
**self.each_context(request),