|
@@ -24,6 +24,18 @@ def article(request):
|
|
|
return render(request, 'management/article/article.html', context={'articles': articles})
|
|
|
|
|
|
|
|
|
+@login_required(login_url='/login')
|
|
|
+def draft(request):
|
|
|
+ page = request.GET.get('page')
|
|
|
+ search_title = request.GET.get('search_title')
|
|
|
+ search_content = request.GET.get('search_content')
|
|
|
+ if page is None:
|
|
|
+ page = 0
|
|
|
+ articles = blog.controller.article.get_article(is_paginator=True, page=int(page), search_title=search_title,
|
|
|
+ search_content=search_content, draft=True)
|
|
|
+ return render(request, 'management/article/draft.html', context={'articles': articles})
|
|
|
+
|
|
|
+
|
|
|
def new(request):
|
|
|
return render(request, 'management/article/new_article.html')
|
|
|
|
|
@@ -41,7 +53,7 @@ def show_article(request, pk):
|
|
|
result = get_record_and_tags()
|
|
|
|
|
|
return render(request, 'blog.html', context={'article': article, 'records': result['records'],
|
|
|
- 'tags': result['tags']})
|
|
|
+ 'tags': result['tags']})
|
|
|
|
|
|
|
|
|
@login_required(login_url='/')
|
|
@@ -219,8 +231,9 @@ def set_tag(articles):
|
|
|
|
|
|
|
|
|
def get_article(top: int = -1, page: int = -1, is_paginator: bool = False, category: models.Category = None,
|
|
|
- tag: models.Tags = None, search_title: str = None, search_content: str = None, date_record: str = None):
|
|
|
- if category is None and tag is None and date_record is None:
|
|
|
+ tag: models.Tags = None, search_title: str = None, search_content: str = None, date_record: str = None,
|
|
|
+ draft: bool = False):
|
|
|
+ if category is None and tag is None and date_record is None and draft == False:
|
|
|
search_dict = dict()
|
|
|
if search_title:
|
|
|
search_dict['title__contains'] = search_title
|
|
@@ -238,21 +251,22 @@ def get_article(top: int = -1, page: int = -1, is_paginator: bool = False, categ
|
|
|
elif date_record is not None:
|
|
|
date_format = "%Y-%m"
|
|
|
date = datetime.strptime(date_record, date_format)
|
|
|
- articles = models.Article.objects.filter(created_time__year=date.year,created_time__month=date.month).order_by('-created_time').values('id', 'title',
|
|
|
- 'intro',
|
|
|
- 'category',
|
|
|
- 'user',
|
|
|
- 'created_time',
|
|
|
- 'type',
|
|
|
- 'cover__file_net_path',
|
|
|
- 'music__file_net_path',
|
|
|
- 'status',
|
|
|
- 'category__name',
|
|
|
- 'user__first_name',
|
|
|
- 'user_id',
|
|
|
- 'user__last_name',
|
|
|
- 'is_top',
|
|
|
- 'html_text').distinct()
|
|
|
+ articles = models.Article.objects.filter(created_time__year=date.year, created_time__month=date.month).order_by(
|
|
|
+ '-created_time').values('id', 'title',
|
|
|
+ 'intro',
|
|
|
+ 'category',
|
|
|
+ 'user',
|
|
|
+ 'created_time',
|
|
|
+ 'type',
|
|
|
+ 'cover__file_net_path',
|
|
|
+ 'music__file_net_path',
|
|
|
+ 'status',
|
|
|
+ 'category__name',
|
|
|
+ 'user__first_name',
|
|
|
+ 'user_id',
|
|
|
+ 'user__last_name',
|
|
|
+ 'is_top',
|
|
|
+ 'html_text').distinct()
|
|
|
elif tag is not None:
|
|
|
articles = models.Article.objects.filter(tags__name=tag.name).order_by('-created_time').values('id', 'title',
|
|
|
'intro',
|
|
@@ -270,6 +284,29 @@ def get_article(top: int = -1, page: int = -1, is_paginator: bool = False, categ
|
|
|
'tags__name',
|
|
|
'is_top',
|
|
|
'html_text')
|
|
|
+ elif draft:
|
|
|
+ search_dict = dict()
|
|
|
+ search_dict['status'] = 0
|
|
|
+
|
|
|
+ if search_title:
|
|
|
+ search_dict['title__contains'] = search_title
|
|
|
+ if search_content:
|
|
|
+ search_dict['markdown_text__contains'] = search_content
|
|
|
+ articles = models.Article.objects.filter(**search_dict).order_by('-created_time').values('id', 'title',
|
|
|
+ 'intro',
|
|
|
+ 'category',
|
|
|
+ 'user',
|
|
|
+ 'created_time',
|
|
|
+ 'type',
|
|
|
+ 'cover__file_net_path',
|
|
|
+ 'music__file_net_path',
|
|
|
+ 'status',
|
|
|
+ 'category__name',
|
|
|
+ 'user__first_name',
|
|
|
+ 'user_id',
|
|
|
+ 'user__last_name',
|
|
|
+ 'is_top',
|
|
|
+ 'html_text').distinct()
|
|
|
else:
|
|
|
articles = models.Article.objects.filter(category=category).order_by('-created_time').values('id', 'title',
|
|
|
'intro',
|