优化了一些问题

master
newrain001 3 years ago
parent c349d55132
commit 11d32be605
  1. 7
      App/admin.py
  2. 14
      App/views.py
  3. 23
      templates/nav/videolist.html

@ -1,3 +1,10 @@
from django.contrib import admin
# Register your models here.
from .models import *
admin.site.register(User)
admin.site.register(Upload)
admin.site.register(Task)
admin.site.register(paper)
admin.site.register(thumbs)
admin.site.register(videoUpload)

@ -285,11 +285,15 @@ def videoView(request, id):
return render(request, 'nav/videoview.html', {'path': data.video_path})
def videoList(request):
video_type = request.GET.get('video_type', '全部内容')
if video_type == '全部内容':
data = videoUpload.objects.all().order_by('video_title', '-video_time')
else:
data = videoUpload.objects.filter(video_desc=video_type).all().order_by('video_title','-video_time')
desc = videoUpload.objects.all().values('video_desc').distinct()
data = {}
for i in desc:
data[i["video_desc"]] = videoUpload.objects.filter(video_desc=i["video_desc"]).all().order_by('video_title')
return render(request, 'nav/videolist.html', {'data':data })
desc = [i['video_desc'] for i in desc]
desc.append('全部内容')
return render(request, 'nav/videolist.html', {'data': data, 'desc': desc, 'selected': video_type})
def file_iterator(file_name, chunk_size=8192, offset=0, length=None):
with open(file_name, "rb") as f:
@ -340,5 +344,5 @@ def videoDownload(request, id):
response = FileResponse(file)
response['Content-Type'] = 'application/octet-stream'
response['Content-Disposition'] = 'attachment;filename="{}"'.format(quote(file_name))
messages.error(request, '下载成功')
#messages.error(request, '下载成功')
return response

@ -7,12 +7,28 @@
{% endblock %}
{% block content %}
<div class="main" style="padding-top: 80px">
<form action="" id="desc">
<select class="form-select form-select-lg mb-3" aria-label=".form-select-lg example" name="video_type">
{% for i in desc %}
{% if i == selected %}
<option selected value="{{ i }}">{{ i }}</option>
{% else %}
<option value="{{ i }}">{{ i }}</option>
{% endif %}
{% endfor %}
</select>
<button class="w-100 btn btn-lg btn-primary" type="submit">提交</button>
</form>
<script>
$(function func() {
var form = document.getElementById('desc');
form.submit();
})
</script>
<div class="dy-content">
{% for k,v in data.items %}
<h1>{{ k }}</h1>
<div class="dy-videos">
<ul class="dy-video-list">
{% for i in v %}
{% for i in data %}
{% if forloop.counter|quyu:5 %}
<li data- class="dy-video-item dy-video-meta-left">
{% else %}
@ -43,7 +59,6 @@
{% endfor %}
</ul>
</div>
{% endfor %}
</div>
</div>
{% if messages %}

Loading…
Cancel
Save