Exemplo n.º 1
0
    def handle(self, *args, **options):

        self.verbosity = options["verbosity"]

        for document in Document.objects.all():

            tags = Tag.objects.exclude(
                pk__in=document.tags.values_list("pk", flat=True))

            for tag in Tag.match_all(document.content, tags):
                print('Tagging {} with "{}"'.format(document, tag))
                document.tags.add(tag)
Exemplo n.º 2
0
    def handle(self, *args, **options):

        self.verbosity = options["verbosity"]

        correspondents = list(Correspondent.objects.all())

        for document in Document.objects.iterator():

            tags = Tag.objects.exclude(
                pk__in=document.tags.values_list("pk", flat=True))

            for tag in Tag.match_all(document.content, tags):
                print('Tagging {} with "{}"'.format(document, tag))
                document.tags.add(tag)

            if not document.correspondent:
                for c in correspondents:
                    if c.matches(document.content):
                        print('Correspondent of {} is "{}"'.format(
                            document, c))
                        document.correspondent = c
                        document.save()