diff --git a/journal/urls.py b/journal/urls.py index e49a8f04..a3c712bc 100644 --- a/journal/urls.py +++ b/journal/urls.py @@ -142,6 +142,7 @@ urlpatterns = [ name="user_calendar_data", ), path("users//feed/reviews/", ReviewFeed(), name="review_feed"), + path("wrapped/", WrappedView.as_view(), name="wrapped_current_year"), path("wrapped//", WrappedView.as_view(), name="wrapped"), path("wrapped//share", WrappedShareView.as_view(), name="wrapped_share"), ] diff --git a/journal/views/wrapped.py b/journal/views/wrapped.py index 2291fb62..1e2aa032 100644 --- a/journal/views/wrapped.py +++ b/journal/views/wrapped.py @@ -1,5 +1,6 @@ import base64 import calendar +import datetime from typing import Any from django.contrib import messages @@ -51,9 +52,10 @@ class WrappedView(LoginRequiredMixin, TemplateView): target = user.identity year = int(kwargs.get("year", 0)) if year < 1970 or year > 2100: - year = 2000 + year = datetime.date.today().year context = super().get_context_data(**kwargs) context["identity"] = target + context["year"] = year cnt = {} cats = [] _item_types = _type_to_emoji() diff --git a/locale/zh_Hans/LC_MESSAGES/django.po b/locale/zh_Hans/LC_MESSAGES/django.po index aa7d10f1..619955dc 100644 --- a/locale/zh_Hans/LC_MESSAGES/django.po +++ b/locale/zh_Hans/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-04-24 01:50-0400\n" +"POT-Creation-Date: 2024-05-15 03:12-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,11 +17,11 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: boofilsic/settings.py:396 +#: boofilsic/settings.py:398 msgid "English" msgstr "英语" -#: boofilsic/settings.py:397 boofilsic/settings.py:400 +#: boofilsic/settings.py:399 boofilsic/settings.py:402 msgid "Simplified Chinese" msgstr "简体中文" @@ -1328,7 +1328,7 @@ msgstr "" msgid "常用标签" msgstr "" -#: common/templates/_sidebar.html:199 +#: common/templates/_sidebar.html:200 msgid "全部" msgstr "" @@ -1442,7 +1442,8 @@ msgstr "内容 (Markdown格式)" msgid "Post to Fediverse" msgstr "发布到联邦宇宙" -#: journal/forms.py:25 journal/forms.py:45 +#: journal/forms.py:25 journal/forms.py:45 users/templates/users/data.html:40 +#: users/templates/users/data.html:134 msgid "Visibility" msgstr "可见性" @@ -1462,15 +1463,18 @@ msgstr "协作编辑" msgid "note" msgstr "备注" -#: journal/models/common.py:26 +#: journal/models/common.py:26 users/templates/users/data.html:49 +#: users/templates/users/data.html:143 msgid "Public" msgstr "公开" -#: journal/models/common.py:27 +#: journal/models/common.py:27 users/templates/users/data.html:57 +#: users/templates/users/data.html:151 msgid "Followers Only" msgstr "仅关注者" -#: journal/models/common.py:28 +#: journal/models/common.py:28 users/templates/users/data.html:65 +#: users/templates/users/data.html:159 msgid "Mentioned Only" msgstr "自己和提到的人" @@ -1942,44 +1946,44 @@ msgstr "链接无效" msgid "{review_title} - a review of {item_title}" msgstr "{review_title} - 关于 {item_title} 的评论" -#: journal/views/tag.py:43 journal/views/tag.py:57 +#: journal/views/tag.py:41 journal/views/tag.py:55 msgid "Invalid tag" msgstr "无效标签" -#: journal/views/tag.py:46 +#: journal/views/tag.py:44 msgid "Tag not found" msgstr "标签不存在" -#: journal/views/tag.py:61 +#: journal/views/tag.py:59 msgid "Tag deleted." msgstr "标签已删除" -#: journal/views/tag.py:71 +#: journal/views/tag.py:69 msgid "Duplicated tag." msgstr "重复标签" -#: journal/views/tag.py:77 +#: journal/views/tag.py:75 msgid "Tag updated." msgstr "标签已更新" -#: journal/views/wrapped.py:141 +#: journal/views/wrapped.py:143 msgid "Summary posted to timeline." msgstr "总结已发布到时间轴" -#: mastodon/api.py:489 takahe/utils.py:514 +#: mastodon/api.py:517 takahe/utils.py:514 #, python-brace-format msgid "regarding {item_title}, may contain spoiler or triggering content" msgstr "关于 {item_title},可能包含剧透或敏感内容" -#: mastodon/api.py:646 +#: mastodon/api.py:674 msgid "collection" msgstr "收藏单" -#: mastodon/api.py:651 +#: mastodon/api.py:679 msgid "shared my collection" msgstr "分享我的收藏单" -#: mastodon/api.py:654 +#: mastodon/api.py:682 #, python-brace-format msgid "shared {username}'s collection" msgstr "分享 {username} 的收藏单" @@ -2382,39 +2386,39 @@ msgstr "" msgid "验证信息不符。" msgstr "" -#: users/data.py:111 +#: users/data.py:119 msgid "导出已开始。" msgstr "" -#: users/data.py:122 +#: users/data.py:130 msgid "导出文件已过期,请重新导出" msgstr "" -#: users/data.py:132 +#: users/data.py:140 msgid "同步已开始。" msgstr "" -#: users/data.py:146 +#: users/data.py:154 msgid "同步设置已保存。" msgstr "" -#: users/data.py:157 +#: users/data.py:165 msgid "已重置。" msgstr "" -#: users/data.py:166 +#: users/data.py:174 msgid "链接已保存,等待后台导入。" msgstr "" -#: users/data.py:168 +#: users/data.py:176 msgid "无法识别链接。" msgstr "" -#: users/data.py:181 users/data.py:204 users/data.py:217 +#: users/data.py:189 users/data.py:212 users/data.py:225 msgid "文件已上传,等待后台导入。" msgstr "" -#: users/data.py:183 users/data.py:219 +#: users/data.py:191 users/data.py:227 msgid "无法识别文件。" msgstr "" @@ -2509,60 +2513,122 @@ msgstr "" msgid "暂无公告" msgstr "" -#: users/templates/users/data.html:19 -msgid "导入豆瓣标记和评论" -msgstr "" +#: users/templates/users/data.html:10 +msgid "Data Management" +msgstr "数据管理" -#: users/templates/users/data.html:69 -msgid "备份文件已上传,请等待导入完成或刷新页面查看最新进度" -msgstr "" +#: users/templates/users/data.html:19 +msgid "Import Marks and Reviews from Douban" +msgstr "导入豆瓣标记和评论" #: users/templates/users/data.html:69 users/templates/users/data.html:88 -#: users/templates/users/data.html:145 users/templates/users/data.html:187 -msgid "导入" -msgstr "" +#: users/templates/users/data.html:162 users/templates/users/data.html:207 +msgid "Import" +msgstr "导入" #: users/templates/users/data.html:78 -msgid "导入Goodreads账号或书单" -msgstr "" +msgid "Import Shelf or List from Goodreads" +msgstr "导入Goodreads书架或书单" -#: users/templates/users/data.html:106 -msgid "导入Letterboxd标记" -msgstr "" +#: users/templates/users/data.html:82 +msgid "Link to Goodreads Profile / Shelf / List" +msgstr "Goodreads个人主页、书架或书单链接" -#: users/templates/users/data.html:165 -msgid "导入播客订阅列表" +#: users/templates/users/data.html:93 +msgid "" +"want-to-read / currently-reading / read books and their reviews will be " +"imported." msgstr "" +"提交Goodreads用户主页链接将导入想读、在读、已读列表,每本书的评论导入为本站短" +"评。" -#: users/templates/users/data.html:194 -msgid "导出个人数据" -msgstr "" +#: users/templates/users/data.html:98 +msgid "Shelf will be imported as a new collection." +msgstr "Goodreads书架将被导入为收藏单,每本书的评论导入为收藏单条目备注。" -#: users/templates/users/data.html:200 -msgid "正在导出标记、短评和评论" -msgstr "" +#: users/templates/users/data.html:103 +msgid "List will be imported as a new collection." +msgstr "Goodreads书单将被导入为收藏单,每本书的评论导入为收藏单条目备注。" -#: users/templates/users/data.html:200 -msgid "导出标记、短评和评论" -msgstr "" +#: users/templates/users/data.html:115 +msgid "Import from Letterboxd" +msgstr "导入Letterboxd标记" -#: users/templates/users/data.html:210 +#: users/templates/users/data.html:164 +msgid "Only forward changes(none->to-watch->watched) will be imported." +msgstr "导入时仅更新正向变化(未标->想看->已看)标记;不足360字符的评论会作为短评添加。" + +#: users/templates/users/data.html:168 +msgid "Last import started" +msgstr "最近导入时间" + +#: users/templates/users/data.html:169 +msgid "Status" +msgstr "状态" + +#: users/templates/users/data.html:173 +msgid "" +"Failed links, likely due to Letterboxd error, you may have to mark them " +"manually" +msgstr "导入失败的链接(通常由于Letterboxd的信息错误,请手工添加标记)" + +#: users/templates/users/data.html:185 +msgid "Import Podcast Subscriptions" +msgstr "导入播客订阅列表 (OPML)" + +#: users/templates/users/data.html:191 +msgid "Import Method" +msgstr "导入方式" + +#: users/templates/users/data.html:198 +msgid "Mark as listening" +msgstr "标记为在听" + +#: users/templates/users/data.html:202 +msgid "Import as a new collection" +msgstr "导入为新收藏单" + +#: users/templates/users/data.html:205 +msgid "Select OPML file" +msgstr "选择OPML文件" + +#: users/templates/users/data.html:214 +msgid "Export Data" +msgstr "导出数据" + +#: users/templates/users/data.html:220 +msgid "Export in progress" +msgstr "正在导出" + +#: users/templates/users/data.html:220 +msgid "Export marks and reviews" +msgstr "导出标记、短评和评论" + +#: users/templates/users/data.html:222 +msgid "Download" +msgstr "下载" + +#: users/templates/users/data.html:229 +msgid "View Annual Summary" +msgstr "查看年度小结" + +#: users/templates/users/data.html:242 msgid "重置所有标记和短评可见性" msgstr "" -#: users/templates/users/data.html:213 +#: users/templates/users/data.html:245 msgid "重置" msgstr "" -#: users/templates/users/data.html:216 +#: users/templates/users/data.html:248 msgid "公开" msgstr "" -#: users/templates/users/data.html:218 +#: users/templates/users/data.html:250 msgid "仅关注者" msgstr "" -#: users/templates/users/data.html:220 +#: users/templates/users/data.html:252 msgid "仅自己" msgstr "" diff --git a/users/data.py b/users/data.py index 1821b958..4115c4b3 100644 --- a/users/data.py +++ b/users/data.py @@ -1,9 +1,11 @@ +import datetime import os import django_rq from django.conf import settings from django.contrib import messages from django.contrib.auth.decorators import login_required +from django.db.models import Min from django.http import HttpResponse from django.shortcuts import redirect, render from django.urls import reverse @@ -16,7 +18,7 @@ from journal.importers.douban import DoubanImporter from journal.importers.goodreads import GoodreadsImporter from journal.importers.letterboxd import LetterboxdImporter from journal.importers.opml import OPMLImporter -from journal.models import reset_journal_visibility_for_user +from journal.models import ShelfType, reset_journal_visibility_for_user from mastodon.api import * from social.models import reset_social_visibility_for_user @@ -72,6 +74,13 @@ def preferences(request): @login_required def data(request): + current_year = datetime.date.today().year + queryset = request.user.identity.shelf_manager.get_shelf( + ShelfType.COMPLETE + ).members.all() + start_date = queryset.aggregate(Min("created_time"))["created_time__min"] + start_year = start_date.year if start_date else current_year + years = reversed(range(start_year, current_year + 1)) return render( request, "users/data.html", @@ -80,6 +89,7 @@ def data(request): "import_status": request.user.preference.import_status, "export_status": request.user.preference.export_status, "letterboxd_task": LetterboxdImporter.latest_task(request.user), + "years": years, }, ) diff --git a/users/templates/users/data.html b/users/templates/users/data.html index f582545a..cc608e37 100644 --- a/users/templates/users/data.html +++ b/users/templates/users/data.html @@ -7,7 +7,7 @@ - {{ site_name }} - 数据管理 + {{ site_name }} - {% trans 'Data Management' %} {% include "common_libs.html" %} @@ -16,7 +16,7 @@
- {% trans '导入豆瓣标记和评论' %} + {% trans 'Import Marks and Reviews from Douban' %}
@@ -37,7 +37,7 @@

