mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-04 03:27:12 -05:00 
			
		
		
		
	inbox tags, archive tags, archive serial number for documents
This commit is contained in:
		
							parent
							
								
									8f6231bd34
								
							
						
					
					
						commit
						c3a144f2ca
					
				
							
								
								
									
										2
									
								
								src/documents/management/commands/document_correspondents.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										2
									
								
								src/documents/management/commands/document_correspondents.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@ -41,7 +41,7 @@ class Command(Renderable, BaseCommand):
 | 
			
		||||
 | 
			
		||||
        self.verbosity = options["verbosity"]
 | 
			
		||||
 | 
			
		||||
        for document in Document.objects.filter(correspondent__isnull=True):
 | 
			
		||||
        for document in Document.objects.filter(correspondent__isnull=True).exclude(tags__is_archived_tag=True):
 | 
			
		||||
 | 
			
		||||
            potential_correspondents = list(
 | 
			
		||||
                Correspondent.match_all(document.content))
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								src/documents/management/commands/document_retagger.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										2
									
								
								src/documents/management/commands/document_retagger.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@ -22,7 +22,7 @@ class Command(Renderable, BaseCommand):
 | 
			
		||||
 | 
			
		||||
        self.verbosity = options["verbosity"]
 | 
			
		||||
 | 
			
		||||
        for document in Document.objects.all():
 | 
			
		||||
        for document in Document.objects.all().exclude(tags__is_archived_tag=True):
 | 
			
		||||
 | 
			
		||||
            tags = Tag.objects.exclude(
 | 
			
		||||
                pk__in=document.tags.values_list("pk", flat=True))
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										34
									
								
								src/documents/migrations/0022_workflow_improvements.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										34
									
								
								src/documents/migrations/0022_workflow_improvements.py
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,34 @@
 | 
			
		||||
# -*- coding: utf-8 -*-
 | 
			
		||||
# Generated by Django 1.11.10 on 2018-02-04 13:07
 | 
			
		||||
from __future__ import unicode_literals
 | 
			
		||||
 | 
			
		||||
from django.db import migrations, models
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Migration(migrations.Migration):
 | 
			
		||||
 | 
			
		||||
    dependencies = [
 | 
			
		||||
        ('documents', '0021_document_storage_type'),
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
    operations = [
 | 
			
		||||
 | 
			
		||||
        migrations.AddField(
 | 
			
		||||
            model_name='document',
 | 
			
		||||
            name='archive_serial_number',
 | 
			
		||||
            field=models.IntegerField(unique=True, blank=True, null=True, db_index=True),
 | 
			
		||||
        ),
 | 
			
		||||
 | 
			
		||||
        migrations.AddField(
 | 
			
		||||
            model_name='tag',
 | 
			
		||||
            name='is_inbox_tag',
 | 
			
		||||
            field=models.BooleanField(default=False),
 | 
			
		||||
        ),
 | 
			
		||||
 | 
			
		||||
        migrations.AddField(
 | 
			
		||||
            model_name='tag',
 | 
			
		||||
            name='is_archived_tag',
 | 
			
		||||
            field=models.BooleanField(default=False),
 | 
			
		||||
        ),
 | 
			
		||||
 | 
			
		||||
    ]
 | 
			
		||||
@ -180,6 +180,14 @@ class Tag(MatchingModel):
 | 
			
		||||
 | 
			
		||||
    colour = models.PositiveIntegerField(choices=COLOURS, default=1)
 | 
			
		||||
 | 
			
		||||
    is_inbox_tag = models.BooleanField(
 | 
			
		||||
        default=False,
 | 
			
		||||
        help_text="Marks this tag as an inbox tag: All newly consumed documents will be tagged with inbox tags.")
 | 
			
		||||
 | 
			
		||||
    is_archived_tag = models.BooleanField(
 | 
			
		||||
        default=False,
 | 
			
		||||
        help_text="Marks this tag as an archive tag: All documents tagged with archive tags will never be modified automatically (i.e., modifying tags by matching rules)")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Document(models.Model):
 | 
			
		||||
 | 
			
		||||
@ -247,6 +255,13 @@ class Document(models.Model):
 | 
			
		||||
    added = models.DateTimeField(
 | 
			
		||||
        default=timezone.now, editable=False, db_index=True)
 | 
			
		||||
 | 
			
		||||
    archive_serial_number = models.IntegerField(
 | 
			
		||||
        blank=True,
 | 
			
		||||
        null=True,
 | 
			
		||||
        unique=True,
 | 
			
		||||
        db_index=True,
 | 
			
		||||
        help_text="The position of this document in your physical document archive.")
 | 
			
		||||
 | 
			
		||||
    class Meta:
 | 
			
		||||
        ordering = ("correspondent", "title")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								src/documents/signals/handlers.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										2
									
								
								src/documents/signals/handlers.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							@ -47,7 +47,7 @@ def set_correspondent(sender, document=None, logging_group=None, **kwargs):
 | 
			
		||||
def set_tags(sender, document=None, logging_group=None, **kwargs):
 | 
			
		||||
 | 
			
		||||
    current_tags = set(document.tags.all())
 | 
			
		||||
    relevant_tags = set(Tag.match_all(document.content)) - current_tags
 | 
			
		||||
    relevant_tags = (set(Tag.match_all(document.content)) | set(Tag.objects.filter(is_inbox_tag=True))) - current_tags
 | 
			
		||||
 | 
			
		||||
    if not relevant_tags:
 | 
			
		||||
        return
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user