mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-21 17:11:06 +00:00
Merge pull request #3418 from bookwyrm-social/hide-ratings
Hide ratings
This commit is contained in:
commit
23dfe3924d
6 changed files with 57 additions and 2 deletions
|
@ -18,6 +18,7 @@ class EditUserForm(CustomForm):
|
|||
"email",
|
||||
"summary",
|
||||
"show_goal",
|
||||
"show_ratings",
|
||||
"show_suggested_users",
|
||||
"manually_approves_followers",
|
||||
"default_post_privacy",
|
||||
|
|
18
bookwyrm/migrations/0209_user_show_ratings.py
Normal file
18
bookwyrm/migrations/0209_user_show_ratings.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 4.2.15 on 2024-08-24 01:16
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("bookwyrm", "0208_merge_0207_merge_20240629_0626_0207_sqlparse_update"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="user",
|
||||
name="show_ratings",
|
||||
field=models.BooleanField(default=True),
|
||||
),
|
||||
]
|
|
@ -141,7 +141,6 @@ class User(OrderedCollectionPageMixin, AbstractUser):
|
|||
hide_follows = fields.BooleanField(default=False)
|
||||
|
||||
# migration fields
|
||||
|
||||
moved_to = fields.RemoteIdField(
|
||||
null=True, unique=False, activitypub_field="movedTo", deduplication_field=False
|
||||
)
|
||||
|
@ -158,6 +157,7 @@ class User(OrderedCollectionPageMixin, AbstractUser):
|
|||
show_suggested_users = models.BooleanField(default=True)
|
||||
discoverable = fields.BooleanField(default=False)
|
||||
show_guided_tour = models.BooleanField(default=True)
|
||||
show_ratings = models.BooleanField(default=True)
|
||||
|
||||
# feed options
|
||||
feed_status_types = DjangoArrayField(
|
||||
|
|
|
@ -14,6 +14,10 @@ let BookWyrm = new (class {
|
|||
.querySelectorAll("[data-controls]")
|
||||
.forEach((button) => button.addEventListener("click", this.toggleAction.bind(this)));
|
||||
|
||||
document
|
||||
.querySelectorAll("[data-disappear]")
|
||||
.forEach((button) => button.addEventListener("click", this.hideSelf.bind(this)));
|
||||
|
||||
document
|
||||
.querySelectorAll(".interaction")
|
||||
.forEach((button) => button.addEventListener("submit", this.interact.bind(this)));
|
||||
|
@ -181,6 +185,18 @@ let BookWyrm = new (class {
|
|||
this.addRemoveClass(visible, "is-hidden", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide the element you just clicked
|
||||
*
|
||||
* @param {Event} event
|
||||
* @return {undefined}
|
||||
*/
|
||||
hideSelf(event) {
|
||||
let trigger = event.currentTarget;
|
||||
|
||||
this.addRemoveClass(trigger, "is-hidden", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute actions on targets based on triggers.
|
||||
*
|
||||
|
|
|
@ -69,6 +69,12 @@
|
|||
{% trans "Show reading goal prompt in feed" %}
|
||||
</label>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="checkbox label" for="id_show_ratings">
|
||||
{{ form.show_ratings }}
|
||||
{% trans "Show ratings" %}
|
||||
</label>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="checkbox label" for="id_show_suggested_users">
|
||||
{{ form.show_suggested_users }}
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
{% spaceless %}
|
||||
{% load utilities %}
|
||||
{% load i18n %}
|
||||
|
||||
<span class="stars">
|
||||
{% with 0|uuid as uuid %}
|
||||
<span class="stars tag">
|
||||
{% if not request.user.show_ratings %}
|
||||
|
||||
<button type="button" data-controls="rating-{{ uuid }}" id="rating-button-{{ uuid }}" aria-pressed="false" data-disappear>
|
||||
<em>{% trans "Show rating" %} </em>
|
||||
</button>
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% if rating %}
|
||||
<span class="{% if not request.user.show_ratings %}is-hidden{% endif %}" id="rating-{{ uuid }}">
|
||||
<span class="is-sr-only">
|
||||
{% blocktranslate trimmed with rating=rating|floatformat:0 count counter=rating|floatformat:0|add:0 %}
|
||||
{{ rating }} star
|
||||
|
@ -19,8 +30,11 @@
|
|||
aria-hidden="true"
|
||||
></span>
|
||||
{% endfor %}
|
||||
</span>
|
||||
{% else %}
|
||||
<span class="no-rating">{% trans "No rating" %}</span>
|
||||
{% endif %}
|
||||
|
||||
</span>
|
||||
{% endwith %}
|
||||
{% endspaceless %}
|
||||
|
|
Loading…
Reference in a new issue