diff --git a/.gitignore b/.gitignore index da0d2ef1..3f331f2b 100644 --- a/.gitignore +++ b/.gitignore @@ -18,8 +18,8 @@ migrations/ *.sqlite3 # deployed media and static files -media/ -static/ +/media/ +/static/ # log file log \ No newline at end of file diff --git a/boofilsic/settings.py b/boofilsic/settings.py index cd0c4f15..85ea6bb6 100644 --- a/boofilsic/settings.py +++ b/boofilsic/settings.py @@ -86,7 +86,7 @@ if DEBUG: 'NAME': 'test', 'USER': 'donotban', 'PASSWORD': 'donotbansilvousplait', - 'HOST': '192.168.238.194', + 'HOST': '172.18.99.149', 'OPTIONS': { 'client_encoding': 'UTF8', # 'isolation_level': psycopg2.extensions.ISOLATION_LEVEL_DEFAULT, @@ -174,8 +174,8 @@ AUTH_USER_MODEL = 'users.User' MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media/') -CLIENT_ID = 'kEbwT9Je5HsadfNs5Mw6Asht456YlQl54t4sj2_4' -CLIENT_SECRET = 'xwmEvlmudLCkBmvdzGf8msdfgsdfggs5di9xnDqeVLrcKSg' +CLIENT_ID = 'kEbwT9Je5HHg4FoLx4nb0tNaIrPNs5Mw6AYlQlsj2_4' +CLIENT_SECRET = 'xwmEvlmudLCkBmvdzGf8m41Ug5o5di9xnDqeVLrcKSg' # Path to save report related images, ends without slash REPORT_MEDIA_PATH_ROOT = 'report/' @@ -190,7 +190,6 @@ MASTODON_DOMAIN_NAME = 'donotban.com' MASTODON_TIMEOUT = 30 # Emoji code in mastodon -# note the white spaces STAR_SOLID = ':star_solid:' STAR_HALF = ':star_half:' STAR_EMPTY = ':star_empty:' @@ -205,5 +204,9 @@ LOGIN_URL = '/users/login/' # Admin site root url ADMIN_URL = 'lpLuTqX72Bt2hLfxxRYKeTZdE59Y2hLfpLuTqX72Btx9sXuljYK4tYEmjrHd' +# Luminati proxy settings +LUMINATI_USERNAME = '***REMOVED***' +LUMINATI_PASSWORD = '***REMOVED***' + # https://django-debug-toolbar.readthedocs.io/en/latest/ # maybe benchmarking before deployment diff --git a/books/forms.py b/books/forms.py index 9ae560d3..274c8e41 100644 --- a/books/forms.py +++ b/books/forms.py @@ -5,6 +5,7 @@ from django.utils.translation import gettext_lazy as _ from .models import Book, BookMark, BookReview from common.models import MarkStatusEnum from common.forms import RadioBooleanField, RatingValidator +from common.forms import PreviewImageInput def BookMarkStatusTranslator(status): @@ -59,13 +60,13 @@ class BookForm(forms.ModelForm): 'brief': _("简介"), 'other_info': _("其他信息"), } - from common.forms import ImageInput + widgets = { 'author': forms.TextInput(attrs={'placeholder': _("多个作者使用英文逗号分隔")}), 'translator': forms.TextInput(attrs={'placeholder': _("多个译者使用英文逗号分隔")}), 'other_info': KeyValueInput(), # 'cover': forms.FileInput(), - 'cover': ImageInput(), + 'cover': PreviewImageInput(), } def clean_isbn(self): @@ -108,7 +109,7 @@ class BookMarkForm(forms.ModelForm): 'text': _("短评"), } widgets = { - 'book': forms.Select(attrs={"hidden": ""}), + 'book': forms.TextInput(attrs={"hidden": ""}), 'text': forms.Textarea(attrs={"placeholder": _("最多只能写500字哦~")}), } @@ -141,7 +142,7 @@ class BookReviewForm(forms.ModelForm): 'share_to_mastodon': _("分享到长毛象") } widgets = { - 'book': forms.Select(attrs={"hidden": ""}), + 'book': forms.TextInput(attrs={"hidden": ""}), } diff --git a/books/templates/books/create_update.html b/books/templates/books/create_update.html index f86923ae..f8769451 100644 --- a/books/templates/books/create_update.html +++ b/books/templates/books/create_update.html @@ -9,38 +9,23 @@ - + {% trans 'Nicedb - ' %}{{ title }} - - - + + +
- + {% include "partial/_navbar.html" %}
-
-
-
+
+
+ {% csrf_token %} {{ form }} @@ -49,11 +34,7 @@
- + {% include "partial/_footer.html" %}
@@ -72,6 +53,10 @@ location.href = "{% url 'common:search' %}" + "?q=" + q; } }); + // mark required + $("#content input[required]").each(function () { + $(this).prev().prepend("*"); + }) diff --git a/books/templates/books/create_update_review.html b/books/templates/books/create_update_review.html index 38117079..f2cd4aa6 100644 --- a/books/templates/books/create_update_review.html +++ b/books/templates/books/create_update_review.html @@ -9,44 +9,34 @@ - + {% trans 'Nicedb - ' %}{{ title }} - - + + +
- + {% include "partial/_navbar.html" %} -
-
-
-
- -
+
+
+
+
+
+ + + +
+
- +
{{ book.title }}
{% if book.isbn %}{% trans 'ISBN:' %}{{ book.isbn }}{% endif %}
{% if book.author %}{% trans '作者:' %} {% for author in book.author %} @@ -57,35 +47,38 @@
{%if book.pub_year %}{% trans '出版时间:' %}{{ book.pub_year }}{% trans '年' %}{% if book.pub_month %}{{ book.pub_month }}{% trans '月' %}{% endif %}{% endif %}
{% if book.rating %} - - {{ book.rating }} + {% trans '评分:' %} + {{ book.rating }} {% endif %}
- -
- +
+ + {% csrf_token %} {{ form.book }} - {{ form.title.label }}{{ form.title }} +
+ {{ form.title.label }} +
+ {{ form.title }}
{{ form.content.label }} - {% trans '预览' %} + {% trans '预览' %}
{{ form.content }}
-
{% trans '不知道什么是Markdown?可以参考' %}{% trans '这里' %}
-
-
+
{% trans '不知道什么是Markdown?可以参考' %}{% trans '这里' %}
+
+
{{ form.is_private.label }}{{ form.is_private }}
-
+
@@ -94,16 +87,13 @@
{{ form.media }} -
+
- + +
- + {% include "partial/_footer.html" %}
{% comment %} diff --git a/books/templates/books/delete.html b/books/templates/books/delete.html index 50f91ff2..836b43e1 100644 --- a/books/templates/books/delete.html +++ b/books/templates/books/delete.html @@ -9,64 +9,57 @@ - + {% trans 'Nicedb - 删除图书' %} - - + + +
- + {% include "partial/_navbar.html" %} -
-
-
-

