- {% if conversation.tags.count() > 0 %}
- {{ (conversation.tags.all()[0]|string).title() }}
+ {% if tags %}
+ {{ ', '.join(tags) }}
{% else %}
Tags
{% endif %}
diff --git a/src/ej_conversations/roles.py b/src/ej_conversations/roles.py
index 8d59afab9..2e1eedbef 100644
--- a/src/ej_conversations/roles.py
+++ b/src/ej_conversations/roles.py
@@ -19,10 +19,11 @@ def conversation_card(conversation, request=None, url=None, **kwargs):
user = getattr(request, 'user', None)
can_moderate = user.has_perm('ej.can_moderate_conversation', conversation)
+ tag = conversation.tags.first() # only first is shown in card to prevent overflow
return {
'conversation': conversation,
'url': url or conversation.get_absolute_url(),
- 'tags': conversation.tags.all(),
+ 'tag': tag,
'n_comments': conversation.approved_comments.count(),
'n_votes': conversation.vote_count(),
'n_followers': conversation.followers.count(),
@@ -41,7 +42,8 @@ def conversation_balloon(conversation, request=None, **kwargs):
favorites = models.FavoriteConversation.objects
is_authenticated = getattr(user, 'is_authenticated', False)
is_favorite = is_authenticated and conversation.is_favorite(user)
- tags = list(map(str, conversation.tags.all()[:3]))
+ tags = list(map(str, conversation.tags.all()))
+
return {
'conversation': conversation,
'tags': tags,
diff --git a/src/ej_conversations/routes/admin.py b/src/ej_conversations/routes/admin.py
index b899b3d72..c2aa91803 100644
--- a/src/ej_conversations/routes/admin.py
+++ b/src/ej_conversations/routes/admin.py
@@ -43,14 +43,16 @@ def get_conversation_edit_context(request, conversation):
instance=conversation,
)
if form.is_valid():
- form.instance.save()
+ form.save()
return redirect(conversation.get_absolute_url() + 'moderate/')
else:
form = forms.ConversationForm(instance=conversation)
+ tags = list(map(str, conversation.tags.all()))
return {
'form': form,
'conversation': conversation,
+ 'tags': ",".join(tags),
'can_promote_conversation': request.user.has_perm('can_publish_promoted'),
'comments': list(conversation.comments.filter(status='pending')),
'manage_stereotypes_url': conversation.get_absolute_url() + 'stereotypes/',
@@ -80,10 +82,12 @@ def get_conversation_moderate_context(request, conversation):
comment.save()
status = request.GET.get('status', 'pending')
+ tags = list(map(str, conversation.tags.all()))
return {
'conversation': conversation,
'comment_status': status,
'edit_url': conversation.get_absolute_url() + 'edit/',
'comments': list(conversation.comments.filter(status=status)),
+ 'tags': tags,
}
diff --git a/src/ej_conversations/tests/test_forms.py b/src/ej_conversations/tests/test_forms.py
index 80bd6cc2f..895a8dbe9 100644
--- a/src/ej_conversations/tests/test_forms.py
+++ b/src/ej_conversations/tests/test_forms.py
@@ -141,6 +141,22 @@ def test_conversation_form_save_without_author(self, db):
is_promoted=True,
)
+ def test_edit_conversation_form(self, db, conversation):
+ conversation.tags.add('oldtag')
+ form = ConversationForm(
+ data={'title': 'tiaatle',
+ 'tags': 'newtag',
+ 'text': 'description',
+ 'comments_count': 0, },
+ instance=conversation,
+ )
+
+ assert form.is_valid()
+ form.save()
+ conversation.refresh_from_db()
+ assert str(conversation.tags.first()) == 'newtag'
+ assert conversation.tags.count() == 1
+
class TestCommentForm:
def test_init(self, conversation):
diff --git a/src/ej_users/socialbuttons.py b/src/ej_users/socialbuttons.py
index 1d2f9348b..93043f1de 100644
--- a/src/ej_users/socialbuttons.py
+++ b/src/ej_users/socialbuttons.py
@@ -49,7 +49,7 @@ def social_buttons(request):
def facebook_button(request):
provider = providers.registry.by_id('facebook', request)
query = {
- 'next': '/conversations/',
+ 'next': request.GET.get('next', '/conversations/'),
'method': 'oauth2',
}
url = provider.get_login_url(request, **query)
@@ -61,7 +61,7 @@ def facebook_button(request):
def twitter_button(request):
provider = providers.registry.by_id('twitter', request)
query = {
- 'next': '/conversations/',
+ 'next': request.GET.get('next', '/conversations/'),
}
url = provider.get_login_url(request, **query)
return fa_icon('twitter', href=url, id='twitter-button', aria_label="Twitter Icon",
@@ -72,7 +72,7 @@ def twitter_button(request):
def github_button(request):
provider = providers.registry.by_id('github', request)
query = {
- 'next': '/conversations/',
+ 'next': request.GET.get('next', '/conversations/'),
}
url = provider.get_login_url(request, **query)
return fa_icon('github', href=url, id='github-button')
@@ -82,7 +82,7 @@ def github_button(request):
def google_button(request):
provider = providers.registry.by_id('google', request)
query = {
- 'next': '/conversations/',
+ 'next': request.GET.get('next', '/conversations/'),
}
url = provider.get_login_url(request, **query)
return fa_icon('google', href=url, id='google-button', aria_label="Google Icon",