parent
27665d1712
commit
a802095ed7
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JavaScriptSettings">
|
||||
<option name="languageLevel" value="ES6" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6" project-jdk-type="Python SDK" />
|
||||
</project>
|
||||
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/music.iml" filepath="$PROJECT_DIR$/.idea/music.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="django" name="Django">
|
||||
<configuration>
|
||||
<option name="rootFolder" value="$MODULE_DIR$" />
|
||||
<option name="settingsModule" value="music/settings.py" />
|
||||
<option name="manageScript" value="$MODULE_DIR$/manage.py" />
|
||||
<option name="environment" value="<map/>" />
|
||||
<option name="doNotUseTestRunner" value="false" />
|
||||
<option name="trackFilePattern" value="migrations" />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="TemplatesService">
|
||||
<option name="TEMPLATE_CONFIGURATION" value="Django" />
|
||||
<option name="TEMPLATE_FOLDERS">
|
||||
<list>
|
||||
<option value="$MODULE_DIR$/../music\templates" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="TestRunnerService">
|
||||
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
|
||||
</component>
|
||||
</module>
|
||||
@ -0,0 +1,171 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="05bf9cdd-8760-4739-880a-b4cd3f04cfab" name="Default Changelist" comment="" />
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="FileEditorManager">
|
||||
<leaf>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/music/settings.py">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/music/urls.py">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/manage.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-2">
|
||||
<folding>
|
||||
<element signature="e#84#93#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
</leaf>
|
||||
</component>
|
||||
<component name="ProjectFrameBounds" extendedState="7">
|
||||
<option name="x" value="1054" />
|
||||
<option name="width" value="879" />
|
||||
<option name="height" value="1000" />
|
||||
</component>
|
||||
<component name="ProjectView">
|
||||
<navigator proportions="" version="1">
|
||||
<foldersAlwaysOnTop value="true" />
|
||||
</navigator>
|
||||
<panes>
|
||||
<pane id="Scope" />
|
||||
<pane id="ProjectPane">
|
||||
<subPane>
|
||||
<expand>
|
||||
<path>
|
||||
<item name="music" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="music" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="music" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="music" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="music" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
</expand>
|
||||
<select />
|
||||
</subPane>
|
||||
</pane>
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="WebServerToolWindowFactoryState" value="false" />
|
||||
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
|
||||
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
|
||||
</component>
|
||||
<component name="RunDashboard">
|
||||
<option name="ruleStates">
|
||||
<list>
|
||||
<RuleState>
|
||||
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
|
||||
</RuleState>
|
||||
<RuleState>
|
||||
<option name="name" value="StatusDashboardGroupingRule" />
|
||||
</RuleState>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="RunManager">
|
||||
<configuration name="music" type="Python.DjangoServer" factoryName="Django server">
|
||||
<module name="music" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="" />
|
||||
<option name="IS_MODULE_SDK" value="false" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="launchJavascriptDebuger" value="false" />
|
||||
<option name="port" value="8000" />
|
||||
<option name="host" value="" />
|
||||
<option name="additionalOptions" value="" />
|
||||
<option name="browserUrl" value="" />
|
||||
<option name="runTestServer" value="false" />
|
||||
<option name="runNoReload" value="false" />
|
||||
<option name="useCustomRunCommand" value="false" />
|
||||
<option name="customRunCommand" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
<component name="SvnConfiguration">
|
||||
<configuration />
|
||||
</component>
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="05bf9cdd-8760-4739-880a-b4cd3f04cfab" name="Default Changelist" comment="" />
|
||||
<created>1568122067539</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1568122067539</updated>
|
||||
<workItem from="1568122069690" duration="1078000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TimeTrackingManager">
|
||||
<option name="totallyTimeSpent" value="1078000" />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="-8" y="-8" width="1936" height="1056" extended-state="7" />
|
||||
<editor active="true" />
|
||||
<layout>
|
||||
<window_info id="Favorites" side_tool="true" />
|
||||
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.25" />
|
||||
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
|
||||
<window_info anchor="bottom" id="Docker" show_stripe_button="false" />
|
||||
<window_info anchor="bottom" id="Database Changes" />
|
||||
<window_info anchor="bottom" id="Version Control" />
|
||||
<window_info anchor="bottom" id="Python Console" />
|
||||
<window_info active="true" anchor="bottom" id="Terminal" visible="true" weight="0.32936078" />
|
||||
<window_info anchor="bottom" id="Event Log" side_tool="true" />
|
||||
<window_info anchor="bottom" id="Message" order="0" />
|
||||
<window_info anchor="bottom" id="Find" order="1" />
|
||||
<window_info anchor="bottom" id="Run" order="2" />
|
||||
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
|
||||
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
|
||||
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
|
||||
<window_info anchor="bottom" id="TODO" order="6" />
|
||||
<window_info anchor="right" id="SciView" />
|
||||
<window_info anchor="right" id="Database" />
|
||||
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
|
||||
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
|
||||
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
|
||||
</layout>
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
<option name="version" value="1" />
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/music/settings.py">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/music/urls.py">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/manage.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-2">
|
||||
<folding>
|
||||
<element signature="e#84#93#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</component>
|
||||
</project>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class CommentConfig(AppConfig):
|
||||
name = 'comment'
|
||||
Binary file not shown.
@ -0,0 +1,3 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
@ -0,0 +1,124 @@
|
||||
{% extends "title_base.html" %}
|
||||
{% load staticfiles %}
|
||||
|
||||
{% block header_extends %}
|
||||
<link type="image/x-icon" rel="shortcut icon" href="{% static 'favicon.ico' %}">
|
||||
<link type="text/css" rel="stylesheet" href="{% static 'css/common.css' %}">
|
||||
<link type="text/css" rel="stylesheet" href="{% static 'css/comment.css' %}">
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<body class="review">
|
||||
<div class="header">
|
||||
<a href="/" class="logo" title="首页"><img alt="易点音乐" src="{% static 'image/logo.png' %}"></a>
|
||||
<div class="search-box">
|
||||
<form id="searchForm" action="{% url 'search' 1 %}" method="post" target="_blank">
|
||||
{% csrf_token %}
|
||||
<div class="search-keyword">
|
||||
<input id="kword" name="kword" type="text" class="keyword" maxlength="120" placeholder="音乐节" />
|
||||
</div>
|
||||
<input id="subSerch" type="submit" class="search-button" value="搜 索" />
|
||||
</form>
|
||||
<div id="suggest" class="search-suggest"></div>
|
||||
<div class="search-hot-words">
|
||||
{% for song in search_song %}
|
||||
<a target="play" href="{% url 'play' song.song.song_id %}" >{{ song.song.song_name }}</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div><!--end header-->
|
||||
<div class="nav-box">
|
||||
<div class="nav-box-inner">
|
||||
<ul class="nav clearfix">
|
||||
<li><a href="/">首页</a></li>
|
||||
<li><a href="{% url 'ranking' %}" target="_blank">歌曲排行</a></li>
|
||||
<li><a href="{% url 'home' 1 %}" target="_blank">用户中心</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div><!--end nav-box-->
|
||||
<div class="wrapper">
|
||||
<div class="breadcrumb">
|
||||
<a href="/">首页</a> >
|
||||
<a href="{% url 'play' song_id %}" target="_self">{{song_name}}</a> >
|
||||
<span>点评</span>
|
||||
</div>
|
||||
<div class="page-title" id="currentSong"></div>
|
||||
</div>
|
||||
<div class="wrapper">
|
||||
<div class="section">
|
||||
<div class="section-header"><h3 class="section-title">网友点评</h3></div>
|
||||
<div class="section-content comments-score-new review-comments-score clearfix">
|
||||
<div class="clearfix">
|
||||
|
||||
<!--点评框-->
|
||||
<div class="comments-box">
|
||||
<div class="comments-box-title">我要点评<<{{ song_name }}>></div>
|
||||
<div class="comments-default-score clearfix"></div>
|
||||
<form action="" method="post" id="usrform">
|
||||
{% csrf_token %}
|
||||
<div class="writebox">
|
||||
<textarea name="comment" form="usrform"></textarea>
|
||||
</div>
|
||||
<div class="comments-box-button clearfix">
|
||||
<input type="submit" value="发布" class="_j_cc_post_entry cc-post-entry" id="scoreBtn">
|
||||
<div data-role="user-login" class="_j_cc_post_login"></div>
|
||||
</div>
|
||||
<div id="scoreTips2" style="padding-top:10px;"></div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="wrapper clearfix">
|
||||
<div class="content">
|
||||
<div id="J_CommentList">
|
||||
<ul class="comment-list">
|
||||
{% for item in contacts.object_list %}
|
||||
<li class="comment-item ">
|
||||
<div class="comments-user">
|
||||
<span class="face">
|
||||
<img src="{% static 'image/user.jpg' %}" width="60" height="60">
|
||||
</span>
|
||||
</div>
|
||||
<div class="comments-list-content">
|
||||
<div class="single-score clearfix">
|
||||
<span class="date">{{ item.comment_date }}</span>
|
||||
<div><span class="score">{{ item.comment_user }}</span></div>
|
||||
</div>
|
||||
<!--comments-content-->
|
||||
<div class="comments-content">
|
||||
<div class="J_CommentContent comment-height-limit">
|
||||
<div class="content-inner">
|
||||
<div class="comments-words">
|
||||
<p>{{ item.comment_text }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<div class="page-box">
|
||||
<div class="pagebar" id="pageBar">
|
||||
{% if contacts.has_previous %}
|
||||
<a href="{% url 'comment' song_id %}?page={{ contacts.previous_page_number }}" class="prev" target="_self"><i></i>上一页</a>
|
||||
{% endif %}
|
||||
{% for page in contacts.paginator.page_range %}
|
||||
{% if contacts.number == page %}
|
||||
<span class="sel">{{ page }}</span>
|
||||
{% else %}
|
||||
<a href="{% url 'comment' song_id %}?page={{ page }}" target="_self">{{ page }}</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if contacts.has_next %}
|
||||
<a href="{% url 'comment' song_id %}?page={{ contacts.next_page_number }}" class="next" target="_self">下一页<i></i></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@ -0,0 +1,20 @@
|
||||
"""music URL Configuration
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/2.0/topics/http/urls/
|
||||
Examples:
|
||||
Function views
|
||||
1. Add an import: from my_app import views
|
||||
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
||||
Class-based views
|
||||
1. Add an import: from other_app.views import Home
|
||||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
||||
Including another URLconf
|
||||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.urls import path
|
||||
from . import views
|
||||
urlpatterns = [
|
||||
path('<int:song_id>.html', views.commentView, name='comment'),
|
||||
]
|
||||
@ -0,0 +1,16 @@
|
||||
from django.apps import AppConfig
|
||||
import os
|
||||
import pymysql
|
||||
pymysql.install_as_MySQLdb()
|
||||
# 修改app在Admin后台显示名称
|
||||
# default_app_config的值来自apps.py的类名
|
||||
default_app_config = 'index.IndexConfig'
|
||||
|
||||
# 获取当前app的命名
|
||||
def get_current_app_name(_file):
|
||||
return os.path.split(os.path.dirname(_file))[-1]
|
||||
|
||||
# 重写类IndexConfig
|
||||
class IndexConfig(AppConfig):
|
||||
name = get_current_app_name(__file__)
|
||||
verbose_name = '网站首页'
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class IndexConfig(AppConfig):
|
||||
name = 'index'
|
||||
@ -0,0 +1,75 @@
|
||||
# Generated by Django 2.2.5 on 2019-09-11 07:37
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Label',
|
||||
fields=[
|
||||
('label_id', models.AutoField(primary_key=True, serialize=False, verbose_name='序号')),
|
||||
('label_name', models.CharField(max_length=10, verbose_name='分类标签')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': '歌曲分类',
|
||||
'verbose_name_plural': '歌曲分类',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Song',
|
||||
fields=[
|
||||
('song_id', models.AutoField(primary_key=True, serialize=False, verbose_name='序号')),
|
||||
('song_name', models.CharField(max_length=50, verbose_name='歌名')),
|
||||
('song_singer', models.CharField(max_length=50, verbose_name='歌手')),
|
||||
('song_time', models.CharField(max_length=10, verbose_name='时长')),
|
||||
('song_album', models.CharField(max_length=50, verbose_name='专辑')),
|
||||
('song_languages', models.CharField(max_length=20, verbose_name='语种')),
|
||||
('song_type', models.CharField(max_length=20, verbose_name='类型')),
|
||||
('song_release', models.CharField(max_length=20, verbose_name='发行时间')),
|
||||
('song_img', models.CharField(max_length=20, verbose_name='歌曲图片')),
|
||||
('song_lyrics', models.CharField(default='暂无歌词', max_length=50, verbose_name='歌词')),
|
||||
('song_file', models.CharField(max_length=50, verbose_name='歌曲文件')),
|
||||
('label', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='index.Label', verbose_name='歌名分类')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': '歌曲信息',
|
||||
'verbose_name_plural': '歌曲信息',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Dynamic',
|
||||
fields=[
|
||||
('dynamic_id', models.AutoField(primary_key=True, serialize=False, verbose_name='序号')),
|
||||
('dynamic_plays', models.IntegerField(verbose_name='播放次数')),
|
||||
('dynamic_search', models.IntegerField(verbose_name='搜索次数')),
|
||||
('dynamic_down', models.IntegerField(verbose_name='下载次数')),
|
||||
('song', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='index.Song', verbose_name='歌名')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': '歌曲动态',
|
||||
'verbose_name_plural': '歌曲动态',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Comment',
|
||||
fields=[
|
||||
('comment_id', models.AutoField(primary_key=True, serialize=False, verbose_name='序号')),
|
||||
('comment_text', models.CharField(max_length=500, verbose_name='内容')),
|
||||
('comment_user', models.CharField(max_length=20, verbose_name='用户')),
|
||||
('comment_date', models.CharField(max_length=50, verbose_name='日期')),
|
||||
('song', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='index.Song', verbose_name='歌名')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': '歌曲评论',
|
||||
'verbose_name_plural': '歌曲评论',
|
||||
},
|
||||
),
|
||||
]
|
||||
Binary file not shown.
Binary file not shown.
@ -0,0 +1,58 @@
|
||||
from django.db import models
|
||||
|
||||
# 歌曲分类表label
|
||||
class Label(models.Model):
|
||||
label_id = models.AutoField('序号', primary_key=True)
|
||||
label_name = models.CharField('分类标签', max_length=10)
|
||||
def __str__(self):
|
||||
return self.label_name
|
||||
class Meta:
|
||||
# 设置Admin界面的显示内容
|
||||
verbose_name = '歌曲分类'
|
||||
verbose_name_plural = '歌曲分类'
|
||||
|
||||
# 歌曲信息表song
|
||||
class Song(models.Model):
|
||||
song_id = models.AutoField('序号', primary_key=True)
|
||||
song_name = models.CharField('歌名', max_length=50)
|
||||
song_singer = models.CharField('歌手', max_length=50)
|
||||
song_time = models.CharField('时长', max_length=10)
|
||||
song_album = models.CharField('专辑', max_length=50)
|
||||
song_languages = models.CharField('语种', max_length=20)
|
||||
song_type = models.CharField('类型', max_length=20)
|
||||
song_release = models.CharField('发行时间', max_length=20)
|
||||
song_img = models.CharField('歌曲图片', max_length=20)
|
||||
song_lyrics = models.CharField('歌词', max_length=50, default='暂无歌词')
|
||||
song_file = models.CharField('歌曲文件', max_length=50)
|
||||
label = models.ForeignKey(Label, on_delete=models.CASCADE,verbose_name='歌名分类')
|
||||
def __str__(self):
|
||||
return self.song_name
|
||||
class Meta:
|
||||
# 设置Admin界面的显示内容
|
||||
verbose_name = '歌曲信息'
|
||||
verbose_name_plural = '歌曲信息'
|
||||
|
||||
# 歌曲动态表dynamic
|
||||
class Dynamic(models.Model):
|
||||
dynamic_id = models.AutoField('序号', primary_key=True)
|
||||
song = models.ForeignKey(Song, on_delete=models.CASCADE, verbose_name='歌名')
|
||||
dynamic_plays = models.IntegerField('播放次数')
|
||||
dynamic_search = models.IntegerField('搜索次数')
|
||||
dynamic_down = models.IntegerField('下载次数')
|
||||
class Meta:
|
||||
# 设置Admin界面的显示内容
|
||||
verbose_name = '歌曲动态'
|
||||
verbose_name_plural = '歌曲动态'
|
||||
|
||||
# 歌曲点评表comment
|
||||
class Comment(models.Model):
|
||||
comment_id = models.AutoField('序号', primary_key=True)
|
||||
comment_text = models.CharField('内容', max_length=500)
|
||||
comment_user = models.CharField('用户', max_length=20)
|
||||
song = models.ForeignKey(Song, on_delete=models.CASCADE,verbose_name='歌名')
|
||||
comment_date = models.CharField('日期', max_length=50)
|
||||
class Meta:
|
||||
# 设置Admin界面的显示内容
|
||||
verbose_name = '歌曲评论'
|
||||
verbose_name_plural = '歌曲评论'
|
||||
# Create your models here.
|
||||
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@ -0,0 +1,24 @@
|
||||
from django.shortcuts import render
|
||||
from .models import *
|
||||
|
||||
|
||||
def indexView(request):
|
||||
# 热搜歌曲
|
||||
search_song = Dynamic.objects.select_related('song').order_by('-dynamic_search').all()[:8]
|
||||
# 音乐分类
|
||||
label_list = Label.objects.all()
|
||||
# 热门歌曲
|
||||
play_hot_song = Dynamic.objects.select_related('song').order_by('-dynamic_plays').all()[:10]
|
||||
# 新歌推荐
|
||||
daily_recommendation = Song.objects.order_by('-song_release').all()[:3]
|
||||
# 热门搜索、热门下载
|
||||
search_ranking = search_song[:6]
|
||||
down_ranking = Dynamic.objects.select_related('song').order_by('-dynamic_down').all()[:6]
|
||||
all_ranking = [search_ranking, down_ranking]
|
||||
return render(request, 'index.html', locals())
|
||||
|
||||
|
||||
# 自定义404和500的错误页面
|
||||
def page_not_found(request):
|
||||
return render(request, 'error404.html', status=404)
|
||||
# Create your views here.
|
||||
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env python
|
||||
"""Django's command-line utility for administrative tasks."""
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'music.settings')
|
||||
try:
|
||||
from django.core.management import execute_from_command_line
|
||||
except ImportError as exc:
|
||||
raise ImportError(
|
||||
"Couldn't import Django. Are you sure it's installed and "
|
||||
"available on your PYTHONPATH environment variable? Did you "
|
||||
"forget to activate a virtual environment?"
|
||||
) from exc
|
||||
execute_from_command_line(sys.argv)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,16 @@
|
||||
"""
|
||||
WSGI config for music project.
|
||||
|
||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'music.settings')
|
||||
|
||||
application = get_wsgi_application()
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class PlayConfig(AppConfig):
|
||||
name = 'play'
|
||||
Binary file not shown.
@ -0,0 +1,3 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
@ -0,0 +1,173 @@
|
||||
{% extends "title_base.html" %}
|
||||
{% load staticfiles %}
|
||||
{% block header_extends %}
|
||||
<link type="image/x-icon" rel="shortcut icon" href="{% static 'favicon.ico' %}">
|
||||
<link type="text/css" rel="stylesheet" href="{% static 'css/common.css' %}">
|
||||
<link type="text/css" rel="stylesheet" href="{% static 'css/play.css' %}">
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<body>
|
||||
<div class="header">
|
||||
<a href="/" class="logo" title="首页"><img src="{% static 'image/logo.png' %}"></a>
|
||||
<div class="search-box">
|
||||
<!-- 歌曲查询 -->
|
||||
<form id="searchForm" action="{% url 'search' 1 %}" method="post" target="_blank">
|
||||
{% csrf_token %}
|
||||
<div class="search-keyword">
|
||||
<input id="kword" name="kword" type="text" class="keyword" maxlength="120" placeholder="音乐节" />
|
||||
</div>
|
||||
<input id="subSerch" type="submit" class="search-button" value="搜 索" />
|
||||
</form>
|
||||
<div id="suggest" class="search-suggest"></div>
|
||||
<div class="search-hot-words">
|
||||
{% for song in search_song %}
|
||||
<a target="play" href="{% url 'play' song.song.song_id %}" >{{ song.song.song_name }}</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div><!--end header-->
|
||||
<div class="nav-box">
|
||||
<div class="nav-box-inner">
|
||||
<ul class="nav clearfix">
|
||||
<li><a href="/">首页</a></li>
|
||||
<li><a href="{% url 'ranking' %}" target="_blank">歌曲排行</a></li>
|
||||
<li><a href="{% url 'home' 1 %}" target="_blank">用户中心</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div><!--end nav-box-->
|
||||
<!--后期修改-->
|
||||
<div class="wrapper clearfix">
|
||||
<div class="content">
|
||||
<div class="product-detail-box clearfix">
|
||||
<div class="product-pics">
|
||||
<div class="music_box">
|
||||
<div id="jquery_jplayer_1" class="jp-jplayer" data-url="{% static 'songFile/' %}{{ song_info.song_file }}></div>
|
||||
<div class="jp_img layz_load pic_po" title="点击播放"><img data-src="{% static 'songImg/' %}{{ song_info.song_img }}></div>
|
||||
<div id="jp_container_1" class="jp-audio">
|
||||
<div class="jp-gui jp-interface">
|
||||
<div class="jp-time-holder clearfix">
|
||||
<div class="jp-progress">
|
||||
<div class="jp-seek-bar">
|
||||
<div class="jp-play-bar"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="jp-time">
|
||||
<span class="jp-current-time"></span> /
|
||||
<span class="jp-duration"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="song_error_corr" id="songCorr">
|
||||
<b class="err_btn">纠错</b>
|
||||
<ul>
|
||||
<li><span>歌词文本错误</span></li>
|
||||
<li><span>歌词时间错误</span></li>
|
||||
<li><span>歌曲错误</span></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="jp-volume-bar">
|
||||
<div class="jp-volume-bar-value"></div>
|
||||
</div>
|
||||
<ul class="jp-controls clearfix">
|
||||
<li><a class="jp-play" tabindex="1" title="play"></a><a class="jp-pause" tabindex="1" title="pause"></a></li>
|
||||
<li><a class="jp-stop" tabindex="1" title="stop"></a></li>
|
||||
<li><a class="jp-repeat" tabindex="1" title="repeat"></a><a class="jp-repeat-off" tabindex="1" title="repeat off"></a></li>
|
||||
<li class="sound"><a class="jp-mute" tabindex="1" title="mute"></a><a class="jp-unmute" tabindex="1" title="unmute"></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="jplayer_content">
|
||||
<ul id="lrc_list" class="lrc_list"></ul>
|
||||
</div>
|
||||
</div><!--end music_box-->
|
||||
<textarea id="lrc_content" style="display: none;">
|
||||
{{ song_lyrics }}
|
||||
</textarea>
|
||||
</div><!--end product-pics-->
|
||||
<div class="product-detail-main">
|
||||
<div class="product-price">
|
||||
<h1 id="currentSong" >{{ song_info.song_name }}</h1>
|
||||
<div class="product-price-info">
|
||||
<span>歌手:{{ song_info.song_singer }}</span>
|
||||
</div>
|
||||
<div class="product-price-info">
|
||||
<span>专辑:{{ song_info.song_album }}</span>
|
||||
<span>语种:{{ song_info.song_languages }}</span>
|
||||
</div>
|
||||
<div class="product-price-info">
|
||||
<span>流派:{{ song_info.song_type }}</span>
|
||||
<span>发行时间:{{ song_info.song_release }}</span>
|
||||
</div>
|
||||
</div><!--end product-price-->
|
||||
<div class="product-comment">
|
||||
<div class="links clearfix">
|
||||
<a class="minimum-link-A click_down" href="{% url 'download' song_info.song_id %}">下载</a>
|
||||
<a class="minimum-link-A" href="{% url 'comment' song_info.song_id %}" >歌曲点评</a>
|
||||
</div><!-- end links-->
|
||||
<h3 class="list_title">当前播放列表</h3>
|
||||
<ul class="playing-li" id="songlist">
|
||||
<!--播放列表-->
|
||||
{% for list in play_list %}
|
||||
{%if list.song_id == song_info.song_id %}
|
||||
<li data-id="{{list.song_id}}" class="current">
|
||||
{%else %}
|
||||
<li data-id="{{list.song_id}}">
|
||||
{%endif %}
|
||||
<span class="num">{{forloop.counter}}</span>
|
||||
<a class="name" href="{% url 'play' list.song_id %}" target="play" >{{list.song_name}}</a>
|
||||
<a class="singer" href="javascript:;" target="_blank" >{{list.song_singer}}</a>
|
||||
</li>
|
||||
{%endfor %}
|
||||
</ul>
|
||||
<div class="nplayL-btns" id="playleixin">
|
||||
<ul>
|
||||
<li class="order current" data-run="order">
|
||||
<a class="icon" href="javascript:void(0)" title="顺序播放"></a>
|
||||
</li>
|
||||
<li class="single" data-run="single">
|
||||
<a class="icon" title="单曲循环" href="javascript:void(0)"></a>
|
||||
</li>
|
||||
<li class="random" data-run="random">
|
||||
<a class="icon" title="随机播放" href="javascript:void(0)"></a>
|
||||
</li>
|
||||
<li class="next" data-run="next">
|
||||
<a href="javascript:void(0)"><i></i>播放下一首</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div><!--end nplayL-btns-->
|
||||
</div><!-- end product-comment -->
|
||||
</div><!-- end product-detail-main -->
|
||||
</div><!-- end product-detail-box -->
|
||||
|
||||
<div class="section">
|
||||
<div class="section-header">
|
||||
<h3>相关歌曲</h3>
|
||||
</div>
|
||||
<div class="section-content">
|
||||
<div class="parts-box">
|
||||
<a href="javascript:;" target="_self" id="J_PartsPrev" class="prev-btn"><i></i></a>
|
||||
<div class="parts-slider" id="J_PartsList">
|
||||
<div class="parts-list-wrap f_w">
|
||||
<ul id="" class="parts-list clearfix f_s">
|
||||
{% for item in song_relevant %}
|
||||
<li>
|
||||
{% if item.song.song_id != song_info.song_id %}
|
||||
<a class="pic layz_load pic_po" href="{% url 'play' item.song.song_id %}" target="play" >
|
||||
<img data-src="{% static "songImg/" %}{{ item.song.song_img }}">
|
||||
</a>
|
||||
<h4><a href="{% url 'play' item.song.song_id %}" target="play" >{{ item.song.song_name}}</a></h4>
|
||||
<a href="javascript:;" class="J_MoreParts accessories-more">{{ item.song.song_singer }}</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<a href="javascript:;" target="_self" id="J_PartsNext" class="next-btn"><i></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script data-main="{% static "js/play.js" %}" src="{% static "js/require.js" %}"></script>
|
||||
{% endblock %}
|
||||
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@ -0,0 +1,23 @@
|
||||
"""music URL Configuration
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/2.0/topics/http/urls/
|
||||
Examples:
|
||||
Function views
|
||||
1. Add an import: from my_app import views
|
||||
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
||||
Class-based views
|
||||
1. Add an import: from other_app.views import Home
|
||||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
||||
Including another URLconf
|
||||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.urls import path
|
||||
from . import views
|
||||
urlpatterns = [
|
||||
# 歌曲播放页面
|
||||
path('<int:song_id>.html', views.playView, name='play'),
|
||||
# 歌曲下载
|
||||
path('download/<int:song_id>.html',views.downloadView, name='download')
|
||||
]
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class RankingConfig(AppConfig):
|
||||
name = 'ranking'
|
||||
Binary file not shown.
@ -0,0 +1,3 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
@ -0,0 +1,99 @@
|
||||
{% extends "title_base.html" %}
|
||||
{% load staticfiles %}
|
||||
{% block header_extends %}
|
||||
<link type="image/x-icon" rel="shortcut icon" href="{% static 'favicon.ico' %}">
|
||||
<link type="text/css" rel="stylesheet" href="{% static 'css/common.css' %}">
|
||||
<link type="text/css" rel="stylesheet" href="{% static 'css/ranking.css' %}">
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<body>
|
||||
<div class="header">
|
||||
<a href="/" class="logo" title="首页"><img alt="我的音乐" src="{% static 'image/logo.png' %}"></a>
|
||||
<div class="search-box">
|
||||
<form id="searchForm" action="{% url 'search' 1 %}" method="post" target="_blank">
|
||||
{% csrf_token %}
|
||||
<div class="search-keyword">
|
||||
<input name="kword" type="text" class="keyword" maxlength="120" placeholder="音乐节" />
|
||||
</div>
|
||||
<input id="subSerch" type="submit" class="search-button" value="搜 索" />
|
||||
</form>
|
||||
<div id="suggest" class="search-suggest"></div>
|
||||
<div class="search-hot-words">
|
||||
{% for song in search_song %}
|
||||
<a target="play" href="{% url 'play' song.song.song_id %}" >{{ song.song.song_name }}</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div><!--end header-->
|
||||
<div class="nav-box">
|
||||
<div class="nav-box-inner">
|
||||
<ul class="nav clearfix">
|
||||
<li><a href="/">首页</a></li>
|
||||
<li><a href="{% url 'ranking' %}">歌曲排行</a></li>
|
||||
<li><a href="{% url 'home' 1 %}" target="_blank">用户中心</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div><!--end nav-box-->
|
||||
<div class="wrapper clearfix">
|
||||
<!-- 左侧列表 -->
|
||||
<div class="side">
|
||||
<!-- 子类分类排行导航 -->
|
||||
<div class="side-nav">
|
||||
<div class="nav-head">
|
||||
<a href="{% url 'ranking' %}">所有歌曲分类</a>
|
||||
</div>
|
||||
<ul id="sideNav" class="cate-item">
|
||||
{% for item in All_list %}
|
||||
<li class="computer">
|
||||
<div class="main-cate">
|
||||
<a href="{% url 'ranking' %}?type={{ item.song_type }}" class="main-title">{{ item.song_type }}</a>
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div><!-- 左侧列表 end -->
|
||||
|
||||
<div class="main">
|
||||
<div class="main-head-box clearfix">
|
||||
<div class="main-head"><h1>歌曲排行榜</h1></div>
|
||||
</div>
|
||||
<table class="rank-list-table">
|
||||
<tr>
|
||||
<th class="cell-1">排名</th>
|
||||
<th class="cell-2">图片</th>
|
||||
<th class="cell-3">歌名</th>
|
||||
<th class="cell-4">专辑</th>
|
||||
<th class="cell-5">下载量</th>
|
||||
<th class="cell-6">播放量</th>
|
||||
</tr>
|
||||
{% for item in song_info %}
|
||||
<tr>
|
||||
{%if forloop.counter < 4 %}
|
||||
<td><span class="n1">{{forloop.counter}}</span></td>
|
||||
{%else %}
|
||||
<td><span class="n2">{{forloop.counter}}</span></td>
|
||||
{%endif %}
|
||||
<td>
|
||||
<a href="{% url 'play' item.song.song_id %}" class="pic" target="play"><img src="{% static 'songImg/' %}{{ item.song.song_img }}" width="80" height="80"></a>
|
||||
</td>
|
||||
<td class="name-cell">
|
||||
<h3><a href="{% url 'play' item.song.song_id %}" target="play" >{{item.song.song_name}}</a></h3>
|
||||
<div class="desc">
|
||||
<a href="javascript:;" target="_blank" class="type" >{{item.song.song_singer}}</a>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div style="text-align:center;">{{item.song.song_album}}</div>
|
||||
</td>
|
||||
<td>
|
||||
<div style="text-align:center;">{{item.dynamic_down}}</div>
|
||||
</td>
|
||||
<td class="num-cell">{{item.dynamic_plays}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<script data-main="{% static "js/ranking.js" %}" src="{% static "js/require.js" %}"></script>
|
||||
{% endblock %}
|
||||
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@ -0,0 +1,22 @@
|
||||
"""music URL Configuration
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/2.0/topics/http/urls/
|
||||
Examples:
|
||||
Function views
|
||||
1. Add an import: from my_app import views
|
||||
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
||||
Class-based views
|
||||
1. Add an import: from other_app.views import Home
|
||||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
||||
Including another URLconf
|
||||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.urls import path
|
||||
from . import views
|
||||
urlpatterns = [
|
||||
path('', views.rankingView, name='ranking'),
|
||||
# 通用视图
|
||||
path('.list', views.RankingList.as_view(), name='rankingList'),
|
||||
]
|
||||
@ -0,0 +1,43 @@
|
||||
from django.shortcuts import render
|
||||
from index.models import *
|
||||
def rankingView(request):
|
||||
# 搜索歌曲
|
||||
search_song = Dynamic.objects.select_related('song').order_by('-dynamic_search').all()[:4]
|
||||
# 歌曲分类列表
|
||||
All_list = Song.objects.values('song_type').distinct()
|
||||
# 歌曲列表信息
|
||||
song_type = request.GET.get('type', '')
|
||||
if song_type:
|
||||
song_info = Dynamic.objects.select_related('song').filter(song__song_type=song_type).order_by('-dynamic_plays').all()[:10]
|
||||
else:
|
||||
song_info = Dynamic.objects.select_related('song').order_by('-dynamic_plays').all()[:10]
|
||||
return render(request, 'ranking.html', locals())
|
||||
|
||||
|
||||
|
||||
# 通用视图
|
||||
from django.views.generic import ListView
|
||||
class RankingList(ListView):
|
||||
# context_object_name设置Html模版的某一个变量名称
|
||||
context_object_name = 'song_info'
|
||||
# 设定模版文件
|
||||
template_name = 'ranking.html'
|
||||
# 查询变量song_info的数据
|
||||
def get_queryset(self):
|
||||
# 获取请求参数
|
||||
song_type = self.request.GET.get('type', '')
|
||||
if song_type:
|
||||
song_info = Dynamic.objects.select_related('song').filter(song__song_type=song_type).order_by('-dynamic_plays').all()[:10]
|
||||
else:
|
||||
song_info = Dynamic.objects.select_related('song').order_by('-dynamic_plays').all()[:10]
|
||||
return song_info
|
||||
|
||||
# 添加其他变量
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
# 搜索歌曲
|
||||
context['search_song'] = Dynamic.objects.select_related('song').order_by('-dynamic_search').all()[:4]
|
||||
# 所有歌曲分类
|
||||
context['All_list'] = Song.objects.values('song_type').distinct()
|
||||
return context
|
||||
# Create your views here.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class SearchConfig(AppConfig):
|
||||
name = 'search'
|
||||
Binary file not shown.
@ -0,0 +1,3 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue