Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #675 from ejplatform/1.3.3-release-candidate
Browse files Browse the repository at this point in the history
Minor Release 1.3.3 Ada Lovelace
  • Loading branch information
pablodiegoss authored Dec 3, 2018
2 parents 7241140 + fe11443 commit d8cda83
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 28 deletions.
3 changes: 1 addition & 2 deletions src/ej_conversations/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ def save_all(self, author, board=None, **kwargs):
conversation.save()

# Save tags on the database
for tag in self.cleaned_data['tags']:
conversation.tags.add(tag)
self.save_m2m()

# Save board
if board:
Expand Down
7 changes: 3 additions & 4 deletions src/ej_conversations/jinja2/ej/role/conversation-card.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
<div class="ConversationCard">
<div class="ConversationTags">
<i class="fa fa-tags"></i>
{% if tags %}
{% for tag in tags %}
{{ tag }}
{% endfor %}
{% if tag %}
{# Only conversation first tag is shown in card to prevent overflow #}
{{ tag }}
{% else %}
{{ _('Conversation') }}
{% endif %}
Expand Down
3 changes: 0 additions & 3 deletions src/ej_conversations/jinja2/ej_conversations/create.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@

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

<div class="Conversation-edit">
<b>{{ _('Edit Conversation') }}</b>
</div>
</div>
<div class="ConversationDetail-arrow"></div>
</div>
Expand Down
15 changes: 5 additions & 10 deletions src/ej_conversations/jinja2/ej_conversations/edit.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,14 @@
</span>
</div>

{% if conversation.tags.count() > 0 %}
{% set tags = (conversation.tags.all()[0]|string).title() %}
{% else %}
{% set tags = 'Tags' %}
{% endif %}

<input type="hidden" name="tags" value="{{ tags }}" />

<div class="ConversationDetail">
<div class="ConversationDetail-banner">
<div class="ConversationTags"><i class="fa fa-tags"></i>
{{ tags }}
</div>
<div class="ConversationTags">
<div class="ConversationField">
<i class="fa fa-tags"></i><input name="tags" value="{{ tags }}" />
</div>
</div>

<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>

Expand Down
4 changes: 2 additions & 2 deletions src/ej_conversations/jinja2/ej_conversations/moderate.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<div class="ConversationDetail">
<div class="ConversationDetail-banner">
<div class="ConversationTags"><i class="fa fa-tags"></i>
{% if conversation.tags.count() > 0 %}
{{ (conversation.tags.all()[0]|string).title() }}
{% if tags %}
{{ ', '.join(tags) }}
{% else %}
Tags
{% endif %}
Expand Down
6 changes: 4 additions & 2 deletions src/ej_conversations/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion src/ej_conversations/routes/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/',
Expand Down Expand Up @@ -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,
}
16 changes: 16 additions & 0 deletions src/ej_conversations/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions src/ej_users/socialbuttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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",
Expand All @@ -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')
Expand All @@ -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",
Expand Down

0 comments on commit d8cda83

Please sign in to comment.