# Path: tidings/compat.py
# def iteritems(d, **kw):
# def iterkeys(d, **kw):
# 
# Path: tidings/utils.py
# def collate(*iterables, **kwargs):
#     def gather_next_value(row, index):
# def hash_to_unsigned(data):
# def emails_with_users_and_watches(
#         subject, template_path, vars, users_and_watches,
#         from_email=settings.TIDINGS_FROM_ADDRESS, **extra_kwargs):
# def import_from_setting(setting_name, fallback):


from django.conf import settings
from django.contrib.auth.models import AnonymousUser
from django.contrib.contenttypes.fields import (GenericForeignKey,
                                                GenericRelation)
from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.models import Site
from django.db import models, connections, router
from .compat import next, text_type
from .utils import import_from_setting, reverse
    user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, blank=True,
                             on_delete=models.CASCADE)

    #: Email stored only in the case of anonymous users:
    email = models.EmailField(db_index=True, null=True, blank=True)

    #: Secret for activating anonymous watch email addresses.
    secret = models.CharField(max_length=10, null=True, blank=True)
    #: Active watches receive notifications, inactive watches don't.
    is_active = models.BooleanField(default=False, db_index=True)

    def __unicode__(self):
        # TODO: Trace event_type back to find the Event subclass, and ask it
        # how to describe me in English.
        rest = self.content_object or self.content_type or self.object_id
        return u'id=%s, type=%s, content_object=%s' % (self.pk,
                                                       self.event_type,
                                                       text_type(rest))

    def activate(self):
        """Enable this watch so it actually fires.

        Return ``self`` to support method chaining.

        """
        self.is_active = True
        return self

    def unsubscribe_url(self):
        """Return the absolute URL to visit to delete me."""

# Path: tidings/compat.py
# def iteritems(d, **kw):
# def iterkeys(d, **kw):
# 
# Path: tidings/utils.py
# def collate(*iterables, **kwargs):
#     def gather_next_value(row, index):
# def hash_to_unsigned(data):
# def emails_with_users_and_watches(
#         subject, template_path, vars, users_and_watches,
#         from_email=settings.TIDINGS_FROM_ADDRESS, **extra_kwargs):
# def import_from_setting(setting_name, fallback):


# Path: tidings/models.py
from django.conf import settings
from django.contrib.auth.models import AnonymousUser
from django.contrib.contenttypes.fields import (GenericForeignKey,
                                                GenericRelation)
from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.models import Site
from django.db import models, connections, router
from .compat import next, text_type
from .utils import import_from_setting, reverse

    user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, blank=True,
                             on_delete=models.CASCADE)

    #: Email stored only in the case of anonymous users:
    email = models.EmailField(db_index=True, null=True, blank=True)

    #: Secret for activating anonymous watch email addresses.
    secret = models.CharField(max_length=10, null=True, blank=True)
    #: Active watches receive notifications, inactive watches don't.
    is_active = models.BooleanField(default=False, db_index=True)

    def __unicode__(self):
        # TODO: Trace event_type back to find the Event subclass, and ask it
        # how to describe me in English.
        rest = self.content_object or self.content_type or self.object_id
        return u'id=%s, type=%s, content_object=%s' % (self.pk,
                                                       self.event_type,
                                                       text_type(rest))

    def activate(self):
        """Enable this watch so it actually fires.

        Return ``self`` to support method chaining.

        """
        self.is_active = True
        return self

    def unsubscribe_url(self):
        """Return the absolute URL to visit to delete me."""

        server_relative = ('%s?s=%s' % (reverse('tidings.unsubscribe',