allow mark/review visible to oneself
This commit is contained in:
parent
38244b959e
commit
bcf846880e
46 changed files with 156 additions and 178 deletions
|
@ -96,11 +96,8 @@ class BookMarkForm(MarkForm):
|
|||
'status',
|
||||
'rating',
|
||||
'text',
|
||||
'is_private',
|
||||
]
|
||||
labels = {
|
||||
'rating': _("评分"),
|
||||
}
|
||||
'visibility',
|
||||
]
|
||||
widgets = {
|
||||
'book': forms.TextInput(attrs={"hidden": ""}),
|
||||
}
|
||||
|
@ -115,14 +112,8 @@ class BookReviewForm(ReviewForm):
|
|||
'book',
|
||||
'title',
|
||||
'content',
|
||||
'is_private'
|
||||
'visibility'
|
||||
]
|
||||
labels = {
|
||||
'book': "",
|
||||
'title': _("标题"),
|
||||
'content': _("正文"),
|
||||
'share_to_mastodon': _("分享到长毛象")
|
||||
}
|
||||
widgets = {
|
||||
'book': forms.TextInput(attrs={"hidden": ""}),
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
<div class="review-form__option">
|
||||
<div class="review-form__visibility-radio">
|
||||
|
||||
{{ form.is_private.label }}{{ form.is_private }}
|
||||
{{ form.visibility.label }}{{ form.visibility }}
|
||||
</div>
|
||||
<div class="review-form__share-checkbox">
|
||||
{{ form.share_to_mastodon }}{{ form.share_to_mastodon.label }}
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
<h5 class="review-head__title">
|
||||
{{ review.title }}
|
||||
</h5>
|
||||
{% if review.is_private %}
|
||||
{% if review.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 20 20"><svg xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 20 20">
|
||||
|
|
|
@ -161,7 +161,7 @@
|
|||
{% if others_mark.rating %}
|
||||
<span class="entity-marks__rating-star rating-star" data-rating-score="{{ others_mark.rating | floatformat:"0" }}"></span>
|
||||
{% endif %}
|
||||
{% if others_mark.is_private %}
|
||||
{% if others_mark.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z"/></svg></span>
|
||||
{% endif %}
|
||||
<span class="entity-marks__mark-time">{{ others_mark.edited_time }}</span>
|
||||
|
@ -185,7 +185,7 @@
|
|||
{% for others_review in review_list %}
|
||||
<li class="entity-reviews__review">
|
||||
<a href="{% url 'users:home' others_review.owner.id %}" class="entity-reviews__owner-link">{{ others_review.owner.username }}</a>
|
||||
{% if others_review.is_private %}
|
||||
{% if others_review.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z"/></svg></span>
|
||||
{% endif %}
|
||||
<span class="entity-reviews__review-time">{{ others_review.edited_time }}</span>
|
||||
|
@ -212,7 +212,7 @@
|
|||
<span class="mark-panel__rating-star rating-star" data-rating-score="{{ mark.rating | floatformat:"0" }}"></span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if mark.is_private %}
|
||||
{% if mark.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z"/></svg></span>
|
||||
{% endif %}
|
||||
<span class="mark-panel__actions">
|
||||
|
@ -254,7 +254,7 @@
|
|||
<div class="review-panel">
|
||||
|
||||
<span class="review-panel__label">{% trans '我的评论' %}</span>
|
||||
{% if review.is_private %}
|
||||
{% if review.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z"/></svg></span>
|
||||
{% endif %}
|
||||
|
||||
|
@ -371,8 +371,8 @@
|
|||
|
||||
<div class="mark-modal__option">
|
||||
<div class="mark-modal__visibility-radio">
|
||||
<span>{{ mark_form.is_private.label }}:</span>
|
||||
{{ mark_form.is_private }}
|
||||
<span>{{ mark_form.visibility.label }}:
|
||||
{{ mark_form.visibility }}</span>
|
||||
</div>
|
||||
<div class="mark-modal__share-checkbox">
|
||||
{{ mark_form.share_to_mastodon }}{{ mark_form.share_to_mastodon.label }}
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
<span class="entity-marks__rating-star rating-star"
|
||||
data-rating-score="{{ mark.rating | floatformat:"0" }}"></span>
|
||||
{% endif %}
|
||||
{% if mark.is_private %}
|
||||
{% if mark.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
|
||||
|
||||
<path
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
<h5 class="review-head__title">
|
||||
{{ review.title }}
|
||||
</h5>
|
||||
{% if review.is_private %}
|
||||
{% if review.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
|
||||
<path
|
||||
d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z" />
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
<li class="entity-reviews__review entity-reviews__review--wider">
|
||||
|
||||
<a href="{% url 'users:home' review.owner.id %}" class="entity-reviews__owner-link">{{ review.owner.username }}</a>
|
||||
{% if review.is_private %}
|
||||
{% if review.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z"/></svg></span>
|
||||
{% endif %}
|
||||
<span class="entity-reviews__review-time">{{ review.edited_time }}</span>
|
||||
|
|
|
@ -10,7 +10,7 @@ from django.utils import timezone
|
|||
from django.core.paginator import Paginator
|
||||
from mastodon import mastodon_request_included
|
||||
from mastodon.models import MastodonApplication
|
||||
from mastodon.api import check_visibility, post_toot, TootVisibilityEnum
|
||||
from mastodon.api import post_toot, TootVisibilityEnum
|
||||
from mastodon.utils import rating_to_emoji
|
||||
from common.utils import PageLinksGenerator
|
||||
from common.views import PAGE_LINK_NUMBER, jump_or_scrape
|
||||
|
@ -303,7 +303,10 @@ def create_update_mark(request):
|
|||
return HttpResponseServerError("integrity error")
|
||||
|
||||
if form.cleaned_data['share_to_mastodon']:
|
||||
if form.cleaned_data['is_private']:
|
||||
print(form.cleaned_data)
|
||||
if form.cleaned_data['visibility'] == 2:
|
||||
visibility = TootVisibilityEnum.DIRECT
|
||||
elif form.cleaned_data['visibility'] == 1:
|
||||
visibility = TootVisibilityEnum.PRIVATE
|
||||
else:
|
||||
visibility = TootVisibilityEnum.PUBLIC if request.user.preference.mastodon_publish_public else TootVisibilityEnum.UNLISTED
|
||||
|
@ -396,7 +399,9 @@ def create_review(request, book_id):
|
|||
form.instance.owner = request.user
|
||||
form.save()
|
||||
if form.cleaned_data['share_to_mastodon']:
|
||||
if form.cleaned_data['is_private']:
|
||||
if form.cleaned_data['visibility'] == 2:
|
||||
visibility = TootVisibilityEnum.DIRECT
|
||||
elif form.cleaned_data['visibility'] == 1:
|
||||
visibility = TootVisibilityEnum.PRIVATE
|
||||
else:
|
||||
visibility = TootVisibilityEnum.PUBLIC if request.user.preference.mastodon_publish_public else TootVisibilityEnum.UNLISTED
|
||||
|
@ -448,7 +453,9 @@ def update_review(request, id):
|
|||
form.instance.edited_time = timezone.now()
|
||||
form.save()
|
||||
if form.cleaned_data['share_to_mastodon']:
|
||||
if form.cleaned_data['is_private']:
|
||||
if form.cleaned_data['visibility'] == 2:
|
||||
visibility = TootVisibilityEnum.DIRECT
|
||||
elif form.cleaned_data['visibility'] == 1:
|
||||
visibility = TootVisibilityEnum.PRIVATE
|
||||
else:
|
||||
visibility = TootVisibilityEnum.PUBLIC if request.user.preference.mastodon_publish_public else TootVisibilityEnum.UNLISTED
|
||||
|
@ -502,7 +509,7 @@ def delete_review(request, id):
|
|||
def retrieve_review(request, id):
|
||||
if request.method == 'GET':
|
||||
review = get_object_or_404(BookReview, pk=id)
|
||||
if not check_visibility(review, request.session['oauth_token'], request.user):
|
||||
if not review.is_visible_to(request.user):
|
||||
msg = _("你没有访问这个页面的权限😥")
|
||||
return render(
|
||||
request,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from django import forms
|
||||
from markdownx.fields import MarkdownxFormField
|
||||
import django.contrib.postgres.forms as postgres
|
||||
from django.utils import formats
|
||||
from django.core.exceptions import ValidationError
|
||||
|
@ -223,22 +224,25 @@ class DurationField(forms.TimeField):
|
|||
#############################
|
||||
# Form
|
||||
#############################
|
||||
VISIBILITY_CHOICES = [
|
||||
(0, _("公开")),
|
||||
(1, _("仅关注者")),
|
||||
(2, _("仅自己")),
|
||||
]
|
||||
|
||||
class MarkForm(forms.ModelForm):
|
||||
IS_PRIVATE_CHOICES = [
|
||||
(True, _("仅关注者")),
|
||||
(False, _("公开")),
|
||||
]
|
||||
|
||||
|
||||
class MarkForm(forms.ModelForm):
|
||||
id = forms.IntegerField(required=False, widget=forms.HiddenInput())
|
||||
share_to_mastodon = forms.BooleanField(
|
||||
label=_("分享到长毛象"), initial=True, required=False)
|
||||
rating = forms.IntegerField(
|
||||
validators=[RatingValidator()], widget=forms.HiddenInput(), required=False)
|
||||
is_private = RadioBooleanField(
|
||||
label=_("评分"), validators=[RatingValidator()], widget=forms.HiddenInput(), required=False)
|
||||
visibility = forms.TypedChoiceField(
|
||||
label=_("可见性"),
|
||||
initial=True,
|
||||
choices=IS_PRIVATE_CHOICES
|
||||
initial=0,
|
||||
coerce=int,
|
||||
choices=VISIBILITY_CHOICES,
|
||||
widget=forms.RadioSelect
|
||||
)
|
||||
tags = TagField(
|
||||
required=False,
|
||||
|
@ -259,15 +263,15 @@ class MarkForm(forms.ModelForm):
|
|||
|
||||
|
||||
class ReviewForm(forms.ModelForm):
|
||||
IS_PRIVATE_CHOICES = [
|
||||
(True, _("仅关注者")),
|
||||
(False, _("公开")),
|
||||
]
|
||||
title = forms.CharField(label=_("标题"))
|
||||
content = MarkdownxFormField(label=_("正文 (Markdown)"))
|
||||
share_to_mastodon = forms.BooleanField(
|
||||
label=_("分享到长毛象"), initial=True, required=False)
|
||||
id = forms.IntegerField(required=False, widget=forms.HiddenInput())
|
||||
is_private = RadioBooleanField(
|
||||
visibility = forms.TypedChoiceField(
|
||||
label=_("可见性"),
|
||||
initial=True,
|
||||
choices=IS_PRIVATE_CHOICES
|
||||
initial=0,
|
||||
coerce=int,
|
||||
choices=VISIBILITY_CHOICES,
|
||||
widget=forms.RadioSelect
|
||||
)
|
||||
|
|
|
@ -150,7 +150,8 @@ class Entity(models.Model):
|
|||
|
||||
|
||||
class UserOwnedEntity(models.Model):
|
||||
is_private = models.BooleanField()
|
||||
is_private = models.BooleanField(default=False, null=True) # first set allow null, then migration, finally (in a few days) remove for good
|
||||
visibility = models.PositiveSmallIntegerField(default=0) # 0: Public / 1: Follower only / 2: Self only
|
||||
owner = models.ForeignKey(
|
||||
User, on_delete=models.CASCADE, related_name='user_%(class)ss')
|
||||
created_time = models.DateTimeField(default=timezone.now)
|
||||
|
@ -163,9 +164,11 @@ class UserOwnedEntity(models.Model):
|
|||
owner = self.owner
|
||||
if owner == viewer:
|
||||
return True
|
||||
if self.visibility == 2:
|
||||
return False
|
||||
if viewer.is_blocking(owner) or owner.is_blocking(viewer) or viewer.is_muting(owner):
|
||||
return False
|
||||
if self.is_private:
|
||||
if self.visibility == 1:
|
||||
return viewer.is_following(owner)
|
||||
else:
|
||||
return True
|
||||
|
@ -189,7 +192,7 @@ class UserOwnedEntity(models.Model):
|
|||
"""
|
||||
user_owned_entities = cls.objects.filter(owner=owner)
|
||||
if not is_following:
|
||||
user_owned_entities = user_owned_entities.exclude(is_private=True)
|
||||
user_owned_entities = user_owned_entities.exclude(visibility__gt=0)
|
||||
return user_owned_entities
|
||||
|
||||
|
||||
|
|
|
@ -66,11 +66,8 @@ class GameMarkForm(MarkForm):
|
|||
'status',
|
||||
'rating',
|
||||
'text',
|
||||
'is_private',
|
||||
'visibility',
|
||||
]
|
||||
labels = {
|
||||
'rating': _("评分"),
|
||||
}
|
||||
widgets = {
|
||||
'game': forms.TextInput(attrs={"hidden": ""}),
|
||||
}
|
||||
|
@ -85,14 +82,8 @@ class GameReviewForm(ReviewForm):
|
|||
'game',
|
||||
'title',
|
||||
'content',
|
||||
'is_private'
|
||||
'visibility'
|
||||
]
|
||||
labels = {
|
||||
'book': "",
|
||||
'title': _("标题"),
|
||||
'content': _("正文"),
|
||||
'share_to_mastodon': _("分享到长毛象")
|
||||
}
|
||||
widgets = {
|
||||
'game': forms.TextInput(attrs={"hidden": ""}),
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
<div class="review-form__option">
|
||||
<div class="review-form__visibility-radio">
|
||||
|
||||
{{ form.is_private.label }}{{ form.is_private }}
|
||||
{{ form.visibility.label }}{{ form.visibility }}
|
||||
</div>
|
||||
<div class="review-form__share-checkbox">
|
||||
{{ form.share_to_mastodon }}{{ form.share_to_mastodon.label }}
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
<h5 class="review-head__title">
|
||||
{{ review.title }}
|
||||
</h5>
|
||||
{% if review.is_private %}
|
||||
{% if review.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 20 20">
|
||||
<path
|
||||
|
|
|
@ -190,7 +190,7 @@
|
|||
{% if others_mark.rating %}
|
||||
<span class="entity-marks__rating-star rating-star" data-rating-score="{{ others_mark.rating | floatformat:"0" }}"></span>
|
||||
{% endif %}
|
||||
{% if others_mark.is_private %}
|
||||
{% if others_mark.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z"/></svg></span>
|
||||
{% endif %}
|
||||
<span class="entity-marks__mark-time">{{ others_mark.edited_time }}</span>
|
||||
|
@ -215,7 +215,7 @@
|
|||
{% for others_review in review_list %}
|
||||
<li class="entity-reviews__review">
|
||||
<a href="{% url 'users:home' others_review.owner.id %}" class="entity-reviews__owner-link">{{ others_review.owner.username }}</a>
|
||||
{% if others_review.is_private %}
|
||||
{% if others_review.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z"/></svg></span>
|
||||
{% endif %}
|
||||
<span class="entity-reviews__review-time">{{ others_review.edited_time }}</span>
|
||||
|
@ -243,7 +243,7 @@
|
|||
<span class="mark-panel__rating-star rating-star" data-rating-score="{{ mark.rating | floatformat:"0" }}"></span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if mark.is_private %}
|
||||
{% if mark.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z"/></svg></span>
|
||||
{% endif %}
|
||||
<span class="mark-panel__actions">
|
||||
|
@ -287,7 +287,7 @@
|
|||
<div class="review-panel">
|
||||
|
||||
<span class="review-panel__label">{% trans '我的评论' %}</span>
|
||||
{% if review.is_private %}
|
||||
{% if review.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z"/></svg></span>
|
||||
{% endif %}
|
||||
|
||||
|
@ -378,8 +378,8 @@
|
|||
|
||||
<div class="mark-modal__option">
|
||||
<div class="mark-modal__visibility-radio">
|
||||
<span>{{ mark_form.is_private.label }}:</span>
|
||||
{{ mark_form.is_private }}
|
||||
<span>{{ mark_form.visibility.label }}:</span>
|
||||
{{ mark_form.visibility }}
|
||||
</div>
|
||||
<div class="mark-modal__share-checkbox">
|
||||
{{ mark_form.share_to_mastodon }}{{ mark_form.share_to_mastodon.label }}
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
<span class="entity-marks__rating-star rating-star"
|
||||
data-rating-score="{{ mark.rating | floatformat:"0" }}"></span>
|
||||
{% endif %}
|
||||
{% if mark.is_private %}
|
||||
{% if mark.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
|
||||
<path
|
||||
d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z" />
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
<h5 class="review-head__title">
|
||||
{{ review.title }}
|
||||
</h5>
|
||||
{% if review.is_private %}
|
||||
{% if review.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
|
||||
<path
|
||||
d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z" />
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
<li class="entity-reviews__review entity-reviews__review--wider">
|
||||
|
||||
<a href="{% url 'users:home' review.owner.id %}" class="entity-reviews__owner-link">{{ review.owner.username }}</a>
|
||||
{% if review.is_private %}
|
||||
{% if review.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z"/></svg></span>
|
||||
{% endif %}
|
||||
<span class="entity-reviews__review-time">{{ review.edited_time }}</span>
|
||||
|
|
|
@ -10,7 +10,7 @@ from django.utils import timezone
|
|||
from django.core.paginator import Paginator
|
||||
from mastodon import mastodon_request_included
|
||||
from mastodon.models import MastodonApplication
|
||||
from mastodon.api import check_visibility, post_toot, TootVisibilityEnum
|
||||
from mastodon.api import post_toot, TootVisibilityEnum
|
||||
from mastodon.utils import rating_to_emoji
|
||||
from common.utils import PageLinksGenerator
|
||||
from common.views import PAGE_LINK_NUMBER, jump_or_scrape
|
||||
|
@ -305,7 +305,9 @@ def create_update_mark(request):
|
|||
return HttpResponseServerError("integrity error")
|
||||
|
||||
if form.cleaned_data['share_to_mastodon']:
|
||||
if form.cleaned_data['is_private']:
|
||||
if form.cleaned_data['visibility'] == 2:
|
||||
visibility = TootVisibilityEnum.DIRECT
|
||||
elif form.cleaned_data['visibility'] == 1:
|
||||
visibility = TootVisibilityEnum.PRIVATE
|
||||
else:
|
||||
visibility = TootVisibilityEnum.PUBLIC if request.user.preference.mastodon_publish_public else TootVisibilityEnum.UNLISTED
|
||||
|
@ -399,7 +401,9 @@ def create_review(request, game_id):
|
|||
form.instance.owner = request.user
|
||||
form.save()
|
||||
if form.cleaned_data['share_to_mastodon']:
|
||||
if form.cleaned_data['is_private']:
|
||||
if form.cleaned_data['visibility'] == 2:
|
||||
visibility = TootVisibilityEnum.DIRECT
|
||||
elif form.cleaned_data['visibility'] == 1:
|
||||
visibility = TootVisibilityEnum.PRIVATE
|
||||
else:
|
||||
visibility = TootVisibilityEnum.PUBLIC if request.user.preference.mastodon_publish_public else TootVisibilityEnum.UNLISTED
|
||||
|
@ -451,7 +455,9 @@ def update_review(request, id):
|
|||
form.instance.edited_time = timezone.now()
|
||||
form.save()
|
||||
if form.cleaned_data['share_to_mastodon']:
|
||||
if form.cleaned_data['is_private']:
|
||||
if form.cleaned_data['visibility'] == 2:
|
||||
visibility = TootVisibilityEnum.DIRECT
|
||||
elif form.cleaned_data['visibility'] == 1:
|
||||
visibility = TootVisibilityEnum.PRIVATE
|
||||
else:
|
||||
visibility = TootVisibilityEnum.PUBLIC if request.user.preference.mastodon_publish_public else TootVisibilityEnum.UNLISTED
|
||||
|
@ -506,7 +512,7 @@ def delete_review(request, id):
|
|||
def retrieve_review(request, id):
|
||||
if request.method == 'GET':
|
||||
review = get_object_or_404(GameReview, pk=id)
|
||||
if not check_visibility(review, request.session['oauth_token'], request.user):
|
||||
if not review.is_visible_to(request.user):
|
||||
msg = _("你没有访问这个页面的权限😥")
|
||||
return render(
|
||||
request,
|
||||
|
|
|
@ -76,6 +76,7 @@ def post_toot(site, content, visibility, token, local_only=False):
|
|||
}
|
||||
if not local_only:
|
||||
del payload['local_only']
|
||||
print(payload)
|
||||
response = post(url, headers=headers, data=payload)
|
||||
return response
|
||||
|
||||
|
@ -135,7 +136,7 @@ def get_site_id(username, user_site, target_site, token):
|
|||
|
||||
|
||||
# high level api below
|
||||
def get_relationship(request_user, target_user, token):
|
||||
def get_relationship(request_user, target_user, useless_token=None):
|
||||
return [{
|
||||
'blocked_by': target_user.is_blocking(request_user),
|
||||
'following': request_user.is_following(target_user),
|
||||
|
@ -172,22 +173,6 @@ def get_cross_site_id(target_user, target_site, token):
|
|||
return cross_site_info.site_id
|
||||
|
||||
|
||||
def check_visibility(user_owned_entity, token, visitor):
|
||||
"""
|
||||
check if given user can see the user owned entity
|
||||
"""
|
||||
if not visitor == user_owned_entity.owner:
|
||||
# mastodon request
|
||||
relationship = get_relationship(visitor, user_owned_entity.owner, token)[0]
|
||||
if relationship['blocked_by']:
|
||||
return False
|
||||
if not relationship['following'] and user_owned_entity.is_private:
|
||||
return False
|
||||
return True
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
# utils below
|
||||
def random_string_generator(n):
|
||||
s = string.ascii_letters + string.punctuation + string.digits
|
||||
|
|
|
@ -119,11 +119,8 @@ class MovieMarkForm(MarkForm):
|
|||
'status',
|
||||
'rating',
|
||||
'text',
|
||||
'is_private',
|
||||
'visibility',
|
||||
]
|
||||
labels = {
|
||||
'rating': _("评分"),
|
||||
}
|
||||
widgets = {
|
||||
'movie': forms.TextInput(attrs={"hidden": ""}),
|
||||
}
|
||||
|
@ -138,14 +135,8 @@ class MovieReviewForm(ReviewForm):
|
|||
'movie',
|
||||
'title',
|
||||
'content',
|
||||
'is_private'
|
||||
'visibility'
|
||||
]
|
||||
labels = {
|
||||
'book': "",
|
||||
'title': _("标题"),
|
||||
'content': _("正文"),
|
||||
'share_to_mastodon': _("分享到长毛象")
|
||||
}
|
||||
widgets = {
|
||||
'movie': forms.TextInput(attrs={"hidden": ""}),
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@
|
|||
<div class="review-form__option">
|
||||
<div class="review-form__visibility-radio">
|
||||
|
||||
{{ form.is_private.label }}{{ form.is_private }}
|
||||
{{ form.visibility.label }}{{ form.visibility }}
|
||||
</div>
|
||||
<div class="review-form__share-checkbox">
|
||||
{{ form.share_to_mastodon }}{{ form.share_to_mastodon.label }}
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
<h5 class="review-head__title">
|
||||
{{ review.title }}
|
||||
</h5>
|
||||
{% if review.is_private %}
|
||||
{% if review.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 20 20">
|
||||
<path
|
||||
|
|
|
@ -261,7 +261,7 @@
|
|||
{% if others_mark.rating %}
|
||||
<span class="entity-marks__rating-star rating-star" data-rating-score="{{ others_mark.rating | floatformat:"0" }}"></span>
|
||||
{% endif %}
|
||||
{% if others_mark.is_private %}
|
||||
{% if others_mark.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z"/></svg></span>
|
||||
{% endif %}
|
||||
<span class="entity-marks__mark-time">{{ others_mark.edited_time }}</span>
|
||||
|
@ -290,7 +290,7 @@
|
|||
{% for others_review in review_list %}
|
||||
<li class="entity-reviews__review">
|
||||
<a href="{% url 'users:home' others_review.owner.id %}" class="entity-reviews__owner-link">{{ others_review.owner.username }}</a>
|
||||
{% if others_review.is_private %}
|
||||
{% if others_review.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z"/></svg></span>
|
||||
{% endif %}
|
||||
<span class="entity-reviews__review-time">{{ others_review.edited_time }}</span>
|
||||
|
@ -318,7 +318,7 @@
|
|||
<span class="mark-panel__rating-star rating-star" data-rating-score="{{ mark.rating | floatformat:"0" }}"></span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if mark.is_private %}
|
||||
{% if mark.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z"/></svg></span>
|
||||
{% endif %}
|
||||
<span class="mark-panel__actions">
|
||||
|
@ -366,7 +366,7 @@
|
|||
<div class="review-panel">
|
||||
|
||||
<span class="review-panel__label">{% trans '我的评论' %}</span>
|
||||
{% if review.is_private %}
|
||||
{% if review.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z"/></svg></span>
|
||||
{% endif %}
|
||||
|
||||
|
@ -483,8 +483,8 @@
|
|||
|
||||
<div class="mark-modal__option">
|
||||
<div class="mark-modal__visibility-radio">
|
||||
<span>{{ mark_form.is_private.label }}:</span>
|
||||
{{ mark_form.is_private }}
|
||||
<span>{{ mark_form.visibility.label }}:</span>
|
||||
{{ mark_form.visibility }}
|
||||
</div>
|
||||
<div class="mark-modal__share-checkbox">
|
||||
{{ mark_form.share_to_mastodon }}{{ mark_form.share_to_mastodon.label }}
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
<span class="entity-marks__rating-star rating-star"
|
||||
data-rating-score="{{ mark.rating | floatformat:"0" }}"></span>
|
||||
{% endif %}
|
||||
{% if mark.is_private %}
|
||||
{% if mark.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
|
||||
<path
|
||||
d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z" />
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
<h5 class="review-head__title">
|
||||
{{ review.title }}
|
||||
</h5>
|
||||
{% if review.is_private %}
|
||||
{% if review.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
|
||||
<path
|
||||
d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z" />
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
<li class="entity-reviews__review entity-reviews__review--wider">
|
||||
|
||||
<a href="{% url 'users:home' review.owner.id %}" class="entity-reviews__owner-link">{{ review.owner.username }}</a>
|
||||
{% if review.is_private %}
|
||||
{% if review.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z"/></svg></span>
|
||||
{% endif %}
|
||||
<span class="entity-reviews__review-time">{{ review.edited_time }}</span>
|
||||
|
|
|
@ -10,7 +10,7 @@ from django.utils import timezone
|
|||
from django.core.paginator import Paginator
|
||||
from mastodon import mastodon_request_included
|
||||
from mastodon.models import MastodonApplication
|
||||
from mastodon.api import check_visibility, post_toot, TootVisibilityEnum
|
||||
from mastodon.api import post_toot, TootVisibilityEnum
|
||||
from mastodon.utils import rating_to_emoji
|
||||
from common.utils import PageLinksGenerator
|
||||
from common.views import PAGE_LINK_NUMBER, jump_or_scrape
|
||||
|
@ -304,7 +304,9 @@ def create_update_mark(request):
|
|||
return HttpResponseServerError("integrity error")
|
||||
|
||||
if form.cleaned_data['share_to_mastodon']:
|
||||
if form.cleaned_data['is_private']:
|
||||
if form.cleaned_data['visibility'] == 2:
|
||||
visibility = TootVisibilityEnum.DIRECT
|
||||
elif form.cleaned_data['visibility'] == 1:
|
||||
visibility = TootVisibilityEnum.PRIVATE
|
||||
else:
|
||||
visibility = TootVisibilityEnum.PUBLIC if request.user.preference.mastodon_publish_public else TootVisibilityEnum.UNLISTED
|
||||
|
@ -398,7 +400,9 @@ def create_review(request, movie_id):
|
|||
form.instance.owner = request.user
|
||||
form.save()
|
||||
if form.cleaned_data['share_to_mastodon']:
|
||||
if form.cleaned_data['is_private']:
|
||||
if form.cleaned_data['visibility'] == 2:
|
||||
visibility = TootVisibilityEnum.DIRECT
|
||||
elif form.cleaned_data['visibility'] == 1:
|
||||
visibility = TootVisibilityEnum.PRIVATE
|
||||
else:
|
||||
visibility = TootVisibilityEnum.PUBLIC if request.user.preference.mastodon_publish_public else TootVisibilityEnum.UNLISTED
|
||||
|
@ -450,7 +454,9 @@ def update_review(request, id):
|
|||
form.instance.edited_time = timezone.now()
|
||||
form.save()
|
||||
if form.cleaned_data['share_to_mastodon']:
|
||||
if form.cleaned_data['is_private']:
|
||||
if form.cleaned_data['visibility'] == 2:
|
||||
visibility = TootVisibilityEnum.DIRECT
|
||||
elif form.cleaned_data['visibility'] == 1:
|
||||
visibility = TootVisibilityEnum.PRIVATE
|
||||
else:
|
||||
visibility = TootVisibilityEnum.PUBLIC if request.user.preference.mastodon_publish_public else TootVisibilityEnum.UNLISTED
|
||||
|
@ -505,7 +511,7 @@ def delete_review(request, id):
|
|||
def retrieve_review(request, id):
|
||||
if request.method == 'GET':
|
||||
review = get_object_or_404(MovieReview, pk=id)
|
||||
if not check_visibility(review, request.session['oauth_token'], request.user):
|
||||
if not review.is_visible_to(request.user):
|
||||
msg = _("你没有访问这个页面的权限😥")
|
||||
return render(
|
||||
request,
|
||||
|
|
|
@ -65,11 +65,8 @@ class SongMarkForm(MarkForm):
|
|||
'status',
|
||||
'rating',
|
||||
'text',
|
||||
'is_private',
|
||||
'visibility',
|
||||
]
|
||||
labels = {
|
||||
'rating': _("评分"),
|
||||
}
|
||||
widgets = {
|
||||
'song': forms.TextInput(attrs={"hidden": ""}),
|
||||
}
|
||||
|
@ -84,14 +81,8 @@ class SongReviewForm(ReviewForm):
|
|||
'song',
|
||||
'title',
|
||||
'content',
|
||||
'is_private'
|
||||
'visibility'
|
||||
]
|
||||
labels = {
|
||||
'song': "",
|
||||
'title': _("标题"),
|
||||
'content': _("正文"),
|
||||
'share_to_mastodon': _("分享到长毛象")
|
||||
}
|
||||
widgets = {
|
||||
'song': forms.TextInput(attrs={"hidden": ""}),
|
||||
}
|
||||
|
@ -148,11 +139,8 @@ class AlbumMarkForm(MarkForm):
|
|||
'status',
|
||||
'rating',
|
||||
'text',
|
||||
'is_private',
|
||||
'visibility',
|
||||
]
|
||||
labels = {
|
||||
'rating': _("评分"),
|
||||
}
|
||||
widgets = {
|
||||
'album': forms.TextInput(attrs={"hidden": ""}),
|
||||
}
|
||||
|
@ -167,14 +155,8 @@ class AlbumReviewForm(ReviewForm):
|
|||
'album',
|
||||
'title',
|
||||
'content',
|
||||
'is_private'
|
||||
'visibility'
|
||||
]
|
||||
labels = {
|
||||
'album': "",
|
||||
'title': _("标题"),
|
||||
'content': _("正文"),
|
||||
'share_to_mastodon': _("分享到长毛象")
|
||||
}
|
||||
widgets = {
|
||||
'album': forms.TextInput(attrs={"hidden": ""}),
|
||||
}
|
||||
|
|
|
@ -225,7 +225,7 @@
|
|||
{% if others_mark.rating %}
|
||||
<span class="entity-marks__rating-star rating-star" data-rating-score="{{ others_mark.rating | floatformat:"0" }}"></span>
|
||||
{% endif %}
|
||||
{% if others_mark.is_private %}
|
||||
{% if others_mark.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z"/></svg></span>
|
||||
{% endif %}
|
||||
<span class="entity-marks__mark-time">{{ others_mark.edited_time }}</span>
|
||||
|
@ -250,7 +250,7 @@
|
|||
{% for others_review in review_list %}
|
||||
<li class="entity-reviews__review">
|
||||
<a href="{% url 'users:home' others_review.owner.id %}" class="entity-reviews__owner-link">{{ others_review.owner.username }}</a>
|
||||
{% if others_review.is_private %}
|
||||
{% if others_review.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z"/></svg></span>
|
||||
{% endif %}
|
||||
<span class="entity-reviews__review-time">{{ others_review.edited_time }}</span>
|
||||
|
@ -278,7 +278,7 @@
|
|||
<span class="mark-panel__rating-star rating-star" data-rating-score="{{ mark.rating | floatformat:"0" }}"></span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if mark.is_private %}
|
||||
{% if mark.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z"/></svg></span>
|
||||
{% endif %}
|
||||
<span class="mark-panel__actions">
|
||||
|
@ -321,7 +321,7 @@
|
|||
<div class="review-panel">
|
||||
|
||||
<span class="review-panel__label">{% trans '我的评论' %}</span>
|
||||
{% if review.is_private %}
|
||||
{% if review.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z"/></svg></span>
|
||||
{% endif %}
|
||||
|
||||
|
@ -415,8 +415,8 @@
|
|||
|
||||
<div class="mark-modal__option">
|
||||
<div class="mark-modal__visibility-radio">
|
||||
<span>{{ mark_form.is_private.label }}:</span>
|
||||
{{ mark_form.is_private }}
|
||||
<span>{{ mark_form.visibility.label }}:</span>
|
||||
{{ mark_form.visibility }}
|
||||
</div>
|
||||
<div class="mark-modal__share-checkbox">
|
||||
{{ mark_form.share_to_mastodon }}{{ mark_form.share_to_mastodon.label }}
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
<span class="entity-marks__rating-star rating-star"
|
||||
data-rating-score="{{ mark.rating | floatformat:" 0" }}"></span>
|
||||
{% endif %}
|
||||
{% if mark.is_private %}
|
||||
{% if mark.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 20 20">
|
||||
<path
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
<h5 class="review-head__title">
|
||||
{{ review.title }}
|
||||
</h5>
|
||||
{% if review.is_private %}
|
||||
{% if review.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
|
||||
<path
|
||||
d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z" />
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
<a href="{% url 'users:home' review.owner.id %}"
|
||||
class="entity-reviews__owner-link">{{ review.owner.username }}</a>
|
||||
{% if review.is_private %}
|
||||
{% if review.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 20 20">
|
||||
<path
|
||||
|
|
|
@ -96,7 +96,7 @@
|
|||
<div class="review-form__option">
|
||||
<div class="review-form__visibility-radio">
|
||||
|
||||
{{ form.is_private.label }}{{ form.is_private }}
|
||||
{{ form.visibility.label }}{{ form.visibility }}
|
||||
</div>
|
||||
<div class="review-form__share-checkbox">
|
||||
{{ form.share_to_mastodon }}{{ form.share_to_mastodon.label }}
|
||||
|
|
|
@ -100,7 +100,7 @@
|
|||
<div class="review-form__option">
|
||||
<div class="review-form__visibility-radio">
|
||||
|
||||
{{ form.is_private.label }}{{ form.is_private }}
|
||||
{{ form.visibility.label }}{{ form.visibility }}
|
||||
</div>
|
||||
<div class="review-form__share-checkbox">
|
||||
{{ form.share_to_mastodon }}{{ form.share_to_mastodon.label }}
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
<h5 class="review-head__title">
|
||||
{{ review.title }}
|
||||
</h5>
|
||||
{% if review.is_private %}
|
||||
{% if review.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 20 20">
|
||||
<path
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
<h5 class="review-head__title">
|
||||
{{ review.title }}
|
||||
</h5>
|
||||
{% if review.is_private %}
|
||||
{% if review.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 20 20">
|
||||
<path
|
||||
|
|
|
@ -171,7 +171,7 @@
|
|||
{% if others_mark.rating %}
|
||||
<span class="entity-marks__rating-star rating-star" data-rating-score="{{ others_mark.rating | floatformat:"0" }}"></span>
|
||||
{% endif %}
|
||||
{% if others_mark.is_private %}
|
||||
{% if others_mark.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z"/></svg></span>
|
||||
{% endif %}
|
||||
<span class="entity-marks__mark-time">{{ others_mark.edited_time }}</span>
|
||||
|
@ -196,7 +196,7 @@
|
|||
{% for others_review in review_list %}
|
||||
<li class="entity-reviews__review">
|
||||
<a href="{% url 'users:home' others_review.owner.id %}" class="entity-reviews__owner-link">{{ others_review.owner.username }}</a>
|
||||
{% if others_review.is_private %}
|
||||
{% if others_review.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z"/></svg></span>
|
||||
{% endif %}
|
||||
<span class="entity-reviews__review-time">{{ others_review.edited_time }}</span>
|
||||
|
@ -224,7 +224,7 @@
|
|||
<span class="mark-panel__rating-star rating-star" data-rating-score="{{ mark.rating | floatformat:"0" }}"></span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if mark.is_private %}
|
||||
{% if mark.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z"/></svg></span>
|
||||
{% endif %}
|
||||
<span class="mark-panel__actions">
|
||||
|
@ -267,7 +267,7 @@
|
|||
<div class="review-panel">
|
||||
|
||||
<span class="review-panel__label">{% trans '我的评论' %}</span>
|
||||
{% if review.is_private %}
|
||||
{% if review.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z"/></svg></span>
|
||||
{% endif %}
|
||||
|
||||
|
@ -361,8 +361,8 @@
|
|||
|
||||
<div class="mark-modal__option">
|
||||
<div class="mark-modal__visibility-radio">
|
||||
<span>{{ mark_form.is_private.label }}:</span>
|
||||
{{ mark_form.is_private }}
|
||||
<span>{{ mark_form.visibility.label }}:</span>
|
||||
{{ mark_form.visibility }}
|
||||
</div>
|
||||
<div class="mark-modal__share-checkbox">
|
||||
{{ mark_form.share_to_mastodon }}{{ mark_form.share_to_mastodon.label }}
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
<span class="entity-marks__rating-star rating-star"
|
||||
data-rating-score="{{ mark.rating | floatformat:" 0" }}"></span>
|
||||
{% endif %}
|
||||
{% if mark.is_private %}
|
||||
{% if mark.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 20 20">
|
||||
<path
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
<h5 class="review-head__title">
|
||||
{{ review.title }}
|
||||
</h5>
|
||||
{% if review.is_private %}
|
||||
{% if review.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
|
||||
<path
|
||||
d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z" />
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
<li class="entity-reviews__review entity-reviews__review--wider">
|
||||
|
||||
<a href="{% url 'users:home' review.owner.id %}" class="entity-reviews__owner-link">{{ review.owner.username }}</a>
|
||||
{% if review.is_private %}
|
||||
{% if review.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z"/></svg></span>
|
||||
{% endif %}
|
||||
<span class="entity-reviews__review-time">{{ review.edited_time }}</span>
|
||||
|
|
|
@ -5,7 +5,7 @@ from common.views import PAGE_LINK_NUMBER, jump_or_scrape
|
|||
from common.utils import PageLinksGenerator
|
||||
from mastodon.models import MastodonApplication
|
||||
from mastodon.utils import rating_to_emoji
|
||||
from mastodon.api import check_visibility, post_toot, TootVisibilityEnum
|
||||
from mastodon.api import post_toot, TootVisibilityEnum
|
||||
from mastodon import mastodon_request_included
|
||||
from django.core.paginator import Paginator
|
||||
from django.utils import timezone
|
||||
|
@ -323,7 +323,9 @@ def create_update_song_mark(request):
|
|||
return HttpResponseServerError("integrity error")
|
||||
|
||||
if form.cleaned_data['share_to_mastodon']:
|
||||
if form.cleaned_data['is_private']:
|
||||
if form.cleaned_data['visibility'] == 2:
|
||||
visibility = TootVisibilityEnum.DIRECT
|
||||
elif form.cleaned_data['visibility'] == 1:
|
||||
visibility = TootVisibilityEnum.PRIVATE
|
||||
else:
|
||||
visibility = TootVisibilityEnum.PUBLIC if request.user.preference.mastodon_publish_public else TootVisibilityEnum.UNLISTED
|
||||
|
@ -417,7 +419,9 @@ def create_song_review(request, song_id):
|
|||
form.instance.owner = request.user
|
||||
form.save()
|
||||
if form.cleaned_data['share_to_mastodon']:
|
||||
if form.cleaned_data['is_private']:
|
||||
if form.cleaned_data['visibility'] == 2:
|
||||
visibility = TootVisibilityEnum.DIRECT
|
||||
elif form.cleaned_data['visibility'] == 1:
|
||||
visibility = TootVisibilityEnum.PRIVATE
|
||||
else:
|
||||
visibility = TootVisibilityEnum.PUBLIC if request.user.preference.mastodon_publish_public else TootVisibilityEnum.UNLISTED
|
||||
|
@ -469,7 +473,9 @@ def update_song_review(request, id):
|
|||
form.instance.edited_time = timezone.now()
|
||||
form.save()
|
||||
if form.cleaned_data['share_to_mastodon']:
|
||||
if form.cleaned_data['is_private']:
|
||||
if form.cleaned_data['visibility'] == 2:
|
||||
visibility = TootVisibilityEnum.DIRECT
|
||||
elif form.cleaned_data['visibility'] == 1:
|
||||
visibility = TootVisibilityEnum.PRIVATE
|
||||
else:
|
||||
visibility = TootVisibilityEnum.PUBLIC if request.user.preference.mastodon_publish_public else TootVisibilityEnum.UNLISTED
|
||||
|
@ -524,7 +530,7 @@ def delete_song_review(request, id):
|
|||
def retrieve_song_review(request, id):
|
||||
if request.method == 'GET':
|
||||
review = get_object_or_404(SongReview, pk=id)
|
||||
if not check_visibility(review, request.session['oauth_token'], request.user):
|
||||
if not review.is_visible_to(request.user):
|
||||
msg = _("你没有访问这个页面的权限😥")
|
||||
return render(
|
||||
request,
|
||||
|
@ -890,7 +896,9 @@ def create_update_album_mark(request):
|
|||
return HttpResponseServerError("integrity error")
|
||||
|
||||
if form.cleaned_data['share_to_mastodon']:
|
||||
if form.cleaned_data['is_private']:
|
||||
if form.cleaned_data['visibility'] == 2:
|
||||
visibility = TootVisibilityEnum.DIRECT
|
||||
elif form.cleaned_data['visibility'] == 1:
|
||||
visibility = TootVisibilityEnum.PRIVATE
|
||||
else:
|
||||
visibility = TootVisibilityEnum.PUBLIC if request.user.preference.mastodon_publish_public else TootVisibilityEnum.UNLISTED
|
||||
|
@ -984,7 +992,9 @@ def create_album_review(request, album_id):
|
|||
form.instance.owner = request.user
|
||||
form.save()
|
||||
if form.cleaned_data['share_to_mastodon']:
|
||||
if form.cleaned_data['is_private']:
|
||||
if form.cleaned_data['visibility'] == 2:
|
||||
visibility = TootVisibilityEnum.DIRECT
|
||||
elif form.cleaned_data['visibility'] == 1:
|
||||
visibility = TootVisibilityEnum.PRIVATE
|
||||
else:
|
||||
visibility = TootVisibilityEnum.PUBLIC if request.user.preference.mastodon_publish_public else TootVisibilityEnum.UNLISTED
|
||||
|
@ -1036,7 +1046,9 @@ def update_album_review(request, id):
|
|||
form.instance.edited_time = timezone.now()
|
||||
form.save()
|
||||
if form.cleaned_data['share_to_mastodon']:
|
||||
if form.cleaned_data['is_private']:
|
||||
if form.cleaned_data['visibility'] == 2:
|
||||
visibility = TootVisibilityEnum.DIRECT
|
||||
elif form.cleaned_data['visibility'] == 1:
|
||||
visibility = TootVisibilityEnum.PRIVATE
|
||||
else:
|
||||
visibility = TootVisibilityEnum.PUBLIC if request.user.preference.mastodon_publish_public else TootVisibilityEnum.UNLISTED
|
||||
|
@ -1091,7 +1103,7 @@ def delete_album_review(request, id):
|
|||
def retrieve_album_review(request, id):
|
||||
if request.method == 'GET':
|
||||
review = get_object_or_404(AlbumReview, pk=id)
|
||||
if not check_visibility(review, request.session['oauth_token'], request.user):
|
||||
if not review.is_visible_to(request.user):
|
||||
msg = _("你没有访问这个页面的权限😥")
|
||||
return render(
|
||||
request,
|
||||
|
|
|
@ -187,7 +187,7 @@ class DoufenRowData:
|
|||
rating: int
|
||||
|
||||
|
||||
def add_new_mark(data, user, entity, entity_class, mark_class, tag_class, sheet, is_private):
|
||||
def add_new_mark(data, user, entity, entity_class, mark_class, tag_class, sheet, default_public):
|
||||
params = {
|
||||
'owner': user,
|
||||
'created_time': data.time,
|
||||
|
@ -195,7 +195,7 @@ def add_new_mark(data, user, entity, entity_class, mark_class, tag_class, sheet,
|
|||
'rating': data.rating,
|
||||
'text': data.content,
|
||||
'status': translate_status(sheet),
|
||||
'is_private': not is_private,
|
||||
'visibility': 0 if default_public else 1,
|
||||
entity_class.__name__.lower(): entity,
|
||||
}
|
||||
mark = mark_class.objects.create(**params)
|
||||
|
|
|
@ -118,7 +118,7 @@
|
|||
<span class="entity-marks__rating-star rating-star"
|
||||
data-rating-score="{{ mark.rating | floatformat:"0" }}" style="left: -4px;"></span>
|
||||
{% endif %}
|
||||
{% if mark.is_private %}
|
||||
{% if mark.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
|
||||
<path
|
||||
d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z" />
|
||||
|
|
|
@ -108,7 +108,7 @@
|
|||
<span class="entity-marks__rating-star rating-star"
|
||||
data-rating-score="{{ mark.rating | floatformat:"0" }}" style="left: -4px;"></span>
|
||||
{% endif %}
|
||||
{% if mark.is_private %}
|
||||
{% if mark.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
|
||||
<path
|
||||
d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z" />
|
||||
|
|
|
@ -121,7 +121,7 @@
|
|||
<span class="entity-marks__rating-star rating-star"
|
||||
data-rating-score="{{ mark.rating | floatformat:"0" }}" style="left: -4px;"></span>
|
||||
{% endif %}
|
||||
{% if mark.is_private %}
|
||||
{% if mark.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
|
||||
<path
|
||||
d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z" />
|
||||
|
|
|
@ -124,7 +124,7 @@
|
|||
<span class="entity-marks__rating-star rating-star"
|
||||
data-rating-score="{{ mark.rating | floatformat:"0" }}" style="left: -4px;"></span>
|
||||
{% endif %}
|
||||
{% if mark.is_private %}
|
||||
{% if mark.visibility > 0 %}
|
||||
<span class="icon-lock"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
|
||||
<path d="M17,8.48h-.73V6.27a6.27,6.27,0,1,0-12.53,0V8.48H3a.67.67,0,0,0-.67.67V19.33A.67.67,0,0,0,3,20H17a.67.67,0,0,0,.67-.67V9.15A.67.67,0,0,0,17,8.48ZM6.42,6.27h0a3.57,3.57,0,0,1,7.14,0h0V8.48H6.42Z" />
|
||||
</svg></span>
|
||||
|
|
Loading…
Add table
Reference in a new issue