{% trans '确认删除这本书吗?相关评论和标记将一并删除。' %}

+
+
+
+
{% trans '确认删除这本书吗?相关评论和标记将一并删除。' %}
-
-
- -
- -
- {{ book.title }} -
-
- {% if book.rating %} - {% trans '评分:' %} - - - {{ book.rating }} - {% else %} - {% trans '评分:暂无评分' %} - {% endif %} -
{% trans '最近编辑者:' %}{{ book.last_editor | default:"" }}
-
{% trans '上次编辑时间:' %}{{ book.edited_time }}
-
+
+
+ + + +
+
+ +
+ {{ book.title }} +
+
+ {% if book.rating %} + {% trans '评分:' %} + + {{ book.rating }} + {% else %} + {% trans '评分:暂无评分' %} + {% endif %} + + {% if book.last_editor %} + +
{% trans '最近编辑者:' %}{{ book.last_editor | default:"" }}
+
+ {% endif %} + +
{% trans '上次编辑时间:' %}{{ book.edited_time }}
-
+
{% csrf_token %} @@ -75,14 +68,11 @@
+
- + {% include "partial/_footer.html" %}
diff --git a/books/templates/books/delete_review.html b/books/templates/books/delete_review.html index cd0f00b6..05898719 100644 --- a/books/templates/books/delete_review.html +++ b/books/templates/books/delete_review.html @@ -9,90 +9,96 @@ - + {% trans 'Nicedb - 删除评论' %} - + - - + + +
- - -
-
-
-

{% trans '确认删除这篇评论吗?' %}

- -
-
-
-
-

- {{ review.title }} - {% if review.is_private %} - - {% endif %} -

