Name change

This commit is contained in:
Seb 2020-05-01 10:48:00 +10:00
parent 03f1d6cb56
commit 3524a6d228
23 changed files with 45 additions and 59 deletions

View File

@ -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 %}
<mj-section>
@ -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

1
birdsong/__init__.py Normal file
View File

@ -0,0 +1 @@
default_app_config = 'birdsong.apps.WagtailBirdsongApp'

6
birdsong/apps.py Normal file
View File

@ -0,0 +1,6 @@
from django.apps import AppConfig
class WagtailBirdsongApp(AppConfig):
name = 'birdsong'
label = 'birdsong'
verbose_name = 'Wagtail Birdsong'

View File

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

View File

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

View File

@ -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'])

View File

@ -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'),
),
]

View File

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

View File

@ -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):

View File

@ -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',
],

View File

@ -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),
),
]