diff --git a/bookwyrm/templates/feed/direct_messages.html b/bookwyrm/templates/feed/direct_messages.html index 1f41808fb..8c53cbeb1 100644 --- a/bookwyrm/templates/feed/direct_messages.html +++ b/bookwyrm/templates/feed/direct_messages.html @@ -1,25 +1,26 @@ {% extends 'feed/feed_layout.html' %} {% block panel %} -
-

Direct Messages

+
+

Direct Messages{% if partner %} with {% include 'snippets/username.html' with user=partner %}{% endif %}

+ {% if partner %}

All messages

{% endif %} +
-
- {% include 'snippets/create_status_form.html' with type="direct" uuid=1 %} -
- -
- {% if not activities %} -

You have no messages right now.

- {% endif %} - {% for activity in activities %} -
- {% include 'snippets/status.html' with status=activity %} -
- {% endfor %} - - {% include 'snippets/pagination.html' with page=activities path="direct-messages" %} -
+
+ {% include 'snippets/create_status_form.html' with type="direct" uuid=1 mentions=partner %}
+
+ {% if not activities %} +

You have no messages right now.

+ {% endif %} + {% for activity in activities %} +
+ {% include 'snippets/status.html' with status=activity %} +
+ {% endfor %} + + {% include 'snippets/pagination.html' with page=activities path="direct-messages" %} +
+ {% endblock %} diff --git a/bookwyrm/templates/snippets/create_status_form.html b/bookwyrm/templates/snippets/create_status_form.html index 534ace290..c6d7be3f2 100644 --- a/bookwyrm/templates/snippets/create_status_form.html +++ b/bookwyrm/templates/snippets/create_status_form.html @@ -35,7 +35,7 @@ {% else %} {% include 'snippets/content_warning_field.html' with parent_status=status %} - + {% endif %}
{% if type == 'quotation' %} 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 08a5e057a..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 @@ -52,19 +53,33 @@ 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', }}