mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Add field 'added' to documents
This field indicates when the document was added to the database
This commit is contained in:
		| @@ -125,7 +125,9 @@ class DocumentAdmin(CommonAdmin): | |||||||
|         } |         } | ||||||
|  |  | ||||||
|     search_fields = ("correspondent__name", "title", "content", "tags__name") |     search_fields = ("correspondent__name", "title", "content", "tags__name") | ||||||
|     list_display = ("title", "created", "thumbnail", "correspondent", "tags_") |     readonly_fields = ("added",) | ||||||
|  |     list_display = ("title", "created", "added", "thumbnail", "correspondent", | ||||||
|  |                     "tags_") | ||||||
|     list_filter = ("tags", "correspondent", FinancialYearFilter, |     list_filter = ("tags", "correspondent", FinancialYearFilter, | ||||||
|                    MonthListFilter) |                    MonthListFilter) | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										27
									
								
								src/documents/migrations/0020_document_added.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								src/documents/migrations/0020_document_added.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | |||||||
|  | # -*- coding: utf-8 -*- | ||||||
|  | from __future__ import unicode_literals | ||||||
|  |  | ||||||
|  | from django.db import migrations, models | ||||||
|  | import django.utils.timezone | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def set_added_time_to_created_time(apps, schema_editor): | ||||||
|  |     Document = apps.get_model("documents", "Document") | ||||||
|  |     for doc in Document.objects.all(): | ||||||
|  |         doc.added = doc.created | ||||||
|  |         doc.save() | ||||||
|  |  | ||||||
|  | class Migration(migrations.Migration): | ||||||
|  |  | ||||||
|  |     dependencies = [ | ||||||
|  |         ('documents', '0019_add_consumer_user'), | ||||||
|  |     ] | ||||||
|  |  | ||||||
|  |     operations = [ | ||||||
|  |         migrations.AddField( | ||||||
|  |             model_name='document', | ||||||
|  |             name='added', | ||||||
|  |             field=models.DateTimeField(db_index=True, default=django.utils.timezone.now, editable=False), | ||||||
|  |         ), | ||||||
|  |         migrations.RunPython(set_added_time_to_created_time) | ||||||
|  |     ] | ||||||
| @@ -229,6 +229,8 @@ class Document(models.Model): | |||||||
|         default=timezone.now, db_index=True) |         default=timezone.now, db_index=True) | ||||||
|     modified = models.DateTimeField( |     modified = models.DateTimeField( | ||||||
|         auto_now=True, editable=False, db_index=True) |         auto_now=True, editable=False, db_index=True) | ||||||
|  |     added = models.DateTimeField( | ||||||
|  |         default=timezone.now, editable=False, db_index=True) | ||||||
|  |  | ||||||
|     class Meta(object): |     class Meta(object): | ||||||
|         ordering = ("correspondent", "title") |         ordering = ("correspondent", "title") | ||||||
|   | |||||||
| @@ -129,24 +129,25 @@ | |||||||
|     {# 0: Checkbox #} |     {# 0: Checkbox #} | ||||||
|     {# 1: Title #} |     {# 1: Title #} | ||||||
|     {# 2: Date #} |     {# 2: Date #} | ||||||
|     {# 3: Image #} |     {# 3: Added #} | ||||||
|     {# 4: Correspondent #} |     {# 4: Image #} | ||||||
|     {# 5: Tags #} |     {# 5: Correspondent #} | ||||||
|     {# 6: Document edit url #} |     {# 6: Tags #} | ||||||
|  |     {# 7: Document edit url #} | ||||||
|     <div class="box"> |     <div class="box"> | ||||||
|       <div class="result"> |       <div class="result"> | ||||||
|         <div class="header" onclick="location.href='{{ result.6 }}';" style="cursor: pointer;"> |         <div class="header" onclick="location.href='{{ result.7 }}';" style="cursor: pointer;"> | ||||||
|           <div class="checkbox">{{ result.0 }}</div> |           <div class="checkbox">{{ result.0 }}</div> | ||||||
|           <div class="info"> |           <div class="info"> | ||||||
|             {{ result.4 }}<br /> |             {{ result.5 }}<br /> | ||||||
|             {{ result.1 }} |             {{ result.1 }} | ||||||
|           </div> |           </div> | ||||||
|           <div style="clear: both;"></div> |           <div style="clear: both;"></div> | ||||||
|         </div> |         </div> | ||||||
|         <div class="tags">{{ result.5 }}</div> |         <div class="tags">{{ result.6 }}</div> | ||||||
|         <div class="date">{{ result.2 }}</div> |         <div class="date">{{ result.2 }}</div> | ||||||
|         <div style="clear: both;"></div> |         <div style="clear: both;"></div> | ||||||
|         <div class="image">{{ result.3 }}</div> |         <div class="image">{{ result.4 }}</div> | ||||||
|       </div> |       </div> | ||||||
|     </div> |     </div> | ||||||
|   {% endfor %} |   {% endfor %} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Erik Arvstedt
					Erik Arvstedt