mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-26 01:50:34 +00:00
Merge pull request #548 from mouse-reeve/at-mentions
puts @'mentions directly in compose box
This commit is contained in:
commit
2809095966
5 changed files with 8 additions and 7 deletions
|
@ -112,7 +112,9 @@ function toggleAction(e) {
|
|||
// set focus, if appropriate
|
||||
var focus = el.getAttribute('data-focus-target');
|
||||
if (focus) {
|
||||
document.getElementById(focus).focus();
|
||||
var focusEl = document.getElementById(focus);
|
||||
focusEl.focus();
|
||||
setTimeout(function(){ focusEl.selectionStart = focusEl.selectionEnd = 10000; }, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
{% load bookwyrm_tags %}
|
||||
<form class="is-flex-grow-1" name="{{ type }}" action="/post/{{ type }}" method="post" id="tab-{{ type }}-{{ book.id }}{{ reply_parent.id }}">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="book" value="{{ book.id }}">
|
||||
|
@ -34,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></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 %}</textarea>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if type == 'quotation' %}
|
||||
|
|
|
@ -142,10 +142,10 @@ def get_markdown(content):
|
|||
|
||||
@register.filter(name='mentions')
|
||||
def get_mentions(status, user):
|
||||
''' anyone tagged or replied to in this status '''
|
||||
''' people to @ in a reply: the parent and all mentions '''
|
||||
mentions = set([status.user] + list(status.mention_users.all()))
|
||||
return ' '.join(
|
||||
'@' + get_user_identifier(m) for m in mentions if not m == user)
|
||||
'@' + get_user_identifier(m) for m in mentions if not m == user) + ' '
|
||||
|
||||
@register.filter(name='status_preview_name')
|
||||
def get_status_preview_name(obj):
|
||||
|
|
|
@ -228,7 +228,7 @@ class TemplateTags(TestCase):
|
|||
status = models.Status.objects.create(
|
||||
content='hi', user=self.remote_user)
|
||||
result = bookwyrm_tags.get_mentions(status, self.user)
|
||||
self.assertEqual(result, '@rat@example.com')
|
||||
self.assertEqual(result, '@rat@example.com ')
|
||||
|
||||
|
||||
def test_get_status_preview_name(self):
|
||||
|
|
|
@ -86,8 +86,6 @@ class CreateStatus(View):
|
|||
# add reply parent to mentions and notify
|
||||
if status.reply_parent:
|
||||
status.mention_users.add(status.reply_parent.user)
|
||||
for mention_user in status.reply_parent.mention_users.all():
|
||||
status.mention_users.add(mention_user)
|
||||
|
||||
if status.reply_parent.user.local:
|
||||
create_notification(
|
||||
|
|
Loading…
Reference in a new issue