mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-27 12:01:14 +00:00
Send message to a particular user
This commit is contained in:
parent
779a5e0cbf
commit
93ef9e31ad
7 changed files with 46 additions and 22 deletions
|
@ -1,25 +1,26 @@
|
|||
{% extends 'feed/feed_layout.html' %}
|
||||
{% block panel %}
|
||||
|
||||
<div class="block">
|
||||
<h1 class="title">Direct Messages</h1>
|
||||
<header class="block">
|
||||
<h1 class="title">Direct Messages{% if partner %} with {% include 'snippets/username.html' with user=partner %}{% endif %}</h1>
|
||||
{% if partner %}<p class="subtitle"><a href="/direct-messages"><span class="icon icon-arrow-left" aria-hidden="true"></span> All messages</a></p>{% endif %}
|
||||
</header>
|
||||
|
||||
<div class="box">
|
||||
{% include 'snippets/create_status_form.html' with type="direct" uuid=1 %}
|
||||
</div>
|
||||
|
||||
<section class="block">
|
||||
{% if not activities %}
|
||||
<p>You have no messages right now.</p>
|
||||
{% endif %}
|
||||
{% for activity in activities %}
|
||||
<div class="block">
|
||||
{% include 'snippets/status.html' with status=activity %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% include 'snippets/pagination.html' with page=activities path="direct-messages" %}
|
||||
</section>
|
||||
<div class="box">
|
||||
{% include 'snippets/create_status_form.html' with type="direct" uuid=1 mentions=partner %}
|
||||
</div>
|
||||
|
||||
<section class="block">
|
||||
{% if not activities %}
|
||||
<p>You have no messages right now.</p>
|
||||
{% endif %}
|
||||
{% for activity in activities %}
|
||||
<div class="block">
|
||||
{% include 'snippets/status.html' with status=activity %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% include 'snippets/pagination.html' with page=activities path="direct-messages" %}
|
||||
</section>
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
<textarea name="quote" class="textarea" id="id_quote_{{ book.id }}_{{ type }}" placeholder="{{ placeholder }}" required></textarea>
|
||||
{% else %}
|
||||
{% include 'snippets/content_warning_field.html' with parent_status=status %}
|
||||
<textarea name="content" class="textarea" id="id_content_{{ type }}-{{ book.id }}{{reply_parent.id}}" placeholder="{{ placeholder }}" {% if type == 'reply' %} aria-label="Reply"{% endif %} required>{% if reply_parent %}{{ reply_parent|mentions:request.user }}{% endif %}</textarea>
|
||||
<textarea name="content" class="textarea" id="id_content_{{ type }}-{{ book.id }}{{reply_parent.id}}" placeholder="{{ placeholder }}" {% if type == 'reply' %} aria-label="Reply"{% endif %} required>{% if reply_parent %}{{ reply_parent|mentions:request.user }}{% endif %}{% if mentions %}@{{ mentions|username }} {% endif %}</textarea>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if type == 'quotation' %}
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
</form>
|
||||
</li>
|
||||
{% else %}
|
||||
<li role="menuitem">
|
||||
<a href="/direct-messages/{{ status.user|username }}" class="button is-fullwidth is-small">Send direct message</a>
|
||||
</li>
|
||||
<li role="menuitem">
|
||||
{% include 'snippets/block_button.html' with user=status.user class="is-fullwidth" %}
|
||||
</li>
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block dropdown-list %}
|
||||
<li role="menuitem">
|
||||
<a href="/direct-messages/{{ user|username }}" class="button is-fullwidth is-small">Send direct message</a>
|
||||
</li>
|
||||
<li role="menuitem">
|
||||
{% include 'snippets/block_button.html' with user=user class="is-fullwidth" %}
|
||||
</li>
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% if not is_self %}
|
||||
{% if not is_self and request.user.is_authenticated %}
|
||||
<div class="field has-addons">
|
||||
<div class="control">
|
||||
{% include 'snippets/follow_button.html' with user=user %}
|
||||
|
|
|
@ -62,6 +62,8 @@ urlpatterns = [
|
|||
# feeds
|
||||
re_path(r'^(?P<tab>home|local|federated)/?$', views.Feed.as_view()),
|
||||
re_path(r'^direct-messages/?$', views.DirectMessage.as_view()),
|
||||
re_path(r'^direct-messages/(?P<username>%s)?$' % regex.username,
|
||||
views.DirectMessage.as_view()),
|
||||
|
||||
# search
|
||||
re_path(r'^search/?$', views.Search.as_view()),
|
||||
|
|
|
@ -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',
|
||||
}}
|
||||
|
|
Loading…
Reference in a new issue