add show_guided_tour value to User

This boolean value indicates whether the user wishes to be show the guided tour.
It defaults to True but will be able to be easily set to False.
This commit is contained in:
Hugh Rundle 2022-06-13 13:07:48 +10:00
parent 2b431986d6
commit 80c71928c3
4 changed files with 28 additions and 1 deletions

View file

@ -0,0 +1,19 @@
# Generated by Django 3.2.13 on 2022-06-13 01:59
import bookwyrm.models.fields
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('bookwyrm', '0150_readthrough_stopped_date'),
]
operations = [
migrations.AddField(
model_name='user',
name='show_guided_tour',
field=bookwyrm.models.fields.BooleanField(default=True),
),
]

View file

@ -143,6 +143,7 @@ class User(OrderedCollectionPageMixin, AbstractUser):
show_goal = models.BooleanField(default=True)
show_suggested_users = models.BooleanField(default=True)
discoverable = fields.BooleanField(default=False)
show_guided_tour = fields.BooleanField(default=True)
# feed options
feed_status_types = ArrayField(

View file

@ -127,7 +127,7 @@ from .setup import InstanceConfig, CreateAdmin
from .status import CreateStatus, EditStatus, DeleteStatus, update_progress
from .status import edit_readthrough
from .updates import get_notification_count, get_unread_status_string
from .user import User, Followers, Following, hide_suggestions, user_redirect
from .user import User, Followers, Following, hide_suggestions, user_redirect, toggle_guided_tour
from .wellknown import *
from .annual_summary import (
AnnualSummary,

View file

@ -165,3 +165,10 @@ def hide_suggestions(request):
def user_redirect(request, username):
"""redirect to a user's feed"""
return redirect("user-feed", username=username)
@login_required
def toggle_guided_tour(request):
"""most people don't want a tour every time they load a page"""
request.user.show_guided_tour = request.GET.get("tour")
request.user.save(broadcast=False, update_fields=["show_guided_tour"])
return redirect("/")