Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pytition/petition/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,14 @@ class SocialNetworkForm(forms.Form):
twitter_image = forms.FileField(max_length=500, required=False)
org_twitter_handle = forms.CharField(max_length=20, required=False)
remove_twitter_image = forms.BooleanField(required=False, initial=False)
has_share_buttons = forms.BooleanField(required=False)
has_email_share_button = forms.BooleanField(required=False)
has_facebook_share_button = forms.BooleanField(required=False)
has_tumblr_share_button = forms.BooleanField(required=False)
has_linkedin_share_button = forms.BooleanField(required=False)
has_twitter_share_button = forms.BooleanField(required=False)
has_mastodon_share_button = forms.BooleanField(required=False)
has_whatsapp_share_button = forms.BooleanField(required=False)



class NewsletterForm(forms.Form):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Generated by Django 4.2.7 on 2023-12-03 10:52

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('petition', '0019_petition_show_publication_date'),
]

operations = [
migrations.AddField(
model_name='petition',
name='has_email_share_button',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='petition',
name='has_facebook_share_button',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='petition',
name='has_linkedin_share_button',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='petition',
name='has_mastodon_share_button',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='petition',
name='has_tumblr_share_button',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='petition',
name='has_twitter_share_button',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='petition',
name='has_whatsapp_share_button',
field=models.BooleanField(default=False),
),
]
27 changes: 27 additions & 0 deletions pytition/petition/migrations/0021_auto_20231203_1026.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 4.2.7 on 2023-12-03 16:26

from django.db import migrations

def set_new_petition_share_fields(apps, schema_editor):
Petition = apps.get_model("petition", "Petition")
for petition in Petition.objects.all():
if petition.has_share_buttons:
petition.has_email_share_button = True
petition.has_facebook_share_button = True
petition.has_tumblr_share_button = True
petition.has_linkedin_share_button = True
petition.has_twitter_share_button = True
petition.has_mastodon_share_button = True
petition.has_whatsapp_share_button = True
petition.save()


class Migration(migrations.Migration):

dependencies = [
('petition', '0020_petition_has_email_share_button_and_more'),
]

operations = [
migrations.RunPython(set_new_petition_share_fields)
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.7 on 2023-12-06 06:28

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('petition', '0021_auto_20231203_1026'),
]

