forked from mirrors/bookwyrm
Merge pull request #568 from mouse-reeve/send-dms
Compose window for dms
This commit is contained in:
commit
02c466e04a
9 changed files with 54 additions and 11 deletions
|
@ -92,6 +92,12 @@ class ReplyForm(CustomForm):
|
|||
'user', 'content', 'content_warning', 'sensitive',
|
||||
'reply_parent', 'privacy']
|
||||
|
||||
class StatusForm(CustomForm):
|
||||
class Meta:
|
||||
model = models.Status
|
||||
fields = [
|
||||
'user', 'content', 'content_warning', 'sensitive', 'privacy']
|
||||
|
||||
|
||||
class EditUserForm(CustomForm):
|
||||
class Meta:
|
||||
|
|
|
@ -1,9 +1,16 @@
|
|||
{% 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 mentions=partner %}
|
||||
</div>
|
||||
|
||||
<section class="block">
|
||||
{% if not activities %}
|
||||
<p>You have no messages right now.</p>
|
||||
{% endif %}
|
||||
|
@ -14,6 +21,6 @@
|
|||
{% endfor %}
|
||||
|
||||
{% include 'snippets/pagination.html' with page=activities path="direct-messages" %}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
{% block panel %}{% endblock %}
|
||||
|
||||
{% if activities %}
|
||||
{% include 'snippets/pagination.html' with page=activities path='/'|add:tab anchor="#feed" %}
|
||||
{% include 'snippets/pagination.html' with page=activities path=path anchor="#feed" %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% load bookwyrm_tags %}
|
||||
<form class="is-flex-grow-1" name="{{ type }}" action="/post/{{ type }}" method="post" id="tab-{{ type }}-{{ book.id }}{{ reply_parent.id }}">
|
||||
<form class="is-flex-grow-1" name="{{ type }}" action="/post/{% if type == 'direct' %}status{% else %}{{ type }}{% endif %}" method="post" id="tab-{{ type }}-{{ book.id }}{{ reply_parent.id }}">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="book" value="{{ book.id }}">
|
||||
<input type="hidden" name="user" value="{{ request.user.id }}">
|
||||
|
@ -11,7 +11,7 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
<div class="control">
|
||||
{% if not type == 'reply' %}
|
||||
{% if type != 'reply' and type != 'direct' %}
|
||||
<label class="label" for="id_{% if type == 'quotation' %}quote{% else %}content{% endif %}_{{ book.id }}_{{ type }}">{{ type|title }}:</label>
|
||||
{% endif %}
|
||||
|
||||
|
@ -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' %}
|
||||
|
@ -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 %}
|
||||
</div>
|
||||
<div class="control">
|
||||
{% include 'snippets/privacy_select.html' with current=reply_parent.privacy%}
|
||||
{% if type == 'direct' %}
|
||||
<input type="hidden" name="privacy" value="direct">
|
||||
<button type="button" class="button" aria-label="Privacy" disabled>Private</button>
|
||||
{% else %}
|
||||
{% include 'snippets/privacy_select.html' with current=reply_parent.privacy %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="column is-narrow">
|
||||
|
|
|
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue