Skip to content

Commit

Permalink
Functional, rudimentary and glitchy
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronschif committed Feb 10, 2014
1 parent 2646847 commit 2a9dddd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
18 changes: 11 additions & 7 deletions djcelery_email/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
import six

from django.core.validators import validate_email
from django.core.exceptions import ValidationError
from django.db.models import TextField, SubfieldBase
from django.utils.translation import ugettext as _
from django.forms import Field


class EmailsFormField(Field):
pass


class EmailsListField(TextField):
Expand All @@ -20,16 +24,16 @@ def to_python(self, value):
def validate(self, value, model_instance):
super(EmailsListField, self).validate(value, model_instance)

if self.blank and not value:
for email in value:
validate_email(email)
for email in value:
validate_email(email)

def get_prep_value(self, value):
if isinstance(value, six.string_types):
return value
else:
return ', '.join(value)

def value_to_string(self, obj):
value = self._get_val_from_obj(obj)
return self.get_db_prep_value(value)
def formfield(self, **kwargs):
defaults = {'form_class': EmailsFormField}
defaults.update(kwargs)
return super(EmailsListField, self).formfield(**defaults)
6 changes: 3 additions & 3 deletions djcelery_email/tasks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.conf import settings
from django.core.mail import get_connection

from celery.task import task
from celery import shared_task

from djcelery_email.models import EMail

Expand All @@ -20,7 +20,7 @@
# @task(**TASK_CONFIG)


@task()
@shared_task()
def send_emails():
conn = get_connection(backend=BACKEND)

Expand All @@ -34,7 +34,7 @@ def send_emails():
finally:
conn.close()

@task()
@shared_task()
def clean_old():
pass
# EMail.objects.filter()

0 comments on commit 2a9dddd

Please sign in to comment.