export reviews
This commit is contained in:
parent
81c793b18e
commit
01db91e610
6 changed files with 40 additions and 2 deletions
|
@ -160,6 +160,10 @@ class BookReview(Review):
|
|||
def url(self):
|
||||
return settings.APP_WEBSITE + reverse("books:retrieve_review", args=[self.id])
|
||||
|
||||
@property
|
||||
def item(self):
|
||||
return self.book
|
||||
|
||||
|
||||
class BookTag(Tag):
|
||||
book = models.ForeignKey(
|
||||
|
|
|
@ -144,6 +144,10 @@ class GameReview(Review):
|
|||
def url(self):
|
||||
return settings.APP_WEBSITE + reverse("games:retrieve_review", args=[self.id])
|
||||
|
||||
@property
|
||||
def item(self):
|
||||
return self.game
|
||||
|
||||
|
||||
class GameTag(Tag):
|
||||
game = models.ForeignKey(
|
||||
|
|
|
@ -260,6 +260,7 @@ class MovieMark(Mark):
|
|||
|
||||
class MovieReview(Review):
|
||||
movie = models.ForeignKey(Movie, on_delete=models.CASCADE, related_name='movie_reviews', null=True)
|
||||
|
||||
class Meta:
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
|
@ -270,6 +271,10 @@ class MovieReview(Review):
|
|||
def url(self):
|
||||
return settings.APP_WEBSITE + reverse("movies:retrieve_review", args=[self.id])
|
||||
|
||||
@property
|
||||
def item(self):
|
||||
return self.movie
|
||||
|
||||
|
||||
class MovieTag(Tag):
|
||||
movie = models.ForeignKey(Movie, on_delete=models.CASCADE, related_name='movie_tags', null=True)
|
||||
|
|
|
@ -188,6 +188,10 @@ class SongReview(Review):
|
|||
def url(self):
|
||||
return settings.APP_WEBSITE + reverse("music:retrieve_song_review", args=[self.id])
|
||||
|
||||
@property
|
||||
def item(self):
|
||||
return self.song
|
||||
|
||||
|
||||
class SongTag(Tag):
|
||||
song = models.ForeignKey(
|
||||
|
@ -235,6 +239,10 @@ class AlbumReview(Review):
|
|||
def url(self):
|
||||
return settings.APP_WEBSITE + reverse("music:retrieve_album_review", args=[self.id])
|
||||
|
||||
@property
|
||||
def item(self):
|
||||
return self.album
|
||||
|
||||
|
||||
class AlbumTag(Tag):
|
||||
album = models.ForeignKey(
|
||||
|
|
|
@ -122,6 +122,23 @@ def export_marks_task(user):
|
|||
line = [title, summary, world_rating, source_url, timestamp, my_rating, tags, text, url, '']
|
||||
ws.append(line)
|
||||
|
||||
review_heading = ['标题', '评论对象', '链接', '创建时间', '我的评分', '类型', '内容', '评论对象原始链接', '评论对象NeoDB链接']
|
||||
for ReviewModel, label in [(MovieReview, '影评'), (BookReview, '书评'), (AlbumReview, '乐评'), (GameReview, '游戏评论')]:
|
||||
ws = wb.create_sheet(title=label)
|
||||
reviews = ReviewModel.objects.filter(owner=user).order_by("-edited_time")
|
||||
ws.append(review_heading)
|
||||
for review in reviews:
|
||||
title = review.title
|
||||
target = "《" + review.item.title + "》"
|
||||
url = review.url
|
||||
timestamp = review.edited_time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
my_rating = None # (mark.rating / 2) if mark.rating else None
|
||||
content = review.content
|
||||
target_source_url = review.item.source_url
|
||||
target_url = review.item.url
|
||||
line = [title, target, url, timestamp, my_rating, label, content, target_source_url, target_url]
|
||||
ws.append(line)
|
||||
|
||||
wb.save(filename=filename)
|
||||
user.preference.export_status['marks_pending'] = False
|
||||
user.preference.export_status['marks_file'] = filename
|
||||
|
|
|
@ -219,9 +219,9 @@
|
|||
<form action="{% url 'users:export_marks' %}" method="POST" enctype="multipart/form-data" >
|
||||
{% csrf_token %}
|
||||
{% if export_status.marks_pending %}
|
||||
<input type="submit" class="import-panel__button" value="{% trans '正在导出兼容豆伴(doufen)和NiceDB的标记和短评' %}" id="uploadBtn" disabled />
|
||||
<input type="submit" class="import-panel__button" value="{% trans '正在导出兼容豆伴(doufen)和NiceDB的标记、短评和评论' %}" id="uploadBtn" disabled />
|
||||
{% else %}
|
||||
<input type="submit" class="import-panel__button" value="{% trans '导出兼容豆伴(doufen)和NiceDB的标记和短评' %}" id="uploadBtn" />
|
||||
<input type="submit" class="import-panel__button" value="{% trans '导出兼容豆伴(doufen)和NiceDB的标记、短评和评论' %}" id="uploadBtn" />
|
||||
{% endif %}
|
||||
{% if export_status.marks_file %}
|
||||
<a href="{% url 'users:export_marks' %}" download>下载 {{ export_status.marks_date }} 的导出</a>
|
||||
|
|
Loading…
Add table
Reference in a new issue