Skip to content

Commit

Permalink
Merge pull request #539 from liangliangyy/dev
Browse files Browse the repository at this point in the history
close #537
  • Loading branch information
liangliangyy committed Jan 24, 2022
2 parents 8fc8ff4 + 5e581e4 commit ccbb65c
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 31 deletions.
10 changes: 1 addition & 9 deletions blog/tests.py
Expand Up @@ -8,11 +8,11 @@
from django.urls import reverse
from django.utils import timezone

from djangoblog.utils import get_current_site, get_sha256
from accounts.models import BlogUser
from blog.forms import BlogSearchForm
from blog.models import Article, Category, Tag, SideBar, Links
from blog.templatetags.blog_tags import load_pagination_info, load_articletags
from djangoblog.utils import get_current_site, get_sha256


# Create your tests here.
Expand Down Expand Up @@ -98,12 +98,7 @@ def test_validate_article(self):
s = load_articletags(article)
self.assertIsNotNone(s)

rsp = self.client.get('/refresh')
self.assertEqual(rsp.status_code, 302)

self.client.login(username='liangliangyy', password='liangliangyy')
rsp = self.client.get('/refresh')
self.assertEqual(rsp.status_code, 200)

response = self.client.get(reverse('blog:archives'))
self.assertEqual(response.status_code, 200)
Expand Down Expand Up @@ -140,9 +135,6 @@ def test_validate_article(self):
response = self.client.get('/links.html')
self.assertEqual(response.status_code, 200)

rsp = self.client.get('/refresh')
self.assertEqual(rsp.status_code, 200)

response = self.client.get('/feed/')
self.assertEqual(response.status_code, 200)

Expand Down
5 changes: 1 addition & 4 deletions blog/urls.py
Expand Up @@ -55,7 +55,4 @@
r'upload',
views.fileupload,
name='upload'),
path(
r'refresh',
views.refresh_memcache,
name='refresh')]
]
17 changes: 0 additions & 17 deletions blog/views.py
Expand Up @@ -6,7 +6,6 @@

from django import forms
from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse, HttpResponseForbidden
from django.shortcuts import get_object_or_404
from django.shortcuts import render
Expand Down Expand Up @@ -313,22 +312,6 @@ def fileupload(request):
return HttpResponse("only for post")


@login_required
def refresh_memcache(request):
try:

if request.user.is_superuser:
from djangoblog.utils import cache
if cache and cache is not None:
cache.clear()
return HttpResponse("ok")
else:
return HttpResponseForbidden()
except Exception as e:
logger.error(e)
return HttpResponse("error")


def page_not_found_view(
request,
exception,
Expand Down
1 change: 0 additions & 1 deletion templates/blog/tags/sidebar.html
Expand Up @@ -126,7 +126,6 @@
<li><a href="{% url "account:login" %}" rel="nofollow">登录</a></li>
{% endif %}
{% if user.is_superuser %}
<li><a href="{% url "blog:refresh" %}" target="_blank">刷新缓存</a></li>
<li><a href="{% url 'owntracks:show_dates' %}" target="_blank">运动轨迹记录</a></li>
{% endif %}
<li><a href="http://gitbook.lylinux.net" target="_blank" rel="nofollow">GitBook</a></li>
Expand Down

0 comments on commit ccbb65c

Please sign in to comment.