fix critical bugs

This commit is contained in:
doubaniux 2020-05-07 06:01:22 +08:00
parent 4fb25ba55e
commit 7e9b4aef2f
7 changed files with 10 additions and 8 deletions

View file

@ -86,7 +86,7 @@ if DEBUG:
'NAME': 'test', 'NAME': 'test',
'USER': 'donotban', 'USER': 'donotban',
'PASSWORD': 'donotbansilvousplait', 'PASSWORD': 'donotbansilvousplait',
'HOST': '192.168.13.72', 'HOST': '192.168.13.68',
'OPTIONS': { 'OPTIONS': {
'client_encoding': 'UTF8', 'client_encoding': 'UTF8',
# 'isolation_level': psycopg2.extensions.ISOLATION_LEVEL_DEFAULT, # 'isolation_level': psycopg2.extensions.ISOLATION_LEVEL_DEFAULT,
@ -173,7 +173,7 @@ CLIENT_SECRET = 'xwmEvlmudLCkBmvdzGf8m41Ug5o5di9xnDqeVLrcKSg'
REPORT_MEDIA_PATH_ROOT = 'report/' REPORT_MEDIA_PATH_ROOT = 'report/'
MARKDOWNX_MEDIA_PATH = 'review/' MARKDOWNX_MEDIA_PATH = 'review/'
BOOK_MEDIA_PATH_ROOT = 'book/' BOOK_MEDIA_PATH_ROOT = 'book/'
DEFAULT_BOOK_IMAGE = os.path.join(MEDIA_ROOT, BOOK_MEDIA_PATH_ROOT, 'default.jpg') DEFAULT_BOOK_IMAGE = os.path.join(BOOK_MEDIA_PATH_ROOT, 'default.jpg')
# Mastodon domain name # Mastodon domain name
MASTODON_DOMAIN_NAME = 'donotban.com' MASTODON_DOMAIN_NAME = 'donotban.com'
@ -183,9 +183,9 @@ MASTODON_TIMEOUT = 30
# Emoji code in mastodon # Emoji code in mastodon
# note the white spaces # note the white spaces
STAR_SOLID = ' :star_solid: ' STAR_SOLID = ':star_solid:'
STAR_HALF = ' :star_half: ' STAR_HALF = ':star_half:'
STAR_EMPTY = ' :star_empty: ' STAR_EMPTY = ':star_empty:'
# Default password for each user. since assword is not used any way, # Default password for each user. since assword is not used any way,
# any string that is not empty is ok # any string that is not empty is ok

View file

@ -63,7 +63,7 @@ class BookForm(forms.ModelForm):
'author': forms.TextInput(attrs={'placeholder': _("多个作者使用英文逗号分隔")}), 'author': forms.TextInput(attrs={'placeholder': _("多个作者使用英文逗号分隔")}),
'translator': forms.TextInput(attrs={'placeholder': _("多个译者使用英文逗号分隔")}), 'translator': forms.TextInput(attrs={'placeholder': _("多个译者使用英文逗号分隔")}),
'other_info': KeyValueInput(), 'other_info': KeyValueInput(),
# 'cover': forms.FileInput(), 'cover': forms.FileInput(),
} }
def clean_isbn(self): def clean_isbn(self):

View file

@ -79,7 +79,7 @@ def update(request, id):
) )
elif request.method == 'POST': elif request.method == 'POST':
book = get_object_or_404(Book, pk=id) book = get_object_or_404(Book, pk=id)
form = BookForm(request.POST, instance=book) form = BookForm(request.POST, request.FILES, instance=book)
if form.is_valid(): if form.is_valid():
form.instance.last_editor = request.user form.instance.last_editor = request.user
form.instance.edited_time = timezone.now() form.instance.edited_time = timezone.now()

View file

@ -8,5 +8,7 @@ def rating_to_emoji(score):
solid_stars = score // 2 solid_stars = score // 2
half_star = int(bool(score % 2)) half_star = int(bool(score % 2))
empty_stars = 5 - solid_stars if not half_star else 5 - solid_stars - 1 empty_stars = 5 - solid_stars if not half_star else 5 - solid_stars - 1
emoji_code = STAR_SOLID * solid_stars + STAR_HALF * half_star + STAR_SOLID * empty_stars emoji_code = STAR_SOLID * solid_stars + STAR_HALF * half_star + STAR_EMPTY * empty_stars
emoji_code = emoji_code.replace("::", ": :")
emoji_code = ' ' + emoji_code + ' '
return emoji_code return emoji_code

BIN
favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB