drip package¶
Subpackages¶
Submodules¶
drip.admin module¶
-
class
drip.admin.
DripAdmin
(model, admin_site)¶ Bases:
django.contrib.admin.options.ModelAdmin
-
add_view
(request: django.http.request.HttpRequest, form_url: str = '', extra_context: Optional[Any] = None) → django.http.response.HttpResponse¶
-
av
(view: Callable) → Callable¶
-
build_extra_context
(extra_context: Optional[Dict[str, Any]]) → Dict[str, Any]¶
-
change_view
(request: django.http.request.HttpRequest, object_id: str, form_url='', extra_context: Optional[Any] = None) → django.http.response.HttpResponse¶
-
form
¶ alias of
drip.admin.DripForm
-
get_mime_html
(drip: drip.models.Drip, user: django.contrib.auth.models.User) → Tuple[str, str]¶
-
get_mime_html_from_alternatives
(alternatives: List[Tuple[str, str]]) → Tuple[str, str]¶
-
get_urls
() → List[django.urls.resolvers.URLPattern]¶
-
inlines
= [<class 'drip.admin.QuerySetRuleInline'>]¶
-
list_display
= ('name', 'enabled', 'message_class')¶
-
property
media
¶
-
timeline
(request: django.core.handlers.wsgi.WSGIRequest, drip_id: int, into_past: int, into_future: int) → django.http.response.HttpResponse¶ Return a list of people who should get emails.
-
users_fields
: Union[str, List[str]] = []¶
-
view_drip_email
(request: django.core.handlers.wsgi.WSGIRequest, drip_id: int, into_past: int, into_future: int, user_id: int) → django.http.response.HttpResponse¶
-
-
class
drip.admin.
DripForm
(*args, **kwargs)¶ Bases:
django.forms.models.ModelForm
-
__init__
(*args, **kwargs)¶ Overriding init form to change help text in body_html_template field according to DRIP_UNSUBSCRIBE_USERS
-
property
media
¶ Return all media required to render the widgets on this form.
-
-
class
drip.admin.
QuerySetRuleInline
(parent_model, admin_site)¶ Bases:
django.contrib.admin.options.TabularInline
-
property
media
¶
-
model
¶ alias of
drip.models.QuerySetRule
-
property
drip.drips module¶
-
class
drip.drips.
DripBase
(drip_model: drip.models.Drip, *args, **kwargs)¶ Bases:
object
A base object for defining a Drip.
You can extend this manually, or you can create full querysets and templates from the admin.
-
__init__
(drip_model: drip.models.Drip, *args, **kwargs)¶ Initialize self. See help(type(self)) for accurate signature.
-
apply_and_queryset_rules
(manager_qs: Union[django.db.models.manager.BaseManager, django.db.models.query.QuerySet]) → django.db.models.query.QuerySet¶ First collect all filter/exclude kwargs and apply any annotations. Then apply AND filters at once, and all excludes at once.
- Parameters
manager_qs (Union[BaseManager, QuerySet]) – Base queryset or manager to apply queryset rules
- Returns
Queryset with AND filters applied
- Return type
QuerySet
-
apply_or_queryset_rules
(manager_qs: Union[django.db.models.manager.BaseManager, django.db.models.query.QuerySet]) → django.db.models.query.QuerySet¶ First collect all filter kwargs. Then apply OR filters at once.
- Parameters
manager_qs (Union[BaseManager, QuerySet]) – Base queryset or manager to apply queryset rules
- Returns
Queryset with OR filters applied
- Return type
QuerySet
-
apply_queryset_rules
(manager_qs: Union[django.db.models.manager.BaseManager, django.db.models.query.QuerySet]) → django.db.models.query.QuerySet¶ First collect all filter/exclude kwargs and apply any annotations. Then apply all filters at once, and all excludes at once.
- Parameters
manager_qs (Union[BaseManager, QuerySet]) – Base queryset or manager to apply queryset rules
- Returns
Queryset with all (AND/OR) filters applied
- Return type
QuerySet
-
body_template
: str¶
-
exclude_sent_drips_users
() → None¶ If configured in can_resend_drip changes queryset excluding Users ids who have a SentDrip already.
-
exclude_unsubcribed_users_campaign
() → None¶ If DRIP_UNSUBSCRIBE_USERS is set to True, get a list of unsubscribed users ids to Campaign model.
-
exclude_unsubcribed_users_drip
() → None¶ If DRIP_UNSUBSCRIBE_USERS is set to True, get a list of unsubscribed users ids to Drip model.
-
exclude_unsubcribed_users_general
() → None¶ If DRIP_UNSUBSCRIBE_USERS is set to True, get a list of unsubscribed users ids to app (all emails).
-
from_email
: str¶
-
from_email_name
: str¶
-
get_count_from_queryset
(message_class) → int¶ Given a Message Class instance (by default drip.drips.DripMessage), returns the amount of sent Drips.
-
get_drip_unsubscribe_users_config
() → bool¶
-
get_queryset
() → django.db.models.query.QuerySet¶ Apply queryset rules or returns the existing queryset
- Returns
Queryset with all (AND/OR) filters applied
- Return type
QuerySet
-
name
: str¶ needs a unique name
-
now
() → datetime.datetime¶ This allows us to override what we consider “now”, making it easy to build timelines of who gets what when.
-
prune
() → None¶ Do an exclude for all Users who have a SentDrip already and if configured the unsubscribed users.
-
queryset
() → django.db.models.manager.BaseManager¶ Returns a queryset of auth.User who meet the criteria of the drip.
Alternatively, you could create Drips on the fly using a queryset builder from the admin interface…
-
run
() → Optional[int]¶ Get the queryset, prune sent people, and send it.
- Returns
Returns count of created SentDrips.
- Return type
Optional[int]
-
send
() → int¶ Send the message to each user on the queryset.
Create SentDrip for each user that gets a message.
Returns count of created SentDrips.
-
subject_template
: str¶
-
timedelta
(*args, **kwargs) → datetime.timedelta¶ If needed, this allows us the ability to manipulate the slicing of time.
-
walk
(into_past: int = 0, into_future: int = 0) → List[drip.drips.DripBase]¶ - Walk over a date range and create
new instances of self with new ranges.
- Parameters
into_past (int, optional) – defaults to 0
into_future (int, optional) – defaults to 0
- Returns
List of DripBase instances.
- Return type
List[DripBase]
-
-
class
drip.drips.
DripBaseParamsOptions
(*args, **kwargs)¶ Bases:
dict
-
drip_model
: drip.models.Drip¶
-
name
: str¶
-
now_shift_kwargs
: Dict[str, Any]¶
-
-
class
drip.drips.
DripMessage
(drip_base: drip.drips.DripBase, user: django.contrib.auth.models.User)¶ Bases:
object
Email message abstraction for manage message interactions, based on EmailMultiAlternatives. You can extend this manually overriding any method that you need.
- Parameters
drip_base (DripBase) – DripBase object to build email
user (User) – User to send email
-
__init__
(drip_base: drip.drips.DripBase, user: django.contrib.auth.models.User)¶ Initialize self. See help(type(self)) for accurate signature.
-
property
body
¶
-
build_context
() → Dict[str, Any]¶ Build context drip dictionary allowing you easy extension. Also it is used to manage unsubscribe links configurations.
-
property
context
¶
-
property
from_email
¶
-
property
from_email_name
¶
-
get_from_
() → str¶
-
property
message
¶
-
property
plain
¶
-
property
subject
¶
-
drip.drips.
configured_message_classes
() → collections.ChainMap¶ Returns a ChainMap (basically a dict), between default settings and settings.DRIP_MESSAGE_CLASSES which should be a dictionary of the form:
{ message_class_name: class_path }
For example, if you define this at DRIP_MESSAGE_CLASSES:
- {
‘default’: ‘my.path.to.DripMessage’, ‘my_other_class’: ‘my.other.path.to.DripMessage’,
}
The returning value of this method would be:
- {
‘default’: ‘my.path.to.Drip’, ‘my_other_class’: ‘my.other.path.to.DripMessage’,
}
But, if you define this:
- {
‘my_other_class’: ‘my.other.path.to.DripMessage’,
}
The returning value of this method would be:
- {
‘default’: ‘drip.drips.DripMessage’, ‘my_other_class’: ‘my.other.path.to.DripMessage’,
}
A ‘default’ key is added when it’s not present on DRIP_MESSAGE_CLASSES.
-
drip.drips.
message_class_for
(name: str) → drip.drips.DripMessage¶ Given a class’s path, returns a reference to it. Raises MessageClassNotFound exception if name is not present in the ChainMap produced by configured_message_classes.
drip.helpers module¶
-
drip.helpers.
get_flexible_regex
(string: str) → Dict[str, Union[str, int]]¶ Matches a string using a more flexible regex expression for parsing it to timedelta object.
-
drip.helpers.
parse
(string: str) → datetime.timedelta¶ Parse a string into a timedelta object.
-
drip.helpers.
process_regex
(matches: Match[str]) → Dict[str, Union[str, int]]¶
-
drip.helpers.
process_string
(string: str) → datetime.timedelta¶ Process a string into a timedelta object, using a standard format used by Postgres, sqlite, or from serialization. Or a flexible regex expression if the standard form is not enough.
drip.models module¶
-
class
drip.models.
AbstractDrip
(*args, **kwargs)¶ Bases:
django.db.models.base.Model
- Parameters
date (DateTimeField) – Date
lastchanged (DateTimeField) – Lastchanged
name (CharField) – Drip name. A unique name for this drip.
enabled (BooleanField) – Enabled
can_resend_drip (BooleanField) – Can resend drip. This will allow you to resend emails to users with the same Drip when query matches the user again.
from_email (EmailField) – From email. Set a custom from email.
from_email_name (CharField) – From email name. Set a name for a custom from email.
subject_template (TextField) – Subject template
body_html_template (TextField) – Body html template. You will have settings and user in the context.
message_class (CharField) – Message class
campaign (ForeignKey to
Campaign
) – Campaign. If set, this is the campaign to which this Drip belongs to.unsubscribed_users (ManyToManyField) – Unsubscribed users
-
body_html_template
¶ Model field: body html template
-
campaign_id
¶ Model field: campaign
-
can_resend_drip
¶ Model field: can resend drip
-
date
¶ Model field: date
-
property
drip
¶
-
enabled
¶ Model field: enabled
-
from_email
¶ Model field: from email
-
from_email_name
¶ Model field: from email name
-
get_next_by_date
(*, field=<django.db.models.fields.DateTimeField: date>, is_next=True, **kwargs)¶ Autogenerated: Finds next instance based on
date
.
-
get_next_by_lastchanged
(*, field=<django.db.models.fields.DateTimeField: lastchanged>, is_next=True, **kwargs)¶ Autogenerated: Finds next instance based on
lastchanged
.
-
get_previous_by_date
(*, field=<django.db.models.fields.DateTimeField: date>, is_next=False, **kwargs)¶ Autogenerated: Finds previous instance based on
date
.
-
get_previous_by_lastchanged
(*, field=<django.db.models.fields.DateTimeField: lastchanged>, is_next=False, **kwargs)¶ Autogenerated: Finds previous instance based on
lastchanged
.
-
lastchanged
¶ Model field: lastchanged
-
message_class
¶ Model field: message class
-
name
¶ Model field: Drip Name
-
subject_template
¶ Model field: subject template
-
unsubscribed_users
¶ Model field: unsubscribed users, accesses the M2M
AbstractDrip
model.
-
class
drip.models.
AbstractQuerySetRule
(*args, **kwargs)¶ Bases:
django.db.models.base.Model
Allows to apply filters to drips
- Parameters
date (DateTimeField) – Date
lastchanged (DateTimeField) – Lastchanged
drip (ForeignKey to
Drip
) – Dripmethod_type (CharField) – Method type
field_name (CharField) – Field name of user
lookup_type (CharField) – Lookup type
rule_type (CharField) – Rule type
field_value (CharField) – Field value. Can be anything from a number, to a string. Or, do now-7 days or today+3 days for fancy timedelta.
-
property
annotated_field_name
¶ Generates an annotated version of this field’s name, based on self.field_name
-
apply
(qs: django.db.models.query.QuerySet, now: Callable = <built-in method now of type object>) → django.db.models.query.QuerySet¶ Returns
qs
filtered/excluded by any filter resulting fromself.filter_kwargs
depending on whetherself.method_type
is one of the following:“filter”
“exclude”
Also annotates
qs
by callingself.apply_any_annotation
.
-
apply_any_annotation
(qs: django.db.models.query.QuerySet) → django.db.models.query.QuerySet¶ Returns qs annotated with Count over this field’s name.
-
clean
() → None¶ Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
-
date
¶ Model field: date
-
drip_id
¶ Model field: drip
-
field_name
¶ Model field: Field name of User
-
field_value
¶ Model field: field value
-
filter_kwargs
(now: Callable = <built-in method now of type object>) → Dict[str, Union[bool, str, django.db.models.expressions.F, datetime.timedelta]]¶ Returns a dictionary {field_name: field_value} where:
field_name is self.annotated_field_name in addition to self.lookup_type in the form FIELD_NAME__LOOKUP.
field_value is the result of passing self.field_value through parsing methods.
The resulting dict can be used to apply filters over querysets.
queryset.filter(**obj.filter_kwargs(datetime.now()))
-
get_lookup_type_display
(*, field=<django.db.models.fields.CharField: lookup_type>)¶ Autogenerated: Shows the label of the
lookup_type
-
get_method_type_display
(*, field=<django.db.models.fields.CharField: method_type>)¶ Autogenerated: Shows the label of the
method_type
-
get_next_by_date
(*, field=<django.db.models.fields.DateTimeField: date>, is_next=True, **kwargs)¶ Autogenerated: Finds next instance based on
date
.
-
get_next_by_lastchanged
(*, field=<django.db.models.fields.DateTimeField: lastchanged>, is_next=True, **kwargs)¶ Autogenerated: Finds next instance based on
lastchanged
.
-
get_previous_by_date
(*, field=<django.db.models.fields.DateTimeField: date>, is_next=False, **kwargs)¶ Autogenerated: Finds previous instance based on
date
.
-
get_previous_by_lastchanged
(*, field=<django.db.models.fields.DateTimeField: lastchanged>, is_next=False, **kwargs)¶ Autogenerated: Finds previous instance based on
lastchanged
.
-
get_rule_type_display
(*, field=<django.db.models.fields.CharField: rule_type>)¶ Autogenerated: Shows the label of the
rule_type
-
lastchanged
¶ Model field: lastchanged
-
lookup_type
¶ Model field: lookup type
-
method_type
¶ Model field: method type
-
rule_type
¶ Model field: rule type
-
set_booleans
(field_value: str) → Union[bool, str]¶ Returns True or False whether field value is ‘True’ or ‘False’ respectively. Otherwise returns field_value unchanged.
-
set_f_expressions
(field_value: str) → Union[django.db.models.expressions.F, str]¶ If field_value starts with the substring ‘F_’, returns an instance of models.F within the field_value expression, otherwise returns field_value unchanged.
-
set_time_deltas_and_dates
(now: Callable, field_value: str) → Union[datetime.timedelta, str]¶ Parses the field_value parameter and returns a TimeDelta object The field_value string might start with one of the following substrings: * “now-” * “now+” * “today-” * “today+” Otherwise returns field_value unchanged.
-
class
drip.models.
AbstractSentDrip
(*args, **kwargs)¶ Bases:
django.db.models.base.Model
Keeps a record of all sent drips.
- Parameters
date (DateTimeField) – Date
drip (ForeignKey to
Drip
) – Dripuser (ForeignKey to
User
) – Usersubject (TextField) – Subject
body (TextField) – Body
from_email (EmailField) – From email
from_email_name (CharField) – From email name
-
body
¶ Model field: body
-
date
¶ Model field: date
-
drip
¶ Model field: drip, accesses the
Drip
model.
-
drip_id
¶ Model field: drip
-
from_email
¶ Model field: from email
-
from_email_name
¶ Model field: from email name
-
get_next_by_date
(*, field=<django.db.models.fields.DateTimeField: date>, is_next=True, **kwargs)¶ Autogenerated: Finds next instance based on
date
.
-
get_previous_by_date
(*, field=<django.db.models.fields.DateTimeField: date>, is_next=False, **kwargs)¶ Autogenerated: Finds previous instance based on
date
.
-
subject
¶ Model field: subject
-
user
¶ Model field: user, accesses the
User
model.
-
user_id
¶ Model field: user
-
class
drip.models.
Drip
(id, date, lastchanged, name, enabled, can_resend_drip, from_email, from_email_name, subject_template, body_html_template, message_class, campaign)¶ Bases:
drip.models.AbstractDrip
- Parameters
id (AutoField) – Id
date (DateTimeField) – Date
lastchanged (DateTimeField) – Lastchanged
name (CharField) – Drip name. A unique name for this drip.
enabled (BooleanField) – Enabled
can_resend_drip (BooleanField) – Can resend drip. This will allow you to resend emails to users with the same Drip when query matches the user again.
from_email (EmailField) – From email. Set a custom from email.
from_email_name (CharField) – From email name. Set a name for a custom from email.
subject_template (TextField) – Subject template
body_html_template (TextField) – Body html template. You will have settings and user in the context.
message_class (CharField) – Message class
campaign (ForeignKey to
Campaign
) – Campaign. If set, this is the campaign to which this Drip belongs to.unsubscribed_users (ManyToManyField) – Unsubscribed users
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
get_next_by_date
(*, field=<django.db.models.fields.DateTimeField: date>, is_next=True, **kwargs)¶ Autogenerated: Finds next instance based on
date
.
-
get_next_by_lastchanged
(*, field=<django.db.models.fields.DateTimeField: lastchanged>, is_next=True, **kwargs)¶ Autogenerated: Finds next instance based on
lastchanged
.
-
get_previous_by_date
(*, field=<django.db.models.fields.DateTimeField: date>, is_next=False, **kwargs)¶ Autogenerated: Finds previous instance based on
date
.
-
get_previous_by_lastchanged
(*, field=<django.db.models.fields.DateTimeField: lastchanged>, is_next=False, **kwargs)¶ Autogenerated: Finds previous instance based on
lastchanged
.
-
id
¶ Model field: ID
-
objects
= <django.db.models.manager.Manager object>¶
-
queryset_rules
¶ Model field: drip, accesses the M2M
QuerySetRule
model.
-
user_unsubscribe_drips
¶ Model field: drip, accesses the M2M
UserUnsubscribeDrip
model.
-
class
drip.models.
QuerySetRule
(id, date, lastchanged, drip, method_type, field_name, lookup_type, rule_type, field_value)¶ Bases:
drip.models.AbstractQuerySetRule
- Parameters
id (AutoField) – Id
date (DateTimeField) – Date
lastchanged (DateTimeField) – Lastchanged
drip (ForeignKey to
Drip
) – Dripmethod_type (CharField) – Method type
field_name (CharField) – Field name of user
lookup_type (CharField) – Lookup type
rule_type (CharField) – Rule type
field_value (CharField) – Field value. Can be anything from a number, to a string. Or, do now-7 days or today+3 days for fancy timedelta.
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
get_lookup_type_display
(*, field=<django.db.models.fields.CharField: lookup_type>)¶ Autogenerated: Shows the label of the
lookup_type
-
get_method_type_display
(*, field=<django.db.models.fields.CharField: method_type>)¶ Autogenerated: Shows the label of the
method_type
-
get_next_by_date
(*, field=<django.db.models.fields.DateTimeField: date>, is_next=True, **kwargs)¶ Autogenerated: Finds next instance based on
date
.
-
get_next_by_lastchanged
(*, field=<django.db.models.fields.DateTimeField: lastchanged>, is_next=True, **kwargs)¶ Autogenerated: Finds next instance based on
lastchanged
.
-
get_previous_by_date
(*, field=<django.db.models.fields.DateTimeField: date>, is_next=False, **kwargs)¶ Autogenerated: Finds previous instance based on
date
.
-
get_previous_by_lastchanged
(*, field=<django.db.models.fields.DateTimeField: lastchanged>, is_next=False, **kwargs)¶ Autogenerated: Finds previous instance based on
lastchanged
.
-
get_rule_type_display
(*, field=<django.db.models.fields.CharField: rule_type>)¶ Autogenerated: Shows the label of the
rule_type
-
id
¶ Model field: ID
-
objects
= <django.db.models.manager.Manager object>¶
-
class
drip.models.
SentDrip
(id, date, drip, user, subject, body, from_email, from_email_name)¶ Bases:
drip.models.AbstractSentDrip
- Parameters
id (AutoField) – Id
date (DateTimeField) – Date
drip (ForeignKey to
Drip
) – Dripuser (ForeignKey to
User
) – Usersubject (TextField) – Subject
body (TextField) – Body
from_email (EmailField) – From email
from_email_name (CharField) – From email name
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
get_next_by_date
(*, field=<django.db.models.fields.DateTimeField: date>, is_next=True, **kwargs)¶ Autogenerated: Finds next instance based on
date
.
-
get_previous_by_date
(*, field=<django.db.models.fields.DateTimeField: date>, is_next=False, **kwargs)¶ Autogenerated: Finds previous instance based on
date
.
-
id
¶ Model field: ID
-
objects
= <django.db.models.manager.Manager object>¶
-
user
¶ Model field: user, accesses the
User
model.
-
class
drip.models.
TestUserUUIDModel
(*args, **kwargs)¶ Bases:
django.db.models.base.Model
Class to test UUID field as id in User model
- Parameters
id (UUIDField) – Id
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
id
¶ Model field: id
-
objects
= <django.db.models.manager.Manager object>¶
-
class
drip.models.
UserUnsubscribe
(id, user, created_date)¶ Bases:
django.db.models.base.Model
- Parameters
id (AutoField) – Id
user (ForeignKey to
User
) – Usercreated_date (DateTimeField) – Created date
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
created_date
¶ Model field: created date
-
get_next_by_created_date
(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)¶ Autogenerated: Finds next instance based on
created_date
.
-
get_previous_by_created_date
(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)¶ Autogenerated: Finds previous instance based on
created_date
.
-
id
¶ Model field: ID
-
objects
= <django.db.models.manager.Manager object>¶
-
user
¶ Model field: user, accesses the
User
model.
-
user_id
¶ Model field: user
-
class
drip.models.
UserUnsubscribeDrip
(id, drip, user, created_date)¶ Bases:
django.db.models.base.Model
- Parameters
id (AutoField) – Id
drip (ForeignKey to
Drip
) – Dripuser (ForeignKey to
User
) – Usercreated_date (DateTimeField) – Created date
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
created_date
¶ Model field: created date
-
drip_id
¶ Model field: drip
-
get_next_by_created_date
(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)¶ Autogenerated: Finds next instance based on
created_date
.
-
get_previous_by_created_date
(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)¶ Autogenerated: Finds previous instance based on
created_date
.
-
id
¶ Model field: ID
-
objects
= <django.db.models.manager.Manager object>¶
-
user
¶ Model field: user, accesses the
User
model.
-
user_id
¶ Model field: user
drip.tests module¶
drip.utils module¶
-
exception
drip.utils.
DripScheduleSettingsError
¶ Bases:
Exception
-
drip.utils.
build_now_from_timedelta
(now_shift_kwargs: Dict[str, Any]) → datetime.datetime¶ Build “now” from shift timedelta.
-
drip.utils.
check_redundant
(model_stack: List[Type[django.db.models.base.Model]], stack_limit: int) → bool¶ Checks to ensure recursion isnt being redundant
- Parameters
model_stack (List[Type[models.Model]]) – List of models.Model
stack_limit (int) – recursion depth to check redundancy
- Returns
Bool that controls if stops recursion
- Return type
bool
-
drip.utils.
get_conditional_now
() → Callable¶
-
drip.utils.
get_field_name
(field, RelatedObject)¶
-
drip.utils.
get_fields
(Model: Type[django.db.models.base.Model], parent_field: str = '', model_stack: List[Type[django.db.models.base.Model]] = [], stack_limit: int = 2, excludes: List[str] = ['permissions', 'comment', 'content_type'])¶ Given a Model, return a list of lists of strings with important stuff: … [‘test_user__user__customuser’, ‘customuser’, ‘User’, ‘RelatedObject’] [‘test_user__unique_id’, ‘unique_id’, ‘TestUser’, ‘CharField’] [‘test_user__confirmed’, ‘confirmed’, ‘TestUser’, ‘BooleanField’] …
-
drip.utils.
get_full_field
(parent_field: str, field_name: str) → str¶ - Parameters
parent_field (str) – Name of parent field
field_name (str) – Field name
- Returns
It is the join between parent_field and field_name or just the field_name
- Return type
str
-
drip.utils.
get_out_fields
(Model: Type[django.db.models.base.Model], parent_field: str, model_stack: List[Type[django.db.models.base.Model]], excludes: List[str], fields: List[Union[django.db.models.fields.Field, django.db.models.fields.related.ForeignKey, django.db.models.fields.related.OneToOneField, django.db.models.fields.reverse_related.ForeignObjectRel, django.db.models.fields.related.ManyToManyField]])¶
-
drip.utils.
get_rel_model
(field: Union[django.db.models.fields.Field, django.db.models.fields.related.ForeignKey, django.db.models.fields.related.OneToOneField, django.db.models.fields.reverse_related.ForeignObjectRel, django.db.models.fields.related.ManyToManyField], RelatedObject: django.db.models.fields.reverse_related.ForeignObjectRel) → Type[django.db.models.base.Model]¶
-
drip.utils.
get_simple_fields
(Model: Type[django.db.models.base.Model], **kwargs) → List¶
-
drip.utils.
get_user_model
() → Type[django.contrib.auth.models.User]¶
-
drip.utils.
give_model_field
(full_field: str, Model: Type[django.db.models.base.Model]) → tuple¶ Given a field_name and Model:
“test_user__unique_id”, <AchievedGoal>
Returns “test_user__unique_id”, “id”, <Model>, <ModelField>
- Parameters
full_field (str) – full field name
Model (models.Model) – models.Model
- Raises
Exception – If the key is not found it raises and exception
- Returns
It is a tuple with field full name, field name, <Model>, <ModelField>
- Return type
tuple
-
drip.utils.
is_valid_instance
(field: Union[django.db.models.fields.Field, django.db.models.fields.related.ForeignKey, django.db.models.fields.related.OneToOneField, django.db.models.fields.reverse_related.ForeignObjectRel, django.db.models.fields.related.ManyToManyField]) → bool¶
-
drip.utils.
validate_path_existence
(path: str, url_args: Dict[str, Any]) → Optional[str]¶ Validate path existence in Django project. And returns it
-
drip.utils.
validate_schedules
()¶
drip.views module¶
-
class
drip.views.
UnsubscribeCampaignView
(**kwargs)¶ Bases:
django.views.generic.base.TemplateView
-
dispatch
(*args: Any, **kwargs: Any)¶
-
get_context_data
(**kwargs: Any) → Dict[str, Any]¶
-
get_template_names
() → List[str]¶ Return a list of template names to be used for the request. Must return a list. May not be called if render_to_response() is overridden.
-
invalid_template_name
= 'unsubscribe_campaign_invalid.html'¶
-
post
(*args: Any, **kwargs: Any)¶
-
success_template_name
= 'unsubscribe_campaign_success.html'¶
-
template_name
= 'unsubscribe_campaign.html'¶
-
-
class
drip.views.
UnsubscribeDripView
(**kwargs)¶ Bases:
django.views.generic.base.TemplateView
-
dispatch
(*args: Any, **kwargs: Any)¶
-
get_context_data
(**kwargs: Any) → Dict[str, Any]¶
-
get_template_names
() → List[str]¶ Return a list of template names to be used for the request. Must return a list. May not be called if render_to_response() is overridden.
-
invalid_template_name
= 'unsubscribe_drip_invalid.html'¶
-
post
(*args: Any, **kwargs: Any)¶
-
success_template_name
= 'unsubscribe_drip_success.html'¶
-
template_name
= 'unsubscribe_drip.html'¶
-
-
class
drip.views.
UnsubscribeView
(**kwargs)¶ Bases:
django.views.generic.base.TemplateView
-
dispatch
(*args: Any, **kwargs: Any)¶
-
get_context_data
(**kwargs: Any) → Dict[str, Any]¶
-
get_template_names
() → List[str]¶ Return a list of template names to be used for the request. Must return a list. May not be called if render_to_response() is overridden.
-
invalid_template_name
= 'unsubscribe_general_invalid.html'¶
-
post
(*args: Any, **kwargs: Any)¶
-
success_template_name
= 'unsubscribe_general_success.html'¶
-
template_name
= 'unsubscribe_general.html'¶
-
drip.tokens module¶
-
class
drip.tokens.
CustomTokenGenerator
¶ Bases:
django.contrib.auth.tokens.PasswordResetTokenGenerator
Custom token generator with no login and password hashing. Also not checking time validation, it is just a hash of user data for email purposes.
-
check_token
(user: Optional[django.contrib.auth.base_user.AbstractBaseUser], token: Optional[str]) → bool¶ Check that a password reset token is correct for a given user. Remove the check of token time validation
-
-
class
drip.tokens.
EmailToken
(user: django.contrib.auth.base_user.AbstractBaseUser)¶ Bases:
object
A base object for managing token validations and generations for Drip id and user data.
-
__init__
(user: django.contrib.auth.base_user.AbstractBaseUser)¶ Initialize self. See help(type(self)) for accurate signature.
-
get_uidb64_token
(object_id: int) → Tuple[str, str, str]¶ Returns drip/campaign and user uidb64 and token for the user, for building url
-
get_uidb64_token_user_only
() → Tuple[str, str]¶ Returns user uidb64 and token for the user, for building url
-
user
: django.contrib.auth.base_user.AbstractBaseUser¶
-
classmethod
validate_campaign_uidb64
(campaign_uidb64: str) → Optional[drip.campaigns.models.Campaign]¶ Validates campaign uidb64 and returns the Campaign object for this string
-
classmethod
validate_drip_uidb64
(drip_uidb64: str) → Optional[drip.models.Drip]¶ Validates drip uidb64 and returns the Drip object for this string
-
classmethod
validate_user_uidb64_token
(uidb64: str, token: str) → Optional[django.contrib.auth.base_user.AbstractBaseUser]¶ Validates user uidb64 and token using custom token generator class and returns the User object for this variables
-