- {{ review.owner.username }} - - {{ review.edited_time }} +
+ + +
+ +
+ {{ review.title }} +
+ {% if review.is_private %} + + + + {% endif %} + +
+
+ + {{ review.owner.username }} + + {% if mark %} + + {% if mark.rating %} + + {% endif %} + + {% endif %} + + {{ review.edited_time }} +
-
- -
- {{ form.content }} -
- {{ form.media }} -
- + +
+
+ {{ form.content }} +
+ {{ form.media }} + +
+
{% csrf_token %} - +
+
- + {% include "partial/_footer.html" %}
- - {% comment %} + + {% comment %} - + {% endcomment %} - + - - + + + + -
- + {% include "partial/_navbar.html" %} -
-
-
-
-
- -
-
-
- {{ book.title }} -
- -
-
{% if book.isbn %}{% trans 'ISBN:' %}{{ book.isbn }}{% endif %}
-
{% if book.author %}{% trans '作者:' %} - {% for author in book.author %} - {{ author }} - {% endfor %} - {% endif %}
-
{% if book.pub_house %}{% trans '出版社:' %}{{ book.pub_house }}{% endif %}
-
{% if book.subtitle %}{% trans '副标题:' %}{{ book.subtitle }}{% endif %}
-
{% if book.translator %}{% trans '译者:' %} - {% for translator in book.translator %} - {{ translator }} - {% endfor %} - {% endif %}
-
{% if book.orig_title %}{% trans '原作名:' %}{{ book.orig_title }}{% endif %}
-
{% if book.language %}{% trans '语言:' %}{{ book.language }}{% endif %}
-
{%if book.pub_year %}{% trans '出版时间:' %}{{ book.pub_year }}{% trans '年' %}{% if book.pub_month %}{{ book.pub_month }}{% trans '月' %}{% endif %}{% endif %}
-
-
- {% if book.rating %} - +
+
+
+
+
- - {{ book.rating }} - {% else %} - {% trans '评分:暂无评分' %} - {% endif %} -
{% if book.binding %}{% trans '装帧:' %}{{ book.binding }}{% endif %}
-
{% if book.price %}{% trans '定价:' %}{{ book.price }}{% endif %}
-
{% if book.pages %}{% trans '页数:' %}{{ book.pages }}{% endif %}
- {% if book.other_info %} - {% for k, v in book.other_info.items %} -
- {{k}}:{{v}} -
- {% endfor %} - {% endif %} + {{ book.title }} + +
+
+ {{ book.title }} +
- {% comment %} - {% url 'users:home' book.last_editor %} - {% endcomment %} +
+
+ {% if book.rating %} + + {{ book.rating }} + {% else %} + {% trans '评分:暂无评分' %} + {% endif %} +
+
{% if book.isbn %}{% trans 'ISBN:' %}{{ book.isbn }}{% endif %}
+
{% if book.author %}{% trans '作者:' %} + {% for author in book.author %} + {{ author }} + {% endfor %} + {% endif %}
+
{% if book.pub_house %}{% trans '出版社:' %}{{ book.pub_house }}{% endif %}
+
{% if book.subtitle %}{% trans '副标题:' %}{{ book.subtitle }}{% endif %}
+
{% if book.translator %}{% trans '译者:' %} + {% for translator in book.translator %} + {{ translator }} + {% endfor %} + {% endif %}
+
{% if book.orig_title %}{% trans '原作名:' %}{{ book.orig_title }}{% endif %}
+
{% if book.language %}{% trans '语言:' %}{{ book.language }}{% endif %}
+
{%if book.pub_year %}{% trans '出版时间:' %}{{ book.pub_year }}{% trans '年' %}{% if book.pub_month %}{{ book.pub_month }}{% trans '月' %}{% endif %}{% endif %}
+
+
+ +
{% if book.binding %}{% trans '装帧:' %}{{ book.binding }}{% endif %}
+
{% if book.price %}{% trans '定价:' %}{{ book.price }}{% endif %}
+
{% if book.pages %}{% trans '页数:' %}{{ book.pages }}{% endif %}
+ {% if book.other_info %} + {% for k, v in book.other_info.items %} +
+ {{k}}:{{v}} +
+ {% endfor %} + {% endif %} -
{% trans '最近编辑者:' %}{{ book.last_editor | default:"" }}
-
- {% trans '编辑这本书' %} - {% if user.is_staff %} - / {% trans '删除' %} - {% endif %} -
-
+ {% if book.last_editor %} +
{% trans '最近编辑者:' %}{{ book.last_editor | default:"" }}
+ {% endif %} + +
+ {% trans '编辑这本书' %} + {% if user.is_staff %} + / {% trans '删除' %} + {% endif %} +
+
+ +
-
-
-
-
{% trans '简介' %}
- - {% if book.brief %} -

