<commit_before>import datetime
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
from django.db import models
from django.utils.timezone import utc
from .utils import id2slug

from notifications.signals import notify

from model_utils import managers

try:
    from django.utils import timezone
    now = timezone.now
except ImportError:
    now = datetime.datetime.now

class NotificationQuerySet(models.query.QuerySet):
    def unread(self):
        return self.filter(unread=True)
    
    # Should we return self on these?    
    def mark_all_as_read(self):
        self.update(unread=False)
    
    def mark_all_as_unread(self):
        self.update(unread=True)

class Notification(models.Model):
    """
    Action model describing the actor acting out a verb (on an optional
    target).
    Nomenclature based on http://activitystrea.ms/specs/atom/1.0/

    Generalized Format::

        <actor> <verb> <time><commit_msg>Keep the same API (but extend it) for manager methods (they turn into query set methods).<commit_after>import datetime
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
from django.db import models
from django.utils.timezone import utc
from .utils import id2slug

from notifications.signals import notify

from model_utils import managers

try:
    from django.utils import timezone
    now = timezone.now
except ImportError:
    now = datetime.datetime.now

class NotificationQuerySet(models.query.QuerySet):
    
    def unread(self):
        "Return only unread items in the current queryset"
        return self.filter(unread=True)
    
    # Should we return self on these?    
    def mark_all_as_read(self, recipient=None):
        if recipient:
            self.filter(recipient=recipient).update(unread=False)
        self.update(unread=False)
    
    def mark_all_as_unread(self, recipient=None):
        if recipient:
            self.filter(recipient=recipient).update(unread=True)
        self.update(unread=True)

class Notification(models.Model):
    """
    Action model describing the actor acting out a verb (on an optional
    target).
    Nomenclature based on http://activitystrea.ms/specs/atom/1.0/

    Generalized Format::

        <actor> <verb> <time>
{'fraction_non_alphanumeric': 0.0763019781994348, 'fraction_numerical': 0.0024222850222042794, 'mean_word_length': 3.5384615384615383, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3359264', 'n_tokens_mistral': 705, 'n_tokens_neox': 688, 'n_words': 212}