- 可见性: + {% trans 'Visibility' %}:

+ {% if import_status.douban_pending %} onclick="return confirm('短期重复上传可能有无法预期的效果,确定现在上传导入吗?')" value="备份文件已上传,请等待导入完成或刷新页面查看最新进度" {% else %} value="{% trans 'Import' %}" {% endif %} />
- {% trans '导入Goodreads账号或书单' %} + {% trans 'Import Shelf or List from Goodreads' %}
{% csrf_token %}
- 输入Goodreads链接 + {% trans 'Link to Goodreads Profile / Shelf / List' %} - +
  • - Goodreads用户主页链接形如 https://www.goodreads.com/user/show/12345-janedoe 将自动导入到当前用户的想读、在读、已读列表,每本书的评论导入为本站短评; + Profile https://www.goodreads.com/user/show/12345-janedoe + {% trans 'want-to-read / currently-reading / read books and their reviews will be imported.' %}
  • - Goodreads书单链接形如 https://www.goodreads.com/review/list/12345-janedoe?shelf=namehttps://www.goodreads.com/list/show/155086.Popular_Highlights 将自动导入成为收藏单,每本书的评论导入为收藏单条目备注。 + Shelf https://www.goodreads.com/review/list/12345-janedoe?shelf=name + {% trans 'Shelf will be imported as a new collection.' %}
  • - 欲导入的Goodreads用户需将Who Can View My Profile设置为anyone,导入后可改回原设置。 + List https://www.goodreads.com/list/show/155086.Popular_Highlights + {% trans 'List will be imported as a new collection.' %} +
  • +
  • + Who Can View My Profile must be set as anyone prior to import.