{{ book.brief | linebreaksbr }}

- {% else %} -

{% trans '暂无简介' %}

- {% endif %} - -
-
-
{% trans '这本书的标记' %}
- {% if mark_list_more %} - {% trans '更多' %} - {% endif %} - {% if mark_list %} - {% for others_mark in mark_list %} -
-
- {{ others_mark.owner.username }} +
+
+
{% trans '简介' %}
+ + {% if book.brief %} +

{{ book.brief | linebreaksbr }}

+ {% else %} +
{% trans '暂无简介' %}
+ {% endif %} + +
+
+
{% trans '这本书的标记' %}
+ {% if mark_list_more %} + {% trans '更多' %} + {% endif %} + {% if mark_list %} +
    + {% for others_mark in mark_list %} +
  • + {{ others_mark.owner.username }} {{ others_mark.get_status_display }} {% if others_mark.rating %} - + {% endif %} {% if others_mark.is_private %} {% endif %} - {{ others_mark.edited_time }} -
- - {% if others_mark.text %} -

{{ others_mark.text }}

+ {{ others_mark.edited_time }} + {% if others_mark.text %} +

{{ others_mark.text }}

+ {% endif %} + + {% endfor %} + + {% else %} +
{% trans '暂无标记' %}
{% endif %} -
- {% endfor %} - {% else %} -

{% trans '暂无标记' %}

- {% endif %} -
-
-
{% trans '这本书的评论' %}
- {% if review_list_more %} - {% trans '更多' %} - {% endif %} - {% if review_list %} - {% for others_review in review_list %} -
-
- {{ others_review.owner.username }} +
+
{% trans '这本书的评论' %}
+ {% if review_list_more %} + {% trans '更多' %} + {% endif %} + {% if review_list %} +
- + {{ others_review.edited_time }} + {{ others_review.title }} + + {% endfor %} + + {% else %} +
{% trans '暂无评论' %}
+ {% endif %}
- {% endfor %} - {% else %} -

{% trans '暂无评论' %}

- {% endif %}
-
-
+
+
{% if mark %} -
-
- {% trans '我' %}{{ mark.get_status_display }} - {% if mark.status == status_enum.DO.value or mark.status == status_enum.COLLECT.value%} - {% if mark.rating %} - - {% endif %} +
+ + {% trans '我' %}{{ mark.get_status_display }} + {% if mark.status == status_enum.DO.value or mark.status == status_enum.COLLECT.value%} + {% if mark.rating %} + {% endif %} - {% if mark.is_private %} - - {% endif %} - - {% trans '修改' %} -
- {% csrf_token %} - {% trans '删除' %} -
-
-
-
- {{ mark.edited_time }} -
+ {% endif %} + {% if mark.is_private %} + + {% endif %} + + {% trans '修改' %} +
+ {% csrf_token %} + {% trans '删除' %} +
+
+
+ +
{{ mark.edited_time }}
+ {% if mark.text %} -

{{ mark.text }}

+

{{ mark.text }}

{% endif %}
{% else %} -
-
- {% trans '标记这本书' %} -
-
- {% trans '想读' %} - {% trans '在读' %} - {% trans '读过' %} +
+
{% trans '标记这本书' %}
+
+ + +
{% endif %}
-
- {% if review %} -
-
- {% trans '我的评论' %} - {% if review.is_private %} - - {% endif %} +
+ {% if review %} +
+ + {% trans '我的评论' %} + {% if review.is_private %} + + {% endif %} - - {% trans '编辑' %} - {% trans '删除' %} - + + {% trans '编辑' %} + {% trans '删除' %} + -
-
- {{ review.edited_time }} -
- +
{{ review.edited_time }}
+ +
{{ review.title }}
{% else %} -
- {% trans '我的评论' %} -
- {% trans '去写评论' %} + +
+
{% trans '我的评论' %}
+ +
+ {% endif %}
+
- + {% include "partial/_footer.html" %}
-
- + {% include "partial/_footer.html" %}
@@ -209,22 +239,22 @@ -