Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Django management command #96

Open
wants to merge 2 commits into from

2 participants

@viaregio

I have added a django management command for submitting submissions. Maybe this helps with issue #39

@dokterbob
Owner

Hey @viaregio, in principle: yes, this helps a great deal. However, it would make more sense to refactor all of this in one strike:

  1. Add management command (which you just did).
  2. Update legacy cronjob to call the new job, in order to maintain compatibility - in such as way that not having django-extensions installed won't break newsletter.
  3. Update the documentation to reflect the new functionality.

If you think you are up to this: great!
Otherwise, I'll implement this myself in a couple of months (and will be sure to include your patch as a start).

@dokterbob dokterbob modified the milestone: Future, 0.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
2  newsletter/management/__init__.py
@@ -0,0 +1,2 @@
+# -*- coding: utf-8 -*-
+# management commands for the newsletter
View
2  newsletter/management/commands/__init__.py
@@ -0,0 +1,2 @@
+# -*- coding: utf-8 -*-
+# management commands for the newsletter
View
21 newsletter/management/commands/submit.py
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+"""
+actual sending of the submissions
+"""
+import logging
+
+from django.core.management.base import BaseCommand
+from django.utils.translation import ugettext as _
+
+from newsletter.models import Submission
+
+
+class Command(BaseCommand):
+ help = "Submit pending messages."
+ args = ""
+
+ def handle(self, *args, **options):
+ self.logger = logging.getLogger(type(self).__name__)
+ self.logger.debug('Handle called')
+ self.logger.info(_('Submitting queued newsletter mailings'))
+ Submission.submit_queue()
Something went wrong with that request. Please try again.