提交内容修改

master
newrain001 2 years ago
parent ff2e981743
commit 0478388f40
  1. 18
      App/migrations/0016_paper_views.py
  2. 27
      App/migrations/0017_auto_20220505_2143.py
  3. 9
      App/models.py
  4. 4
      App/templatetags/myfilter.py
  5. 16
      App/views.py
  6. 26
      templates/function/viewmd.html
  7. 8
      templates/index.html
  8. 4
      templates/nav/dashboard.html
  9. 2
      templates/nav/image.html
  10. 5
      templates/nav/paperlist.html
  11. 68
      templates/task/detailed.html
  12. 2
      templates/task/tasklist.html
  13. 151
      templates/template.html

@ -0,0 +1,18 @@
# Generated by Django 3.2.9 on 2022-05-05 13:08
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('App', '0015_auto_20220503_2328'),
]
operations = [
migrations.AddField(
model_name='paper',
name='views',
field=models.IntegerField(default=0),
),
]

@ -0,0 +1,27 @@
# Generated by Django 3.2.9 on 2022-05-05 13:43
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('App', '0016_paper_views'),
]
operations = [
migrations.RemoveField(
model_name='paper',
name='thumbs_up',
),
migrations.CreateModel(
name='thumbs',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('username', models.CharField(max_length=100)),
('thumbs_time', models.DateTimeField(auto_now_add=True)),
('paper_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='App.paper')),
],
),
]

@ -43,7 +43,7 @@ class paper(models.Model):
paper_title = models.CharField(max_length=200)
paper_desc = models.CharField(max_length=2000)
paper_content = models.TextField()
thumbs_up = models.IntegerField(default=0)
views = models.IntegerField(default=0)
paper_image = models.URLField(max_length=10000, default='')
def __str__(self):
return self.username
@ -53,5 +53,12 @@ class comment(models.Model):
comment_time = models.DateTimeField(auto_now_add=True)
comment_content = models.CharField(max_length=100)
paper_id = models.ForeignKey(paper, on_delete=models.CASCADE)
def __str__(self):
return self.username
class thumbs(models.Model):
username = models.CharField(max_length=100)
thumbs_time = models.DateTimeField(auto_now_add=True)
paper_id = models.ForeignKey(paper, on_delete=models.CASCADE)
def __str__(self):
return self.username

@ -15,3 +15,7 @@ def checkover(value, tags):
return '未完成'
else:
return '已完成'
@register.filter(name='dict_get', is_safe=False)
def dict_get(value, key):
return value.get(key)

@ -1,4 +1,5 @@
from django.contrib.auth import authenticate
from django.db.models import F
from django.http import JsonResponse
from django.shortcuts import HttpResponse, render, redirect, reverse
from django.contrib.auth.decorators import login_required
@ -222,8 +223,19 @@ def editMD(request, id=None):
def paperList(request):
data = paper.objects.all()
return render(request, 'nav/paperlist.html', {'data': data, 'username': auth.get_user(request).username})
thumbs_up = {}
for i in data:
thumbs_up[i.id] = thumbs.objects.filter(paper_id=i.id).count()
return render(request, 'nav/paperlist.html', {'data': data, 'thumbs': thumbs_up, 'username': auth.get_user(request).username})
def paperDetail(request, id):
if request.method == 'POST':
if thumbs.objects.filter(username=auth.get_user(request).username, paper_id=id).exists():
thumbs.objects.filter(username=auth.get_user(request).username, paper_id=id).delete()
else:
thumbs.objects.create(username=auth.get_user(request).username, paper_id=paper.objects.filter(id=id).get()).save()
return redirect(reverse('App:paperDetail', kwargs={'id': id}))
data = paper.objects.filter(id=id).get()
return render(request, 'function/viewmd.html', {'data': data})
if data:
paper.objects.filter(id=id).update(views=paper.objects.filter(id=id).get().views+1)
return render(request, 'function/viewmd.html', {'data': data, 'thumbs': thumbs.objects.filter(paper_id=id).count()})

