- {% if not type == 'reply' %}
+ {% if type != 'reply' and type != 'direct' %}
{% endif %}
@@ -35,7 +35,7 @@
{% else %}
{% include 'snippets/content_warning_field.html' with parent_status=status %}
-
+
{% endif %}
{% if type == 'quotation' %}
@@ -53,7 +53,12 @@
{% include 'snippets/toggle/toggle_button.html' with text="Include spoiler alert" icon="warning is-size-4" controls_text="spoilers" controls_uid=uuid focus="id_content_warning" checkbox="id_show_spoilers" class="toggle-button" pressed=status.content_warning %}
- {% include 'snippets/privacy_select.html' with current=reply_parent.privacy%}
+ {% if type == 'direct' %}
+
+
+ {% else %}
+ {% include 'snippets/privacy_select.html' with current=reply_parent.privacy %}
+ {% endif %}
diff --git a/bookwyrm/templates/snippets/status_options.html b/bookwyrm/templates/snippets/status_options.html
index a6609cb30..3bf8251f6 100644
--- a/bookwyrm/templates/snippets/status_options.html
+++ b/bookwyrm/templates/snippets/status_options.html
@@ -18,6 +18,9 @@
{% else %}
+
+ Send direct message
+
{% include 'snippets/block_button.html' with user=status.user class="is-fullwidth" %}
diff --git a/bookwyrm/templates/snippets/user_options.html b/bookwyrm/templates/snippets/user_options.html
index ab68c2e3c..bc54ca1c7 100644
--- a/bookwyrm/templates/snippets/user_options.html
+++ b/bookwyrm/templates/snippets/user_options.html
@@ -8,6 +8,9 @@
{% endblock %}
{% block dropdown-list %}
+
+ Send direct message
+
{% include 'snippets/block_button.html' with user=user class="is-fullwidth" %}
diff --git a/bookwyrm/templates/user/user_layout.html b/bookwyrm/templates/user/user_layout.html
index 3fcbf1e2f..1ab51ce32 100644
--- a/bookwyrm/templates/user/user_layout.html
+++ b/bookwyrm/templates/user/user_layout.html
@@ -42,7 +42,7 @@
{% endif %}
- {% if not is_self %}
+ {% if not is_self and request.user.is_authenticated %}
{% include 'snippets/follow_button.html' with user=user %}
diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py
index d232747f9..6d759ac21 100644
--- a/bookwyrm/urls.py
+++ b/bookwyrm/urls.py
@@ -62,6 +62,8 @@ urlpatterns = [
# feeds
re_path(r'^(?Phome|local|federated)/?$', views.Feed.as_view()),
re_path(r'^direct-messages/?$', views.DirectMessage.as_view()),
+ re_path(r'^direct-messages/(?P%s)?$' % regex.username,
+ views.DirectMessage.as_view()),
# search
re_path(r'^search/?$', views.Search.as_view()),
diff --git a/bookwyrm/views/feed.py b/bookwyrm/views/feed.py
index 931cf355c..0e550f0c8 100644
--- a/bookwyrm/views/feed.py
+++ b/bookwyrm/views/feed.py
@@ -1,6 +1,7 @@
''' non-interactive pages '''
from django.contrib.auth.decorators import login_required
from django.core.paginator import Paginator
+from django.db.models import Q
from django.http import HttpResponseNotFound
from django.template.response import TemplateResponse
from django.utils import timezone
@@ -44,6 +45,7 @@ class Feed(View):
'activities': paginated.page(page),
'tab': tab,
'goal_form': forms.GoalForm(),
+ 'path': '/%s' % tab,
}}
return TemplateResponse(request, 'feed/feed.html', data)
@@ -51,20 +53,35 @@ class Feed(View):
@method_decorator(login_required, name='dispatch')
class DirectMessage(View):
''' dm view '''
- def get(self, request):
+ def get(self, request, username=None):
''' like a feed but for dms only '''
try:
page = int(request.GET.get('page', 1))
except ValueError:
page = 1
- activities = get_activity_feed(request.user, 'direct')
+ queryset = models.Status.objects
+
+ user = None
+ if username:
+ try:
+ user = get_user_from_username(username)
+ except models.User.DoesNotExist:
+ pass
+ if user:
+ queryset = queryset.filter(Q(user=user) | Q(mention_users=user))
+
+ activities = get_activity_feed(
+ request.user, 'direct', queryset=queryset)
+
paginated = Paginator(activities, PAGE_LENGTH)
activity_page = paginated.page(page)
data = {**feed_page_data(request.user), **{
'title': 'Direct Messages',
'user': request.user,
+ 'partner': user,
'activities': activity_page,
+ 'path': '/direct-messages',
}}
return TemplateResponse(request, 'feed/direct_messages.html', data)