Compare commits
1 Commits
main
...
dev/music-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b9302fee6 |
17
README.md
17
README.md
@@ -1,18 +1,3 @@
|
|||||||
# music-storage
|
# music-storage
|
||||||
|
|
||||||
Мини сервис для хранения/загрузки/воспроизведении песен
|
Мини сервис для хранения/загрузки/воспроизведении песен
|
||||||
|
|
||||||
Пример сервиса: https://music.nervy.pro
|
|
||||||
|
|
||||||
|
|
||||||
## environment
|
|
||||||
|
|
||||||
- переименовать `music_storage/.env.example` -> `music_storage/.env`
|
|
||||||
- заполнить `.env`
|
|
||||||
|
|
||||||
## Запуск
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd music_storage
|
|
||||||
uv run python manage.py runserver
|
|
||||||
```
|
|
||||||
@@ -2,7 +2,10 @@ from typing import Any
|
|||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.http import HttpRequest
|
from django.http import HttpRequest
|
||||||
|
from django.http import HttpResponse
|
||||||
|
from django.urls import path
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
from django.shortcuts import render
|
||||||
from django.utils.html import format_html
|
from django.utils.html import format_html
|
||||||
|
|
||||||
from music.models import Track
|
from music.models import Track
|
||||||
@@ -114,3 +117,15 @@ class MusicLogAdmin(admin.ModelAdmin):
|
|||||||
search_fields = ("track__title", "track__album__artist__name", "track__album__name")
|
search_fields = ("track__title", "track__album__artist__name", "track__album__name")
|
||||||
list_filter = ("played_at",)
|
list_filter = ("played_at",)
|
||||||
readonly_fields = ("track", "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