From 6548291571155494f5ed48548a0934d60b43c3be Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 25 Mar 2021 08:39:45 -0700 Subject: [PATCH] Adds join directory insert --- bookwyrm/templates/directory.html | 17 +++++++++++++++++ bookwyrm/views/directory.py | 7 +++++++ 2 files changed, 24 insertions(+) diff --git a/bookwyrm/templates/directory.html b/bookwyrm/templates/directory.html index 9323752f..9e1cfae9 100644 --- a/bookwyrm/templates/directory.html +++ b/bookwyrm/templates/directory.html @@ -11,6 +11,23 @@ {% trans "Directory" %} + +{% if not request.user.discoverable %} +
+ {% url 'settings-profile' as path %} +

+ {% trans "Make your profile discoverable so other BookWyrm users can find you." %} +

+
+ {% csrf_token %} + +

+ {% blocktrans %}You can opt-out at any time in your profile settings{% endblocktrans %} +

+
+
+{% endif %} +
{% for user in users %}
diff --git a/bookwyrm/views/directory.py b/bookwyrm/views/directory.py index cc21baf2..addb85c2 100644 --- a/bookwyrm/views/directory.py +++ b/bookwyrm/views/directory.py @@ -1,6 +1,7 @@ """ who all's here? """ from django.contrib.auth.decorators import login_required from django.core.paginator import Paginator +from django.shortcuts import redirect from django.template.response import TemplateResponse from django.views import View from django.utils.decorators import method_decorator @@ -30,3 +31,9 @@ class Directory(View): "users": paginated.page(page), } return TemplateResponse(request, "directory.html", data) + + def post(self, request): + """ join the directory """ + request.user.discoverable = True + request.user.save() + return redirect('directory')