@@ -103,18 +109,27 @@
- {% trans '导入Letterboxd标记' %} + {% trans 'Import from Letterboxd' %}
{% csrf_token %} - 在Letterboxd网站的Settings页面中选择DATA,或在其app的Settings菜单中选择Advanced Settings,点击 EXPORT YOUR DATA,即可下载导出名称类似letterboxd-username-2018-03-11-07-52-utc.zip的文件,不必解压。 +
    +
  • + In letterboxd.com, + click DATA in Settings; + or in its app, tap Advanced Settings in Settings, tap EXPORT YOUR DATA +
  • +
  • + download file with name like letterboxd-username-2018-03-11-07-52-utc.zip, do not unzip. +
  • +

- 可见性: + {% trans 'Visibility' %}:

- + - 导入时仅更新正向变化(未标->想看->已看)标记;不足360字符的评论会作为短评添加。 + {% trans 'Only forward changes(none->to-watch->watched) will be imported.' %} {% if letterboxd_task %}
- 最近导入于{{ letterboxd_task.created_time }},状态:{{ letterboxd_task.get_state_display }}。 + {% trans 'Last import started' %}: {{ letterboxd_task.created_time }} + {% trans 'Status' %}: {{ letterboxd_task.get_state_display }}。
{{ letterboxd_task.message }} {% if letterboxd_task.metadata.failed_urls %} - 导入失败的链接(通常由于Letterboxd的信息错误,请手工添加标记): + {% trans 'Failed links, likely due to Letterboxd error, you may have to mark them manually' %}
{% endif %} @@ -162,48 +178,60 @@
- {% trans '导入播客订阅列表' %} + {% trans 'Import Podcast Subscriptions' %} {% csrf_token %}
- 导入方式: + {% trans 'Import Method' %}:
- 选择OPML文件 + {% trans 'Select OPML file' %} - +
+
+
+ {% trans 'View Annual Summary' %} +
+ {% for year in years %} + + {{ year }} + + {% endfor %} +
+
+