@ -1,20 +1,23 @@
<!DOCTYPE html>
<html lang="zh">
<head>
{% extends 'template.html' %}
{% load static %}
{% block title %}
<meta charset="utf-8"/>
<title>{{ data.paper_title }}</title>
<link rel="stylesheet" href="{% static 'css/style.css' %}"/>
<link rel="stylesheet" href="{% static 'css/editormd.css' %}"/>
<link rel="stylesheet" href="{% static 'css/station/bootstrap.min.css' %}"/>
<link rel="shortcut icon" href="https://pandao.github.io/editor.md/favicon.ico" type="image/x-icon"/>
</head>
<body>
<div id="layout" style="height: 800px;background: #f6f6f6;">
<h1>{{ data.paper_title }}</h1>
{% endblock %}
{% block content %}
<div id="layout" style="padding-top: 80px; height: 800px;background: #f6f6f6;">
<div class="btns">
<button id="print-btn">打印</button>
<button id="preview-btn">切换模式</button>
<p style="display:inline; font-size: 20px">标题:{{ data.paper_title }}</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<button id="print-btn" class="btn-success text-dark">打印</button>
<button id="preview-btn" class="btn-success text-dark">切换模式</button>
<form action="" method="post" style="margin:0 auto;display:inline;">
{% csrf_token %}
<button class="btn-success text-dark"><img src="{% static 'images/thumbs.jpg' %}" width="20" height="20">{{ thumbs }}</button>
</form>
</div>
<div id="test-editormd">
<textarea style="display:none;">{{ data.paper_content }}</textarea>
@ -45,5 +48,6 @@
});
});
</script>
</body>
</html>
{% endblock %}
{% block foot %}
{% endblock %}

@ -7,7 +7,7 @@
<link rel="stylesheet" href="{% static 'css/station/carousel.css' %}">
{% endblock %}
{% block login %}
<header style="padding-top: 80px">
<header style="padding-top: 70px">
<div class="px-3 py-2 border-bottom mb-3">
<div class="container d-flex flex-wrap justify-content-center">
<form class="col-12 col-lg-auto mb-2 mb-lg-0 me-lg-auto">
@ -111,9 +111,6 @@
</div><!-- /.col-lg-4 -->
</div><!-- /.row -->
<!-- START THE FEATURETTES -->
<hr class="featurette-divider">
{% for k,v in data.items %}
<div class="row featurette">
@ -124,10 +121,9 @@
</div>
<div class="col-md-5">
<img class="bd-placeholder-img bd-placeholder-img-lg featurette-image img-fluid mx-auto" width="500" height="500" src="{{ v.image }}" role="img" aria-label="Placeholder: 500x500" preserveAspectRatio="xMidYMid slice" focusable="false"></img>
</div>
</div>
<hr class="featurette-divider">
<hr>
{% endfor %}
<!-- /END THE FEATURETTES -->

@ -7,7 +7,7 @@
{% block content %}
<div style="padding-top: 80px">
<div class="row">
<nav id="sidebarMenu" style="padding-top: 80px" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
<nav id="sidebarMenu" style="padding-top: 70px" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
<div class="position-sticky pt-3">
<ul class="nav flex-column">
<li class="nav-item">
@ -137,7 +137,7 @@
<tr>
<td>{{ i.upload_time }}</td>
<td>{{ i.file_name }}</td>
<td>{{ i.file_size }}</td>
<td>{{ i.file_size |filesizeformat }}</td>
<td>{{ i.url_path }}</td>
</tr>
{% endfor %}

@ -11,7 +11,7 @@
</style>
{% endblock %}
{% block content %}
<div style="padding-top: 80px">
<div style="padding-top: 70px">
<div class="container px-4 py-5">
<h2 class="pb-2 border-bottom">我的相册</h2>
<div class="row row-cols-1 row-cols-lg-3 align-items-stretch g-4 py-5">

