parser.add_argument('--dry-run', action='store_true', help='Dry run')
def handle(self, *args, **options):
- for et in EmailTemplate.objects.all():
+ for et in EmailTemplate.objects.filter(is_active=True):
et.run(verbose=True, dry_run=options['dry_run'])
--- /dev/null
+# Generated by Django 2.2.9 on 2020-01-17 12:26
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('messaging', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='emailtemplate',
+ name='is_active',
+ field=models.BooleanField(default=False, verbose_name='active'),
+ ),
+ migrations.AlterField(
+ model_name='emailtemplate',
+ name='state',
+ field=models.CharField(choices=[('club-membership-expiring', 'club membership expiring'), ('club-payment-unfinished', 'club payment unfinished'), ('club-recurring-payment-problem', 'club recurring payment problem')], help_text='?', max_length=128, verbose_name='state'),
+ ),
+ ]
body = models.TextField(_('body'))
days = models.SmallIntegerField(_('days'), null=True, blank=True)
hour = models.IntegerField(_('hour'), null=True, blank=True)
+ is_active = models.BooleanField(_('active'), default=False)
class Meta:
verbose_name = _('email template')
def get_hashed_value(self, obj):
return '%s:%s' % (obj.pk, obj.expires_at.isoformat())
+
class ClubPaymentUnfinished(State):
slug = 'club-payment-unfinished'
name = _('club payment unfinished')
)
+class ClubRecurringPaymentProblem(State):
+ slug = 'club-recurring-payment-problem'
+ name = _('club recurring payment problem')
+
+ def get_objects(self):
+ from club.models import Schedule
+ return Schedule.objects.none()
+
+
states = [
ClubMembershipExpiring,
ClubPaymentUnfinished,
+ ClubRecurringPaymentProblem,
]