1- from datetime import datetime , timedelta
2-
3- from django .db import models
4- from django .core .exceptions import ValidationError
5- from django .conf import settings
6-
7- from drip .utils import get_user_model
1+ from datetime import datetime
82
93# just using this to parse, but totally insane package naming...
104# https://bitbucket.org/schinckel/django-timedelta-field/
115import timedelta as djangotimedelta
6+ from django .conf import settings
7+ from django .core .exceptions import ValidationError
8+ from django .db import models
9+
10+ from drip .utils import get_user_model
1211
1312
1413class Drip (models .Model ):
@@ -23,26 +22,30 @@ class Drip(models.Model):
2322
2423 enabled = models .BooleanField (default = False )
2524
26- from_email = models .EmailField (null = True , blank = True ,
27- help_text = 'Set a custom from email.' )
28- from_email_name = models .CharField (max_length = 150 , null = True , blank = True ,
29- help_text = "Set a name for a custom from email." )
25+ from_email = models .EmailField (
26+ null = True , blank = True , help_text = 'Set a custom from email.' ,
27+ )
28+ from_email_name = models .CharField (
29+ max_length = 150 , null = True , blank = True , help_text = "Set a name for a custom from email." ,
30+ )
3031 subject_template = models .TextField (null = True , blank = True )
31- body_html_template = models .TextField (null = True , blank = True ,
32- help_text = 'You will have settings and user in the context.' )
32+ body_html_template = models .TextField (
33+ null = True , blank = True , help_text = 'You will have settings and user in the context.' ,
34+ )
3335 message_class = models .CharField (max_length = 120 , blank = True , default = 'default' )
3436
3537 @property
3638 def drip (self ):
3739 from drip .drips import DripBase
3840
39- drip = DripBase (drip_model = self ,
40- name = self .name ,
41- from_email = self .from_email if self .from_email else None ,
42- from_email_name = self .from_email_name if self .from_email_name else None ,
43- subject_template = self .subject_template if self .subject_template else None ,
44- body_template = self .body_html_template if self .body_html_template else None )
45- return drip
41+ return DripBase (
42+ drip_model = self ,
43+ name = self .name ,
44+ from_email = self .from_email if self .from_email else None ,
45+ from_email_name = self .from_email_name if self .from_email_name else None ,
46+ subject_template = self .subject_template if self .subject_template else None ,
47+ body_template = self .body_html_template if self .body_html_template else None ,
48+ )
4649
4750 def __unicode__ (self ):
4851 return self .name
@@ -60,14 +63,13 @@ class SentDrip(models.Model):
6063 subject = models .TextField ()
6164 body = models .TextField ()
6265 from_email = models .EmailField (
63- null = True , default = None # For south so that it can migrate existing rows.
66+ null = True , default = None , # For south so that it can migrate existing rows.
6467 )
65- from_email_name = models .CharField (max_length = 150 ,
66- null = True , default = None # For south so that it can migrate existing rows.
68+ from_email_name = models .CharField (
69+ max_length = 150 , null = True , default = None , # For south so that it can migrate existing rows.
6770 )
6871
6972
70-
7173METHOD_TYPES = (
7274 ('filter' , 'Filter' ),
7375 ('exclude' , 'Exclude' ),
@@ -90,6 +92,7 @@ class SentDrip(models.Model):
9092 ('iendswith' , 'ends with (case insensitive)' ),
9193)
9294
95+
9396class QuerySetRule (models .Model ):
9497 date = models .DateTimeField (auto_now_add = True )
9598 lastchanged = models .DateTimeField (auto_now = True )
@@ -100,9 +103,9 @@ class QuerySetRule(models.Model):
100103 field_name = models .CharField (max_length = 128 , verbose_name = 'Field name of User' )
101104 lookup_type = models .CharField (max_length = 12 , default = 'exact' , choices = LOOKUP_TYPES )
102105
103- field_value = models .CharField (max_length = 255 ,
104- help_text = ( 'Can be anything from a number, to a string. Or, do ' +
105- '`now-7 days` or `today+3 days` for fancy timedelta.' ))
106+ field_value = models .CharField (max_length = 255 , help_text = (
107+ 'Can be anything from a number, to a string. Or, do `now-7 days` or `today+3 days` for fancy timedelta.'
108+ ))
106109
107110 def clean (self ):
108111 User = get_user_model ()
0 commit comments