diff --git a/README.md b/README.md index fbaf7a8..ff4a33b 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Add the following to your installed apps: ``` 'mjml', -'wagtailbirdsong', +'wagtail-birdsong', 'wagtail.contrib.modeladmin', ``` @@ -16,8 +16,8 @@ from django.db import models from wagtail.admin.edit_handlers import FieldPanel, StreamFieldPanel from wagtail.core.fields import StreamField -from wagtailbirdsong.blocks import DefaultBlocks -from wagtailbirdsong.models import Contact, Campaign +from birdsong.blocks import DefaultBlocks +from birdsong.models import Contact, Campaign class ExtendedContact(Contact): @@ -39,7 +39,7 @@ In your `wagtail_hooks.py` add something like: ``` from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register -from wagtailbirdsong.options import EmailAdmin +from birdsong.options import EmailAdmin from .models import ExtendedContact, SaleEmail @@ -63,7 +63,7 @@ class ContactAdmin(ModelAdmin): Create your email template in `{app_folder}/templates/{app_name}/mail/{model_name}.html` eg `email/templates/email/mail/sale_email.html`: ``` -{% extends "wagtailbirdsong/mail/base_email.html" %} +{% extends "birdsong/mail/base_email.html" %} {% block email_body %} @@ -79,7 +79,7 @@ Create your email template in `{app_folder}/templates/{app_name}/mail/{model_nam # Custom backend -Do mostly as you would in the above example, but override the `get_backend` method of the `Campaign` class. Your custom backend should follow what you see in `wagtailbirdsong.backends.BaseEmailBackend`. +Do mostly as you would in the above example, but override the `get_backend` method of the `Campaign` class. Your custom backend should follow what you see in `birdsong.backends.BaseEmailBackend`. For example: @@ -89,8 +89,8 @@ from django.db import models from wagtail.admin.edit_handlers import FieldPanel, StreamFieldPanel from wagtail.core.fields import StreamField -from wagtailbirdsong.blocks import DefaultBlocks -from wagtailbirdsong.models import Campaign +from birdsong.blocks import DefaultBlocks +from birdsong.models import Campaign from .backends import CustomBackend diff --git a/birdsong/__init__.py b/birdsong/__init__.py new file mode 100644 index 0000000..595aef0 --- /dev/null +++ b/birdsong/__init__.py @@ -0,0 +1 @@ +default_app_config = 'birdsong.apps.WagtailBirdsongApp' \ No newline at end of file diff --git a/birdsong/apps.py b/birdsong/apps.py new file mode 100644 index 0000000..0a753d3 --- /dev/null +++ b/birdsong/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + +class WagtailBirdsongApp(AppConfig): + name = 'birdsong' + label = 'birdsong' + verbose_name = 'Wagtail Birdsong' \ No newline at end of file diff --git a/wagtailbirdsong/backends/__init__.py b/birdsong/backends/__init__.py similarity index 55% rename from wagtailbirdsong/backends/__init__.py rename to birdsong/backends/__init__.py index 0112053..5e56fd8 100644 --- a/wagtailbirdsong/backends/__init__.py +++ b/birdsong/backends/__init__.py @@ -6,6 +6,6 @@ class BaseEmailBackend: @property def from_email(self): - if hasattr(settings, 'WAGTAILBIRDSONG_FROM_EMAIL'): - return settings.WAGTAILBIRDSONG_FROM_EMAIL + if hasattr(settings, 'BIRDSONG_FROM_EMAIL'): + return settings.BIRDSONG_FROM_EMAIL return settings.DEFAULT_FROM_EMAIL \ No newline at end of file diff --git a/wagtailbirdsong/backends/smtp.py b/birdsong/backends/smtp.py similarity index 93% rename from wagtailbirdsong/backends/smtp.py rename to birdsong/backends/smtp.py index 8f8ff2f..ac33f28 100644 --- a/wagtailbirdsong/backends/smtp.py +++ b/birdsong/backends/smtp.py @@ -3,7 +3,8 @@ from smtplib import SMTPException from django.core.mail import send_mass_mail from django.template.loader import render_to_string -from wagtailbirdsong.utils import send_mass_html_mail +from birdsong.utils import send_mass_html_mail + from . import BaseEmailBackend diff --git a/wagtailbirdsong/blocks.py b/birdsong/blocks.py similarity index 83% rename from wagtailbirdsong/blocks.py rename to birdsong/blocks.py index cc26ade..e9032e6 100644 --- a/wagtailbirdsong/blocks.py +++ b/birdsong/blocks.py @@ -10,5 +10,5 @@ class UnwrappedStreamBlock(blocks.StreamBlock): class DefaultBlocks(UnwrappedStreamBlock): - rich_text = blocks.RichTextBlock(template='wagtailbirdsong/mail/blocks/richtext.html', + rich_text = blocks.RichTextBlock(template='birdsong/mail/blocks/richtext.html', features=['h3', 'h4', 'bold', 'italic', 'link', 'ul', 'ol', 'document-link']) diff --git a/wagtailbirdsong/migrations/0001_initial.py b/birdsong/migrations/0001_initial.py similarity index 68% rename from wagtailbirdsong/migrations/0001_initial.py rename to birdsong/migrations/0001_initial.py index aea9fe4..8fe5786 100644 --- a/wagtailbirdsong/migrations/0001_initial.py +++ b/birdsong/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 2.2.12 on 2020-04-29 03:13 +# Generated by Django 3.0.5 on 2020-05-01 00:41 from django.db import migrations, models import django.db.models.deletion @@ -16,7 +16,9 @@ class Migration(migrations.Migration): name='Campaign', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(help_text='The name of the campaign', max_length=255)), ('subject', models.TextField()), + ('sent_date', models.DateTimeField(blank=True, null=True)), ], ), migrations.CreateModel( @@ -30,14 +32,15 @@ class Migration(migrations.Migration): name='Receipt', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('sent_date', models.DateTimeField(blank=True)), - ('campaign', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wagtailbirdsong.Campaign')), - ('contact', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wagtailbirdsong.Contact')), + ('sent_date', models.DateTimeField(auto_now=True)), + ('success', models.BooleanField(default=False)), + ('campaign', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='birdsong.Campaign')), + ('contact', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='birdsong.Contact')), ], ), migrations.AddField( model_name='campaign', name='receipts', - field=models.ManyToManyField(through='wagtailbirdsong.Receipt', to='wagtailbirdsong.Contact'), + field=models.ManyToManyField(through='birdsong.Receipt', to='birdsong.Contact'), ), - ] \ No newline at end of file + ] diff --git a/wagtailbirdsong/__init__.py b/birdsong/migrations/__init__.py similarity index 100% rename from wagtailbirdsong/__init__.py rename to birdsong/migrations/__init__.py diff --git a/wagtailbirdsong/models.py b/birdsong/models.py similarity index 100% rename from wagtailbirdsong/models.py rename to birdsong/models.py diff --git a/wagtailbirdsong/options.py b/birdsong/options.py similarity index 97% rename from wagtailbirdsong/options.py rename to birdsong/options.py index 1164f17..2010ac7 100644 --- a/wagtailbirdsong/options.py +++ b/birdsong/options.py @@ -1,11 +1,13 @@ -from django.urls import reverse from django.conf.urls import url - +from django.urls import reverse from wagtail.contrib.modeladmin.helpers import AdminURLHelper, ButtonHelper from wagtail.contrib.modeladmin.options import ModelAdmin -from wagtailbirdsong.backends.smtp import SMTPEmailBackend -from .views import editor, mail + +from birdsong.backends.smtp import SMTPEmailBackend + from .models import Contact +from .views import editor, mail + class EmailCampaignButtonHelper(ButtonHelper): def get_buttons_for_obj(self, campaign, **kwargs): @@ -65,7 +67,7 @@ class EmailAdmin(ModelAdmin): button_helper_class = EmailCampaignButtonHelper inspect_view_enabled = True inspect_view_class = editor.InspectCampaign - inspect_template_name = 'wagtailbirdsong/editor/inspect_campaign.html' + inspect_template_name = 'birdsong/editor/inspect_campaign.html' backend_class = SMTPEmailBackend contact_class = Contact diff --git a/wagtailbirdsong/templates/wagtailbirdsong/editor/inspect_campaign.html b/birdsong/templates/wagtailbirdsong/editor/inspect_campaign.html similarity index 100% rename from wagtailbirdsong/templates/wagtailbirdsong/editor/inspect_campaign.html rename to birdsong/templates/wagtailbirdsong/editor/inspect_campaign.html diff --git a/wagtailbirdsong/templates/wagtailbirdsong/editor/send_confirm.html b/birdsong/templates/wagtailbirdsong/editor/send_confirm.html similarity index 100% rename from wagtailbirdsong/templates/wagtailbirdsong/editor/send_confirm.html rename to birdsong/templates/wagtailbirdsong/editor/send_confirm.html diff --git a/wagtailbirdsong/templates/wagtailbirdsong/editor/test_confirm.html b/birdsong/templates/wagtailbirdsong/editor/test_confirm.html similarity index 100% rename from wagtailbirdsong/templates/wagtailbirdsong/editor/test_confirm.html rename to birdsong/templates/wagtailbirdsong/editor/test_confirm.html diff --git a/wagtailbirdsong/templates/wagtailbirdsong/mail/base_email.html b/birdsong/templates/wagtailbirdsong/mail/base_email.html similarity index 100% rename from wagtailbirdsong/templates/wagtailbirdsong/mail/base_email.html rename to birdsong/templates/wagtailbirdsong/mail/base_email.html diff --git a/wagtailbirdsong/templates/wagtailbirdsong/mail/blocks/richtext.html b/birdsong/templates/wagtailbirdsong/mail/blocks/richtext.html similarity index 100% rename from wagtailbirdsong/templates/wagtailbirdsong/mail/blocks/richtext.html rename to birdsong/templates/wagtailbirdsong/mail/blocks/richtext.html diff --git a/wagtailbirdsong/utils.py b/birdsong/utils.py similarity index 100% rename from wagtailbirdsong/utils.py rename to birdsong/utils.py diff --git a/wagtailbirdsong/version.py b/birdsong/version.py similarity index 100% rename from wagtailbirdsong/version.py rename to birdsong/version.py diff --git a/wagtailbirdsong/migrations/__init__.py b/birdsong/views/__init__.py similarity index 100% rename from wagtailbirdsong/migrations/__init__.py rename to birdsong/views/__init__.py diff --git a/wagtailbirdsong/views/editor.py b/birdsong/views/editor.py similarity index 80% rename from wagtailbirdsong/views/editor.py rename to birdsong/views/editor.py index eba2621..6fa9e21 100644 --- a/wagtailbirdsong/views/editor.py +++ b/birdsong/views/editor.py @@ -15,7 +15,7 @@ def confirm_send(request, campaign, send_url, index_url): 'index_url': index_url } - return render(request, "wagtailbirdsong/editor/send_confirm.html", context) + return render(request, "birdsong/editor/send_confirm.html", context) def confirm_test(request, campaign, send_url, index_url): @@ -26,7 +26,7 @@ def confirm_test(request, campaign, send_url, index_url): 'index_url': index_url } - return render(request, "wagtailbirdsong/editor/test_confirm.html", context) + return render(request, "birdsong/editor/test_confirm.html", context) class InspectCampaign(InspectView): diff --git a/wagtailbirdsong/views/mail.py b/birdsong/views/mail.py similarity index 100% rename from wagtailbirdsong/views/mail.py rename to birdsong/views/mail.py diff --git a/setup.py b/setup.py index dec9694..e60b7de 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,10 @@ #!/usr/bin/env python """ -Install wagtailmodelchooser using setuptools +Install wagtail-birdsong using setuptools """ from setuptools import find_packages, setup -with open('wagtailbirdsong/version.py', 'r') as f: +with open('birdsong/version.py', 'r') as f: version = None exec(f.read()) @@ -12,14 +12,14 @@ with open('README.md', 'r') as f: readme = f.read() setup( - name='wagtailbirdsong', + name='wagtail-birdsong', version=version, description='Create and send email campaigns from Wagtail', long_description=readme, author='Jonny Scholes', author_email='jonny@neonjungle.studio', - install_requires=['wagtail>=2.2', 'django-mjml'], + install_requires=['wagtail>=2.7', 'django-mjml'], zip_safe=False, license='BSD License', @@ -34,8 +34,10 @@ setup( 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', 'Framework :: Django', 'License :: OSI Approved :: BSD License', ], diff --git a/wagtailbirdsong/migrations/0002_auto_20200430_1727.py b/wagtailbirdsong/migrations/0002_auto_20200430_1727.py deleted file mode 100644 index 9d5d416..0000000 --- a/wagtailbirdsong/migrations/0002_auto_20200430_1727.py +++ /dev/null @@ -1,29 +0,0 @@ -# Generated by Django 3.0.5 on 2020-04-30 07:27 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('wagtailbirdsong', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='campaign', - name='name', - field=models.CharField(default='default', help_text='The name of the campaign', max_length=255), - preserve_default=False, - ), - migrations.AddField( - model_name='receipt', - name='success', - field=models.BooleanField(default=False), - ), - migrations.AlterField( - model_name='receipt', - name='sent_date', - field=models.DateTimeField(auto_now=True), - ), - ] diff --git a/wagtailbirdsong/views/__init__.py b/wagtailbirdsong/views/__init__.py deleted file mode 100644 index e69de29..0000000