@ -1,11 +1,12 @@
{% extends 'template.html' %}
{% load static %}
{% load myfilter %}
{% block title %}
<title>博客列表</title>
<link rel="stylesheet" href="{% static 'css/station/bootstrap.min.css' %}">
{% endblock %}
{% block content %}
<div class="container" style="padding-top: 80px">
<div class="container" style="padding-top: 70px">
<div class="p-4 p-md-5 mb-4 text-white rounded bg-dark">
<div class="col-md-6 px-0">
<h1 class="display-4 fst-italic">文章列表</h1>
@ -20,7 +21,7 @@
<div class="col-md-6">
<div class="row g-0 border rounded overflow-hidden flex-md-row mb-4 shadow-sm h-md-250 position-relative">
<div class="col p-4 d-flex flex-column position-static">
<strong class="d-inline-block mb-2 text-primary">{{ i.username }}</strong>
<strong class="d-inline-block mb-2 text-primary">作者:{{ i.username }}&nbsp;&nbsp;浏览:{{ i.views }}&nbsp;&nbsp;点赞:{{ thumbs |dict_get:i.id }}</strong>
<h3 class="mb-0">{{ i.paper_title }}</h3>
<div class="mb-1 text-muted">{{ i.paper_time }}</div>
<p class="card-text mb-auto">{{ i.paper_desc }}</p>

@ -3,40 +3,42 @@
<title>任务查看</title>
{% endblock %}
{% block content %}
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th scope="col">姓名</th>
<th scope="col">状态</th>
<th scope="col">更新时间</th>
<th scope="col">操作</th>
</tr>
</thead>
<tbody>
{% for k,v in data.items %}
{% if v.status == '未完成' %}
<tr class="table-danger">
{% else %}
<tr class="table-success">
{% endif %}
<td>{{ k }}</td>
<td>{{ v.status }}</td>
<td>{{ v.update_time }}</td>
<td>
{% if v.status == '未完成' %}
<form action="{% url 'App:checkTask' id %}?name={{ k }}" method="post">
{% csrf_token %}
<input type="submit" value="点击完成">
</form>
{% else %}
<div class="container" style="padding-top: 70px">
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th scope="col">姓名</th>
<th scope="col">状态</th>
<th scope="col">更新时间</th>
<th scope="col">操作</th>
</tr>
</thead>
<tbody>
{% for k,v in data.items %}
{% if v.status == '未完成' %}
<tr class="table-danger">
{% else %}
<tr class="table-success">
{% endif %}
<td>{{ k }}</td>
<td>{{ v.status }}</td>
<td>{{ v.update_time }}</td>
<td>
{% if v.status == '未完成' %}
<form action="{% url 'App:checkTask' id %}?name={{ k }}" method="post">
{% csrf_token %}
<input type="submit" value="点击完成">
</form>
{% else %}
<input type="submit" value="已完成任务">
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock %}
{% block foot %}

@ -7,7 +7,7 @@
{% endblock %}
{% block content %}
{% load static %}
<div style="padding-top: 80px">
<div style="padding-top: 70px">
<section class="py-5 text-center container">
<div class="row py-lg-2">
<div class="col-lg-6 col-md-8 mx-auto">

