Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Providing management command which will send a list of feeds which ar…

…e pending approval.
  • Loading branch information...
commit 3554caf2ef736bbc357810e0e47c1e56ba4c3922 1 parent a0db331
@justinabrahms justinabrahms authored
View
0  django_website/aggregator/management/__init__.py
No changes.
View
0  django_website/aggregator/management/commands/__init__.py
No changes.
View
46 django_website/aggregator/management/commands/send_pending_approval_email.py
@@ -0,0 +1,46 @@
+"""
+Send an email to settings.FEED_APPROVERS with the feeds that need to
+be manually approved.
+"""
+from __future__ import absolute_import
+
+from django.conf import settings
+from django.core.mail import send_mail
+from django.core.management.base import NoArgsCommand
+from django.template import Context, Template
+from ...models import Feed, PENDING_FEED
+
+class Command(NoArgsCommand):
+
+ def handle_noargs(self, **kwargs):
+ try:
+ verbosity = int(kwargs['verbosity'])
+ except (KeyError, TypeError, ValueError):
+ verbosity = 1
+
+ feeds = Feed.objects.filter(approval_status=PENDING_FEED)
+
+ if len(feeds) == 0:
+ if verbosity >= 1:
+ print "There are no pending feeds. Skipping the email."
+ return
+
+ email = """The following feeds are pending approval:
+{% regroup feeds by feed_type as feed_grouping %}{% for group in feed_grouping %}
+{{ group.grouper }} {% for feed in group.list %}
+ - {{ feed.title }} ( {{ feed.feed_url }} ) {% endfor %}
+{% endfor %}
+
+To approve them, visit: http://djangoproject.com{% url admin:aggregator_feed_changelist %}
+"""
+
+ message = Template(email).render(Context({'feeds': feeds}))
+ if verbosity >= 2:
+ print "Pending approval email:\n"
+ print message
+
+ send_mail("django community feeds pending approval", message,
+ 'nobody@djangoproject.com', settings.FEED_APPROVERS)
+
+ if verbosity >= 1:
+ print "Sent pending approval email to: %s" % (', '.join(settings.FEED_APPROVERS))
Please sign in to comment.
Something went wrong with that request. Please try again.