Добавил заглушки, чтобы смотреть статистику по прослушиванию в будущем
This commit is contained in:
@@ -2,7 +2,10 @@ from typing import Any
|
||||
|
||||
from django.contrib import admin
|
||||
from django.http import HttpRequest
|
||||
from django.http import HttpResponse
|
||||
from django.urls import path
|
||||
from django.urls import reverse
|
||||
from django.shortcuts import render
|
||||
from django.utils.html import format_html
|
||||
|
||||
from music.models import Track
|
||||
@@ -114,3 +117,15 @@ class MusicLogAdmin(admin.ModelAdmin):
|
||||
search_fields = ("track__title", "track__album__artist__name", "track__album__name")
|
||||
list_filter = ("played_at",)
|
||||
readonly_fields = ("track", "played_at")
|
||||
|
||||
change_list_template = "admin/musiclog/change_list.html"
|
||||
|
||||
def get_urls(self):
|
||||
urls = super().get_urls()
|
||||
custom_urls = [
|
||||
path("statistics/", self.admin_site.admin_view(self.get_statistic_view), name="musiclog_statistics"),
|
||||
]
|
||||
return custom_urls + urls
|
||||
|
||||
def get_statistic_view(self, request: HttpRequest) -> HttpResponse:
|
||||
return render(request, "admin/musiclog/statistics.html")
|
||||
10
music_storage/templates/admin/musiclog/change_list.html
Normal file
10
music_storage/templates/admin/musiclog/change_list.html
Normal file
@@ -0,0 +1,10 @@
|
||||
{% extends "admin/change_list.html" %}
|
||||
|
||||
{% block object-tools-items %}
|
||||
{{ block.super }}
|
||||
<li>
|
||||
<a href="{% url 'admin:musiclog_statistics' %}" class="button">
|
||||
statistics
|
||||
</a>
|
||||
</li>
|
||||
{% endblock %}
|
||||
13
music_storage/templates/admin/musiclog/statistics.html
Normal file
13
music_storage/templates/admin/musiclog/statistics.html
Normal file
@@ -0,0 +1,13 @@
|
||||
{% extends "admin/base_site.html" %}
|
||||
{% load i18n admin_urls static admin_list %}
|
||||
|
||||
|
||||
{% block title %}{% translate "Music Log Statistics" %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<button onclick="history.back()">Back</button>
|
||||
<h1>{% translate "Music Log Statistics" %}</h1>
|
||||
<div>
|
||||
<canvas id="musicLogChart" width="800" height="400"></canvas>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user