operations = [
migrations.RemoveField(
model_name='petition',
name='has_share_buttons',
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Generated by Django 4.2.7 on 2023-12-08 11:51

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('petition', '0022_remove_petition_has_share_buttons'),
]

operations = [
migrations.AddField(
model_name='petitiontemplate',
name='has_email_share_button',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='petitiontemplate',
name='has_facebook_share_button',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='petitiontemplate',
name='has_linkedin_share_button',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='petitiontemplate',
name='has_mastodon_share_button',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='petitiontemplate',
name='has_tumblr_share_button',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='petitiontemplate',
name='has_twitter_share_button',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='petitiontemplate',
name='has_whatsapp_share_button',
field=models.BooleanField(default=False),
),
]
27 changes: 27 additions & 0 deletions pytition/petition/migrations/0024_auto_20231208_0621.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 4.2.7 on 2023-12-08 12:21

from django.db import migrations


def set_new_petition_template_share_fields(apps, schema_editor):
PetitionTemplate = apps.get_model('petition', 'PetitionTemplate')
for pt in PetitionTemplate.objects.all():
if pt.has_share_buttons:
pt.has_email_share_button = True
pt.has_facebook_share_button = True
pt.has_tumblr_share_button = True
pt.has_linkedin_share_button = True
pt.has_twitter_share_button = True
pt.has_mastodon_share_button = True
pt.has_whatsapp_share_button = True
pt.save()

class Migration(migrations.Migration):

dependencies = [
('petition', '0023_petitiontemplate_has_email_share_button_and_more'),
]

operations = [
migrations.RunPython(set_new_petition_template_share_fields)
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.7 on 2023-12-09 06:02

import colorfield.fields
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('petition', '0024_auto_20231208_0621'),
]

operations = [
migrations.RemoveField(
model_name='petitiontemplate',
name='has_share_buttons',
),
]
16 changes: 14 additions & 2 deletions pytition/petition/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,13 @@ class Petition(models.Model):
creation_date = models.DateTimeField(blank=True)
last_modification_date = models.DateTimeField(blank=True)
moderated = models.BooleanField(default=False)
has_share_buttons = models.BooleanField(default=True)
has_email_share_button = models.BooleanField(default=False)
has_facebook_share_button = models.BooleanField(default=False)
has_tumblr_share_button = models.BooleanField(default=False)
has_linkedin_share_button = models.BooleanField(default=False)
has_twitter_share_button = models.BooleanField(default=False)
has_mastodon_share_button = models.BooleanField(default=False)
has_whatsapp_share_button = models.BooleanField(default=False)
publication_date = models.DateTimeField(blank=True, null=True)
show_publication_date = models.BooleanField(default=False)

Expand Down Expand Up @@ -540,7 +546,13 @@ class PetitionTemplate(models.Model):
sign_form_footer = models.TextField(blank=True)
confirmation_email_reply = models.EmailField(max_length=100, blank=True)
use_custom_email_settings = models.BooleanField(default=False)
has_share_buttons = models.BooleanField(default=True)
has_email_share_button = models.BooleanField(default=False)
has_facebook_share_button = models.BooleanField(default=False)
has_tumblr_share_button = models.BooleanField(default=False)
has_linkedin_share_button = models.BooleanField(default=False)
has_twitter_share_button = models.BooleanField(default=False)
has_mastodon_share_button = models.BooleanField(default=False)
has_whatsapp_share_button = models.BooleanField(default=False)
paper_signatures_enabled = models.BooleanField(default=False)

def __str__(self):
Expand Down
80 changes: 70 additions & 10 deletions pytition/petition/templates/petition/edit_petition.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,76 @@
{% if petition.org_twitter_handle %}value="{{ petition.org_twitter_handle }}"{% endif %}>
</div>
</div>
<div class="form-group row">
<label for="id_has_share_buttons" class="col-sm-12 col-md-3 col-lg-2 col-form-label">{% trans "Enable share buttons?" %}</label>
<div class="col-sm-12 col-md-9 col-lg-10">
<div class="custom-control custom-switch">
<input type="checkbox" name="has_share_buttons" class="is-valid custom-control-input" id="id_has_share_buttons"
{% if petition.has_share_buttons %} checked {% endif %}>
<label class="custom-control-label" for="id_has_share_buttons">{% trans "Enable share buttons?" %}</label>
</div>
</div>
</div>
<div class="form-group row">
<label for="id_has_email_share_button" class="col-sm-12 col-md-3 col-lg-2 col-form-label">{% trans "Enable email share button?" %}</label>
<div class="col-sm-12 col-md-9 col-lg-10">
<div class="custom-control custom-switch">
<input type="checkbox" name="has_email_share_button" class="is-valid custom-control-input" id="id_has_email_share_button"
{% if petition.has_email_share_button %} checked {% endif %}>
<label class="custom-control-label" for="id_has_email_share_button">{% trans "Enable email share button?" %}</label>
</div>
</div>
</div>
<div class="form-group row">
<label for="id_has_facebook_share_button" class="col-sm-12 col-md-3 col-lg-2 col-form-label">{% trans "Enable Facebook share button?" %}</label>
<div class="col-sm-12 col-md-9 col-lg-10">
<div class="custom-control custom-switch">
<input type="checkbox" name="has_facebook_share_button" class="is-valid custom-control-input" id="id_has_facebook_share_button"
{% if petition.has_facebook_share_button %} checked {% endif %}>
<label class="custom-control-label" for="id_has_facebook_share_button">{% trans "Enable Facebook share button?" %}</label>
</div>
</div>
</div>
<div class="form-group row">
<label for="id_has_tumblr_share_button" class="col-sm-12 col-md-3 col-lg-2 col-form-label">{% trans "Enable Tumblr share button?" %}</label>
<div class="col-sm-12 col-md-9 col-lg-10">
<div class="custom-control custom-switch">
<input type="checkbox" name="has_tumblr_share_button" class="is-valid custom-control-input" id="id_has_tumblr_share_button"
{% if petition.has_tumblr_share_button %} checked {% endif %}>
<label class="custom-control-label" for="id_has_tumblr_share_button">{% trans "Enable Tumblr share buttons?" %}</label>
</div>
</div>
</div>
<div class="form-group row">
<label for="id_has_linkedin_share_button" class="col-sm-12 col-md-3 col-lg-2 col-form-label">{% trans "Enable LinkedIn share button?" %}</label>
<div class="col-sm-12 col-md-9 col-lg-10">
<div class="custom-control custom-switch">
<input type="checkbox" name="has_linkedin_share_button" class="is-valid custom-control-input" id="id_has_linkedin_share_button"
{% if petition.has_linkedin_share_button %} checked {% endif %}>
<label class="custom-control-label" for="id_has_linkedin_share_button">{% trans "Enable LinkedIn share button?" %}</label>
</div>
</div>
</div>
<div class="form-group row">
<label for="id_has_twitter_share_button" class="col-sm-12 col-md-3 col-lg-2 col-form-label">{% trans "Enable Twitter share button?" %}</label>
<div class="col-sm-12 col-md-9 col-lg-10">
<div class="custom-control custom-switch">
<input type="checkbox" name="has_twitter_share_button" class="is-valid custom-control-input" id="id_has_twitter_share_button"
{% if petition.has_twitter_share_button %} checked {% endif %}>
<label class="custom-control-label" for="id_has_twitter_share_button">{% trans "Enable Twitter share button?" %}</label>
</div>
</div>
</div>
<div class="form-group row">
<label for="id_has_mastodon_share_button" class="col-sm-12 col-md-3 col-lg-2 col-form-label">{% trans "Enable Mastodon share button?" %}</label>
<div class="col-sm-12 col-md-9 col-lg-10">
<div class="custom-control custom-switch">
<input type="checkbox" name="has_mastodon_share_button" class="is-valid custom-control-input" id="id_has_mastodon_share_button"
{% if petition.has_mastodon_share_button %} checked {% endif %}>
<label class="custom-control-label" for="id_has_mastodon_share_button">{% trans "Enable Mastodon share button?" %}</label>
</div>
</div>
</div>
<div class="form-group row">
<label for="id_has_whatsapp_share_button" class="col-sm-12 col-md-3 col-lg-2 col-form-label">{% trans "Enable Whatsapp share button?" %}</label>
<div class="col-sm-12 col-md-9 col-lg-10">
<div class="custom-control custom-switch">
<input type="checkbox" name="has_whatsapp_share_button" class="is-valid custom-control-input" id="id_has_whatsapp_share_button"
{% if petition.has_whatsapp_share_button %} checked {% endif %}>
<label class="custom-control-label" for="id_has_whatsapp_share_button">{% trans "Enable Whatsapp share button?" %}</label>
</div>
</div>
</div>
<div class="form-group row">
<div class="input-group">
<input type="checkbox" name="remove_twitter_image" id="remove_twitter_image" hidden>
Expand Down
Loading