Skip to content

Commit 6e6b161

Browse files
authored
Merge pull request #524 from liangliangyy/dev
代码结构调整及缓存优化
2 parents 62285aa + 6284fff commit 6e6b161

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+402
-1015
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ venv/
44
migrations/
55
!migrations/__init__.py
66
collectedstatic/
7-
DjangoBlog/whoosh_index/
7+
djangoblog/whoosh_index/
88
uploads/
99
settings_production.py
1010
*.md

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ venv/
6969
migrations/
7070
!migrations/__init__.py
7171
collectedstatic/
72-
DjangoBlog/whoosh_index/
72+
djangoblog/whoosh_index/
7373
google93fd32dbd906620a.html
7474
baidu_verify_FlHL7cUyC9.html
7575
BingSiteAuth.xml
7676
cb9339dbe2ff86a5aa169d28dba5f615.txt
77-
werobot_session
77+
werobot_session.*
7878
django.jpg
7979
uploads/
8080
settings_production.py

DjangoBlog/urls.py

Lines changed: 0 additions & 56 deletions
This file was deleted.

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM python:3
22
ENV PYTHONUNBUFFERED 1
3-
WORKDIR /code/DjangoBlog/
3+
WORKDIR /code/djangoblog/
44
RUN apt-get install default-libmysqlclient-dev -y && \
55
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
66
ADD requirements.txt requirements.txt
@@ -10,5 +10,5 @@ RUN pip install --upgrade pip && \
1010
pip cache purge
1111

1212
ADD . .
13-
RUN chmod +x /code/DjangoBlog/bin/docker_start.sh
14-
ENTRYPOINT ["/code/DjangoBlog/bin/docker_start.sh"]
13+
RUN chmod +x /code/djangoblog/bin/docker_start.sh
14+
ENTRYPOINT ["/code/djangoblog/bin/docker_start.sh"]

accounts/admin.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
from django import forms
2-
from django.contrib import admin
32
from django.contrib.auth.admin import UserAdmin
4-
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
53
from django.contrib.auth.forms import ReadOnlyPasswordHashField
4+
from django.contrib.auth.forms import UserChangeForm
5+
from django.contrib.auth.forms import UsernameField
6+
from django.utils.translation import gettext_lazy as _
7+
68
# Register your models here.
79
from .models import BlogUser
8-
from django.utils.translation import gettext, gettext_lazy as _
9-
from django.contrib.auth.forms import UsernameField
1010

1111

1212
class BlogUserCreationForm(forms.ModelForm):

accounts/forms.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
#!/usr/bin/env python
2-
# encoding: utf-8
3-
4-
5-
"""
6-
@version: ??
7-
@author: liangliangyy
8-
@license: MIT Licence
9-
10-
@site: https://www.lylinux.net/
11-
@software: PyCharm
12-
@file: forms.py
13-
@time: 2016/11/20 下午3:16
14-
"""
151
from django import forms
162
from django.contrib.auth import get_user_model, password_validation
173
from django.contrib.auth.forms import AuthenticationForm, UserCreationForm
@@ -108,7 +94,7 @@ def clean_new_password2(self):
10894
def clean_email(self):
10995
user_email = self.cleaned_data.get("email")
11096
if not BlogUser.objects.filter(
111-
email=user_email
97+
email=user_email
11298
).exists():
11399
# todo 这里的报错提示可以判断一个邮箱是不是注册过,如果不想暴露可以修改
114100
raise ValidationError("未找到邮箱对应的用户")

accounts/models.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
from django.contrib.auth.models import AbstractUser
12
from django.db import models
2-
from django.contrib.auth.models import AbstractUser, BaseUserManager
33
from django.urls import reverse
4-
from DjangoBlog.utils import get_current_site
54
from django.utils.timezone import now
65

6+
from djangoblog.utils import get_current_site
7+
78

89
# Create your models here.
910

accounts/templatetags/__init__.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +0,0 @@
1-
#!/usr/bin/env python
2-
# encoding: utf-8
3-
4-
5-
"""
6-
@version: ??
7-
@author: liangliangyy
8-
@license: MIT Licence
9-
10-
@site: https://www.lylinux.net/
11-
@software: PyCharm
12-
@file: __init__.py
13-
@time: 2016/11/2 下午9:15
14-
"""

accounts/tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from django.urls import reverse
44
from django.utils import timezone
55

6-
from DjangoBlog.utils import *
6+
from djangoblog.utils import *
77
from accounts.models import BlogUser
88
from blog.models import Article, Category
99
from . import utils
@@ -83,7 +83,7 @@ def test_validate_register(self):
8383
user.is_superuser = True
8484
user.is_staff = True
8585
user.save()
86-
delete_sidebar_cache(user.username)
86+
delete_sidebar_cache()
8787
category = Category()
8888
category.name = "categoryaaa"
8989
category.created_time = timezone.now()

accounts/urls.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,8 @@
1-
#!/usr/bin/env python
2-
# encoding: utf-8
3-
4-
5-
"""
6-
@version: ??
7-
@author: liangliangyy
8-
@license: MIT Licence
9-
10-
@site: https://www.lylinux.net/
11-
@software: PyCharm
12-
@file: urls.py
13-
@time: 2016/11/20 下午3:52
14-
"""
15-
161
from django.conf.urls import url
172
from django.urls import path
183

19-
from .forms import LoginForm
204
from . import views
5+
from .forms import LoginForm
216

227
app_name = "accounts"
238

0 commit comments

Comments
 (0)