-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ded974
commit 447c8c8
Showing
19 changed files
with
242 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class NoticeConfig(AppConfig): | ||
name = 'notice' |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.db import models | ||
|
||
# Create your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django.urls import path | ||
from . import views | ||
|
||
app_name = 'notice' | ||
|
||
urlpatterns = [ | ||
# 通知列表 | ||
path('list/', views.CommentNoticeListView.as_view(), name='list'), | ||
# 更新通知状态 | ||
path('update/', views.CommentNoticeUpdateView.as_view(), name='update'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
# Create your views here. | ||
from django.shortcuts import render, redirect | ||
from django.views import View | ||
from django.views.generic import ListView,DetailView,DeleteView | ||
from django.views.generic.edit import CreateView,UpdateView | ||
from django.contrib.auth.mixins import LoginRequiredMixin | ||
from article.models import ArticlePost | ||
|
||
|
||
class CommentNoticeListView(LoginRequiredMixin, ListView): | ||
"""通知列表""" | ||
# 上下文的名称 | ||
context_object_name = 'notices' | ||
# 模板位置 | ||
template_name = 'notice/list.html' | ||
# 登录重定向 | ||
login_url = '/userprofile/login/' | ||
|
||
# 未读通知的查询集 | ||
def get_queryset(self): | ||
return self.request.user.notifications.unread() | ||
|
||
|
||
class CommentNoticeUpdateView(View): | ||
"""更新通知状态""" | ||
# 处理 get 请求 | ||
def get(self, request): | ||
# 获取未读消息 | ||
notice_id = request.GET.get('notice_id') | ||
# 更新单条通知 | ||
if notice_id: | ||
article = ArticlePost.objects.get(id=request.GET.get('article_id')) | ||
request.user.notifications.get(id=notice_id).mark_as_read() | ||
return redirect(article) | ||
# 更新全部通知 | ||
else: | ||
request.user.notifications.mark_all_as_read() | ||
return redirect('notice:list') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
{% extends "base.html" %} {% load static %} | ||
{% extends "base.html" %} | ||
|
||
{% load static %} | ||
|
||
{% block title %} | ||
首页 | ||
|
@@ -9,6 +11,8 @@ | |
|
||
<!-- 定义放置文章标题的div容器 --> | ||
<div class="container"> | ||
<div class="row"> | ||
<main class="col-md-8 mr-auto"> | ||
<br /> | ||
<nav aria-label="breadcrumb"> | ||
<ol class="breadcrumb" style="background-color: white; padding: 0 0 0 2px; font-size: 1.2em"> | ||
|
@@ -39,8 +43,7 @@ | |
</nav> | ||
|
||
<!-- 新增,搜索栏 --> | ||
<div class="row"> | ||
<div class="col-md-8"> | ||
|
||
<form class="form-inline"> | ||
<label class="sr-only">content</label> | ||
<input | ||
|
@@ -54,8 +57,7 @@ | |
<button type="submit" class="btn btn-warning">Search</button> | ||
</form> | ||
<br> | ||
</div> | ||
</div> | ||
|
||
|
||
<!-- 新增,搜索提示语 --> | ||
{% if search %} | ||
|
@@ -85,10 +87,10 @@ <h4>暂无<span style="color: red;">"{{ search }}"</span>有关的文章。</h4> | |
{% endif %} | ||
|
||
<!-- 栏目 --> | ||
<div class="col"> | ||
<div class="col-9"> | ||
|
||
<!-- 标题 --> | ||
<h4> | ||
<h5> | ||
<b> | ||
<a | ||
href="{% url 'article:article_detail' article.id %}" | ||
|
@@ -97,38 +99,37 @@ <h4> | |
{{ article.title }} | ||
</a> | ||
</b> | ||
</h4> | ||
</h5> | ||
<!-- 摘要 --> | ||
|
||
<p style="color: gray;" > | ||
{{ article.body|slice:'100' }}... | ||
{{ article.body|slice:'50' }}... | ||
</p> | ||
|
||
<h5> | ||
<p> | ||
{% if article.category %} | ||
<span> | ||
<a | ||
role="button" | ||
href="{% url 'article:article_list' %}?category={{ article.category.id }}" | ||
class="btn btn-sm mb-2 | ||
{% if article.category.name == 'Html' %} btn-success btn-sm | ||
{% elif article.category.name == 'Java' %} btn-danger btn-sm | ||
{% elif article.category.name == 'Python' %} btn-info btn-sm | ||
{% endif %}" | ||
><i class="fas fa-code"></i> {{ article.category }} </a> | ||
class="btn btn-sm mb-1 btn-success"><i class="fas fa-code-branch"></i> {{ article.category }} </a> | ||
{% endif %} | ||
</span> | ||
|
||
<!-- Tags --> | ||
<span> | ||
{% for tag in article.tags.all %} | ||
{% for tag in article.tags.all %} | ||
<span> | ||
<a | ||
href="{% url 'article:article_list' %}?tag={{ tag }}" | ||
class="badge badge-pill badge-light" | ||
class="badge badge-secondary" | ||
> | ||
{{ tag }} | ||
</a> | ||
{% endfor %} | ||
</span> | ||
</h5> | ||
{% empty %} | ||
{% endfor %} | ||
|
||
</p> | ||
|
||
<p > | ||
<span> | ||
|
@@ -151,7 +152,6 @@ <h5> | |
</p> | ||
</div> | ||
<hr style="width: 100%;"/> | ||
|
||
{% endfor %} | ||
|
||
</div> | ||
|
@@ -202,5 +202,75 @@ <h5> | |
</span> | ||
</div> | ||
</div> | ||
|
||
</main> | ||
|
||
<aside class="col-md-4 mt-md-5"> | ||
|
||
|
||
|
||
<div class="row notification"> | ||
<div class="card col-10 ml-md-2 mb-3"> | ||
<div class="card-body"> | ||
<p class="card-text"><i class="fas fa-bullhorn"></i> 修改海量bug中</p> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
|
||
|
||
<div class="row contanct"> | ||
<div class="card col-10 ml-md-2 mb-3"> | ||
<div class="card-body pb-0"> | ||
<h5 class="card-title">About Me | ||
<a href="https://www.linkedin.com/in/zeliang-yao-359183114/"> | ||
<i class="fab fa-linkedin"></i></a> | ||
|
||
<a href="https://github.com/yaozeliang/"> | ||
<i class="fab fa-github" style="color: lightslategrey"></i></a> | ||
</h5> | ||
<p class="card-text mb-0"> Python爱好者, 玻尿酸采购直邮</p> | ||
<p class="card-text mb-0"><span><i class="far fa-envelope "></i></span> [email protected]</p> | ||
<p><span><i class="fab fa-weixin" style="color: yellowgreen"></i></span> alpha94511</p> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
|
||
|
||
<div class="row gallery"> | ||
<div class="card col-10 ml-md-2 mb-3"> | ||
|
||
<div class="card-body "> | ||
<h6 class="card-title">Category <span><i class="fas fa-code-branch"></i></span> </h6> | ||
<p class="card-text"> | ||
|
||
|
||
</p> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
|
||
|
||
|
||
|
||
|
||
</div> | ||
|
||
|
||
|
||
|
||
|
||
|
||
</aside> | ||
|
||
|
||
|
||
|
||
|
||
|
||
</div> | ||
|
||
</div> | ||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.