-
-
Notifications
You must be signed in to change notification settings - Fork 34
Issue 311 #312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 311 #312
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
This looks good, just a few remarks in the review :)
Also, could you add/update the testsuite to test for those new fields?
Thanks a lot!
| {% block extracss %} | ||
| <link href="{% static "css/petition.css" %}" rel="stylesheet" type="text/css"> | ||
| {% if petition.has_share_buttons %} | ||
| {% if petition.has_email_share_button or petition.has_facebook_share_button or petition.has_tumblr_share_button or petition.has_linkedin_share_button or petition.has_twitter_share_button or petition.has_mastodon_share_button or petition.has_whatsapp_share_button %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could add a has_any_share_button() method in the Petition class that does this boolean computation, just for the sake of keeping the template easy to read.
| </ul> | ||
| </div> | ||
| {% endif %} | ||
| {% if petition.has_email_share_button or petition.has_facebook_share_button or petition.has_tumblr_share_button or petition.has_linkedin_share_button or petition.has_twitter_share_button or petition.has_mastodon_share_button or petition.has_whatsapp_share_button %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same remark here about adding a has_any_share_button() method to Petition class.
| {% block extrajs %} | ||
| <script type="text/javascript" src="{% static "js/petition.js" %}"></script> | ||
| {% if petition.has_share_buttons %} | ||
| {% if petition.has_email_share_button or petition.has_facebook_share_button or petition.has_tumblr_share_button or petition.has_linkedin_share_button or petition.has_twitter_share_button or petition.has_mastodon_share_button or petition.has_whatsapp_share_button %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same remark here.
|
For the unit test you can either add a new test in
|
OK. I am planning to add new test in the file
@fallen can you please give me an example test for one of the |
Sure, here you go: def test_edit_petition_email_share_button(self):
julia = self.login('julia')
org = Organization.objects.get(name='RAP')
share_button_form_data = {
'social_network_form_submitted': 'yes',
'has_email_share_button': True,
}
# For an org owned petition
p = Petition.objects.create(title="My petition", org=org)
# By default, a new petition has no share button
self.assertFalse(p.has_email_share_button)
# Now let's enable the email share button
response = self.client.post(reverse("edit_petition", args=[p.id]),
share_button_form_data)
self.assertEqual(response.status_code, 200)
p.refresh_from_db()
self.assertTemplateUsed(response, "petition/edit_petition.html")
self.assertEquals(response.context['social_network_form'].is_valid(), True)
self.assertEquals(response.context['social_network_form'].is_bound, True)
self.assertEquals(response.context['content_form_submitted'], False)
self.assertEquals(response.context['email_form_submitted'], False)
self.assertEquals(response.context['social_network_form_submitted'], True)
self.assertEquals(response.context['newsletter_form_submitted'], False)
self.assertTrue(p.has_email_share_button)
# Let's now turn it back off
share_button_form_data['has_email_share_button'] = False
response = self.client.post(reverse("edit_petition", args=[p.id]),
share_button_form_data)
self.assertEqual(response.status_code, 200)
p.refresh_from_db()
self.assertFalse(p.has_email_share_button)
# For a user owned petition
p = Petition.objects.create(title="My petition 2", user=julia)
# By default, a new petition has no share button
self.assertFalse(p.has_email_share_button)
# Now let's enable the email share button
share_button_form_data['has_email_share_button'] = True
response = self.client.post(reverse("edit_petition", args=[p.id]), share_button_form_data)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "petition/edit_petition.html")
p.refresh_from_db()
self.assertEquals(response.context['social_network_form'].is_valid(), True)
self.assertEquals(response.context['social_network_form'].is_bound, True)
self.assertEquals(response.context['content_form_submitted'], False)
self.assertEquals(response.context['email_form_submitted'], False)
self.assertEquals(response.context['social_network_form_submitted'], True)
self.assertEquals(response.context['newsletter_form_submitted'], False)
self.assertTrue(p.has_email_share_button)
# Let's now turn it back off
share_button_form_data['has_email_share_button'] = False
response = self.client.post(reverse("edit_petition", args=[p.id]), share_button_form_data)
self.assertEqual(response.status_code, 200)
p.refresh_from_db()
self.assertFalse(p.has_email_share_button)This tests that when creating a Petition, the "has_email_share_button" is by default "off" and then tries to enable it and switch it back off using the "edit_petition" view. I hope you are well and I wish you a very happy festive season :) |
|
@fallen Wish you a very happy festive season too! |
|
Hi @fallen, hope all is well. The PR is ready for review and please take a look whenever you get the chance. |
fallen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks good to me, thanks a lot and sorry for the review delay!
For #311