Beispiel #1
0
    def label(self, *labels):
        """
        Adds the given labels to this message
        """
        from casepro.profiles.models import Notification

        self.labels.add(*labels)

        # notify all users who watch these labels
        for watcher in set(User.objects.filter(watched_labels__in=labels)):
            Notification.new_message_labelling(self.org, watcher, self)
Beispiel #2
0
    def label(self, *labels):
        """
        Adds the given labels to this message
        """
        from casepro.profiles.models import Notification

        self.labels.add(*labels)

        # notify all users who watch these labels
        for watcher in set(User.objects.filter(watched_labels__in=labels)):
            Notification.new_message_labelling(self.org, watcher, self)
Beispiel #3
0
    def label(self, *labels):
        """
        Adds the given labels to this message
        """
        from casepro.profiles.models import Notification
        from casepro.statistics.models import DailyCount, datetime_to_date

        existing_label_ids = Labelling.objects.filter(
            message=self, label__in=labels).values_list("label", flat=True)
        add_labels = [l for l in labels if l.id not in existing_label_ids]
        new_labellings = [Labelling(message=self, label=l) for l in add_labels]
        Labelling.objects.bulk_create(new_labellings)

        day = datetime_to_date(self.created_on, self.org)
        for label in add_labels:
            DailyCount.record_item(day, DailyCount.TYPE_INCOMING, label)

        # notify all users who watch these labels
        for watcher in set(User.objects.filter(watched_labels__in=labels)):
            Notification.new_message_labelling(self.org, watcher, self)