Skip to content

Commit d8cda83

Browse files
authored
Merge pull request #675 from ejplatform/1.3.3-release-candidate
Minor Release 1.3.3 Ada Lovelace
2 parents 7241140 + fe11443 commit d8cda83

9 files changed

Lines changed: 40 additions & 28 deletions

File tree

src/ej_conversations/forms.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ def save_all(self, author, board=None, **kwargs):
5959
conversation.save()
6060

6161
# Save tags on the database
62-
for tag in self.cleaned_data['tags']:
63-
conversation.tags.add(tag)
62+
self.save_m2m()
6463

6564
# Save board
6665
if board:

src/ej_conversations/jinja2/ej/role/conversation-card.jinja2

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
<div class="ConversationCard">
33
<div class="ConversationTags">
44
<i class="fa fa-tags"></i>
5-
{% if tags %}
6-
{% for tag in tags %}
7-
{{ tag }}
8-
{% endfor %}
5+
{% if tag %}
6+
{# Only conversation first tag is shown in card to prevent overflow #}
7+
{{ tag }}
98
{% else %}
109
{{ _('Conversation') }}
1110
{% endif %}

src/ej_conversations/jinja2/ej_conversations/create.jinja2

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@
5454

5555
<p>{{ form.text }}</p>
5656

57-
<div class="Conversation-edit">
58-
<b>{{ _('Edit Conversation') }}</b>
59-
</div>
6057
</div>
6158
<div class="ConversationDetail-arrow"></div>
6259
</div>

src/ej_conversations/jinja2/ej_conversations/edit.jinja2

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,14 @@
1919
</span>
2020
</div>
2121

22-
{% if conversation.tags.count() > 0 %}
23-
{% set tags = (conversation.tags.all()[0]|string).title() %}
24-
{% else %}
25-
{% set tags = 'Tags' %}
26-
{% endif %}
27-
28-
<input type="hidden" name="tags" value="{{ tags }}" />
2922

3023
<div class="ConversationDetail">
3124
<div class="ConversationDetail-banner">
32-
<div class="ConversationTags"><i class="fa fa-tags"></i>
33-
{{ tags }}
34-
</div>
25+
<div class="ConversationTags">
26+
<div class="ConversationField">
27+
<i class="fa fa-tags"></i><input name="tags" value="{{ tags }}" />
28+
</div>
29+
</div>
3530

3631
<p><textarea onfocus="this.style.height = (this.scrollHeight) + 'px'" onkeyup="this.style.height = (this.scrollHeight) + 'px'" class="Conversation-edit-field" name="text" required id="id_text">{{ conversation.text }}</textarea></p>
3732

src/ej_conversations/jinja2/ej_conversations/moderate.jinja2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<div class="ConversationDetail">
88
<div class="ConversationDetail-banner">
99
<div class="ConversationTags"><i class="fa fa-tags"></i>
10-
{% if conversation.tags.count() > 0 %}
11-
{{ (conversation.tags.all()[0]|string).title() }}
10+
{% if tags %}
11+
{{ ', '.join(tags) }}
1212
{% else %}
1313
Tags
1414
{% endif %}

src/ej_conversations/roles.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ def conversation_card(conversation, request=None, url=None, **kwargs):
1919

2020
user = getattr(request, 'user', None)
2121
can_moderate = user.has_perm('ej.can_moderate_conversation', conversation)
22+
tag = conversation.tags.first() # only first is shown in card to prevent overflow
2223
return {
2324
'conversation': conversation,
2425
'url': url or conversation.get_absolute_url(),
25-
'tags': conversation.tags.all(),
26+
'tag': tag,
2627
'n_comments': conversation.approved_comments.count(),
2728
'n_votes': conversation.vote_count(),
2829
'n_followers': conversation.followers.count(),
@@ -41,7 +42,8 @@ def conversation_balloon(conversation, request=None, **kwargs):
4142
favorites = models.FavoriteConversation.objects
4243
is_authenticated = getattr(user, 'is_authenticated', False)
4344
is_favorite = is_authenticated and conversation.is_favorite(user)
44-
tags = list(map(str, conversation.tags.all()[:3]))
45+
tags = list(map(str, conversation.tags.all()))
46+
4547
return {
4648
'conversation': conversation,
4749
'tags': tags,

src/ej_conversations/routes/admin.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,16 @@ def get_conversation_edit_context(request, conversation):
4343
instance=conversation,
4444
)
4545
if form.is_valid():
46-
form.instance.save()
46+
form.save()
4747
return redirect(conversation.get_absolute_url() + 'moderate/')
4848
else:
4949
form = forms.ConversationForm(instance=conversation)
50+
tags = list(map(str, conversation.tags.all()))
5051

5152
return {
5253
'form': form,
5354
'conversation': conversation,
55+
'tags': ",".join(tags),
5456
'can_promote_conversation': request.user.has_perm('can_publish_promoted'),
5557
'comments': list(conversation.comments.filter(status='pending')),
5658
'manage_stereotypes_url': conversation.get_absolute_url() + 'stereotypes/',
@@ -80,10 +82,12 @@ def get_conversation_moderate_context(request, conversation):
8082
comment.save()
8183

8284
status = request.GET.get('status', 'pending')
85+
tags = list(map(str, conversation.tags.all()))
8386

8487
return {
8588
'conversation': conversation,
8689
'comment_status': status,
8790
'edit_url': conversation.get_absolute_url() + 'edit/',
8891
'comments': list(conversation.comments.filter(status=status)),
92+
'tags': tags,
8993
}

src/ej_conversations/tests/test_forms.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,22 @@ def test_conversation_form_save_without_author(self, db):
141141
is_promoted=True,
142142
)
143143

144+
def test_edit_conversation_form(self, db, conversation):
145+
conversation.tags.add('oldtag')
146+
form = ConversationForm(
147+
data={'title': 'tiaatle',
148+
'tags': 'newtag',
149+
'text': 'description',
150+
'comments_count': 0, },
151+
instance=conversation,
152+
)
153+
154+
assert form.is_valid()
155+
form.save()
156+
conversation.refresh_from_db()
157+
assert str(conversation.tags.first()) == 'newtag'
158+
assert conversation.tags.count() == 1
159+
144160

145161
class TestCommentForm:
146162
def test_init(self, conversation):

src/ej_users/socialbuttons.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def social_buttons(request):
4949
def facebook_button(request):
5050
provider = providers.registry.by_id('facebook', request)
5151
query = {
52-
'next': '/conversations/',
52+
'next': request.GET.get('next', '/conversations/'),
5353
'method': 'oauth2',
5454
}
5555
url = provider.get_login_url(request, **query)
@@ -61,7 +61,7 @@ def facebook_button(request):
6161
def twitter_button(request):
6262
provider = providers.registry.by_id('twitter', request)
6363
query = {
64-
'next': '/conversations/',
64+
'next': request.GET.get('next', '/conversations/'),
6565
}
6666
url = provider.get_login_url(request, **query)
6767
return fa_icon('twitter', href=url, id='twitter-button', aria_label="Twitter Icon",
@@ -72,7 +72,7 @@ def twitter_button(request):
7272
def github_button(request):
7373
provider = providers.registry.by_id('github', request)
7474
query = {
75-
'next': '/conversations/',
75+
'next': request.GET.get('next', '/conversations/'),
7676
}
7777
url = provider.get_login_url(request, **query)
7878
return fa_icon('github', href=url, id='github-button')
@@ -82,7 +82,7 @@ def github_button(request):
8282
def google_button(request):
8383
provider = providers.registry.by_id('google', request)
8484
query = {
85-
'next': '/conversations/',
85+
'next': request.GET.get('next', '/conversations/'),
8686
}
8787
url = provider.get_login_url(request, **query)
8888
return fa_icon('google', href=url, id='google-button', aria_label="Google Icon",

0 commit comments

Comments
 (0)