@ -35,10 +35,8 @@
}
}
#top {
width: 100%;
position: fixed;
z-index: 9999;
h1, h2, div, span, p {
caret-color: transparent;
}
</style>
@ -79,68 +77,68 @@
<main>
<header>
<div class="container">
<div class="navbar fixed-top navbar-light" style="background-color: #5c636a">
<div class="d-flex flex-wrap align-items-center justify-content-center justify-content-lg-start container-md">
<a href="/"
class="d-flex align-items-center my-2 my-lg-0 me-lg-auto text-white text-decoration-none">
<svg class="bi me-2" width="40" height="32" role="img" aria-label="Bootstrap">
<use xlink:href="#bootstrap"/>
</svg>
</a>
<div class="container">
<div class="navbar fixed-top navbar-light" style="background-color: #5c636a; height: 70px">
<div class="d-flex flex-wrap align-items-center justify-content-center justify-content-lg-start container-md">
<a href="/"
class="d-flex align-items-center my-2 my-lg-0 me-lg-auto text-white text-decoration-none">
<svg class="bi me-2" width="40" height="32" role="img" aria-label="Bootstrap">
<use xlink:href="#bootstrap"/>
</svg>
</a>
<ul class="nav col-12 col-lg-auto my-2 justify-content-center my-md-0 text-small">
<li>
<a href="{% url 'App:index' %}" class="nav-link text-white">
<svg class="bi d-block mx-auto mb-1" width="24" height="24">
<use xlink:href="#home"/>
</svg>
主页
</a>
</li>
<li>
<a href="{% url 'App:dashboard' 'login' %}?time=week" class="nav-link text-white">
<svg class="bi d-block mx-auto mb-1" width="24" height="24">
<use xlink:href="#speedometer2"/>
</svg>
仪表盘
</a>
</li>
<li>
<a href="{% url 'App:listTask' %}" class="nav-link text-white">
<img class="bi d-block mx-auto mb-1" width="24" height="24"
src="{% static 'images/archive.png' %}">
任务列表
</a>
</li>
<li>
<a href="{% url 'App:image' %}" class="nav-link text-white">
<svg class="bi d-block mx-auto mb-1" width="24" height="24">
<use xlink:href="#table"/>
</svg>
相册
</a>
</li>
<li>
<a href="{% url 'App:paperList' %}" class="nav-link text-white">
<svg class="bi d-block mx-auto mb-1" width="24" height="24">
<use xlink:href="#grid"/>
</svg>
文章列表
</a>
</li>
<li>
<a href="{% url 'App:userinfo' %}" class="nav-link text-white">
<svg class="bi d-block mx-auto mb-1" width="24" height="24">
<use xlink:href="#people-circle"/>
</svg>
用户
</a>
</li>
</ul>
</div>
<ul class="nav col-12 col-lg-auto my-2 justify-content-center my-md-0 text-small">
<li>
<a href="{% url 'App:index' %}" class="nav-link text-white">
<svg class="bi d-block mx-auto mb-1" width="24" height="24">
<use xlink:href="#home"/>
</svg>
主页
</a>
</li>
<li>
<a href="{% url 'App:dashboard' 'login' %}?time=week" class="nav-link text-white">
<svg class="bi d-block mx-auto mb-1" width="24" height="24">
<use xlink:href="#speedometer2"/>
</svg>
仪表盘
</a>
</li>
<li>
<a href="{% url 'App:listTask' %}" class="nav-link text-white">
<img class="bi d-block mx-auto mb-1" width="24" height="24"
src="{% static 'images/archive.png' %}">
任务列表
</a>
</li>
<li>
<a href="{% url 'App:image' %}" class="nav-link text-white">
<svg class="bi d-block mx-auto mb-1" width="24" height="24">
<use xlink:href="#table"/>
</svg>
相册
</a>
</li>
<li>
<a href="{% url 'App:paperList' %}" class="nav-link text-white">
<svg class="bi d-block mx-auto mb-1" width="24" height="24">
<use xlink:href="#grid"/>
</svg>
文章列表
</a>
</li>
<li>
<a href="{% url 'App:userinfo' %}" class="nav-link text-white">
<svg class="bi d-block mx-auto mb-1" width="24" height="24">
<use xlink:href="#people-circle"/>
</svg>
用户
</a>
</li>
</ul>
</div>
</div>
</div>
</header>
</main>
@ -150,10 +148,6 @@
{% block content %}
{% endblock %}
{% block foot %}
<footer class="container">
<p class="float-end"><a href="#">回到顶部</a></p>
<p>&copy; 2017–2021 Company, Inc. &middot; <a href="#">Privacy</a> &middot; <a href="#">Terms</a></p>
</footer>
<div class="container">
<footer class="py-5">
<div class="row">
@ -209,27 +203,8 @@
</form>
</div>
</div>
<div class="d-flex justify-content-between py-4 my-4 border-top">
<p>&copy; 2021 Company, Inc. All rights reserved.</p>
<ul class="list-unstyled d-flex">
<li class="ms-3"><a class="link-dark" href="#">
<svg class="bi" width="24" height="24">
<use xlink:href="#twitter"/>
</svg>
</a></li>
<li class="ms-3"><a class="link-dark" href="#">
<svg class="bi" width="24" height="24">
<use xlink:href="#instagram"/>
</svg>
</a></li>
<li class="ms-3"><a class="link-dark" href="#">
<svg class="bi" width="24" height="24">
<use xlink:href="#facebook"/>
</svg>
</a></li>
</ul>
</div>
<p class="float-end"><a href="#">回到顶部</a></p>
<p>&copy; 2017–2021 Company, Inc. &middot; <a href="#">Privacy</a> &middot; <a href="#">Terms</a></p>
</footer>
</div>
<script src="{% static 'js/bootstrap.bundle.min.js' %}"></script>

Loading…
Cancel
Save