mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Merge pull request #1440 from GwynHannay/feature-orig-filename-metadata
Feature: Preserve original filename in metadata
This commit is contained in:
		| @@ -171,6 +171,7 @@ into paperless. It receives the following environment variables: | ||||
| * ``DOCUMENT_THUMBNAIL_URL`` | ||||
| * ``DOCUMENT_CORRESPONDENT`` | ||||
| * ``DOCUMENT_TAGS`` | ||||
| * ``DOCUMENT_ORIGINAL_FILENAME`` | ||||
|  | ||||
| The script can be in any language, but for a simple shell script | ||||
| example, you can take a look at `post-consumption-example.sh`_ in this project. | ||||
|   | ||||
| @@ -816,7 +816,7 @@ | ||||
|         </context-group> | ||||
|         <context-group purpose="location"> | ||||
|           <context context-type="sourcefile">src/app/components/document-detail/document-detail.component.html</context> | ||||
|           <context context-type="linenumber">174</context> | ||||
|           <context context-type="linenumber">178</context> | ||||
|         </context-group> | ||||
|         <context-group purpose="location"> | ||||
|           <context context-type="sourcefile">src/app/components/document-list/save-view-config-dialog/save-view-config-dialog.component.html</context> | ||||
| @@ -1570,78 +1570,85 @@ | ||||
|           <context context-type="linenumber">113</context> | ||||
|         </context-group> | ||||
|       </trans-unit> | ||||
|       <trans-unit id="4500855521601039868" datatype="html"> | ||||
|         <source>Original filename</source> | ||||
|         <context-group purpose="location"> | ||||
|           <context context-type="sourcefile">src/app/components/document-detail/document-detail.component.html</context> | ||||
|           <context context-type="linenumber">117</context> | ||||
|         </context-group> | ||||
|       </trans-unit> | ||||
|       <trans-unit id="7985558498848210210" datatype="html"> | ||||
|         <source>Original MD5 checksum</source> | ||||
|         <context-group purpose="location"> | ||||
|           <context context-type="sourcefile">src/app/components/document-detail/document-detail.component.html</context> | ||||
|           <context context-type="linenumber">117</context> | ||||
|           <context context-type="linenumber">121</context> | ||||
|         </context-group> | ||||
|       </trans-unit> | ||||
|       <trans-unit id="5888243105821763422" datatype="html"> | ||||
|         <source>Original file size</source> | ||||
|         <context-group purpose="location"> | ||||
|           <context context-type="sourcefile">src/app/components/document-detail/document-detail.component.html</context> | ||||
|           <context context-type="linenumber">121</context> | ||||
|           <context context-type="linenumber">125</context> | ||||
|         </context-group> | ||||
|       </trans-unit> | ||||
|       <trans-unit id="2696647325713149563" datatype="html"> | ||||
|         <source>Original mime type</source> | ||||
|         <context-group purpose="location"> | ||||
|           <context context-type="sourcefile">src/app/components/document-detail/document-detail.component.html</context> | ||||
|           <context context-type="linenumber">125</context> | ||||
|           <context context-type="linenumber">129</context> | ||||
|         </context-group> | ||||
|       </trans-unit> | ||||
|       <trans-unit id="342875990758166588" datatype="html"> | ||||
|         <source>Archive MD5 checksum</source> | ||||
|         <context-group purpose="location"> | ||||
|           <context context-type="sourcefile">src/app/components/document-detail/document-detail.component.html</context> | ||||
|           <context context-type="linenumber">129</context> | ||||
|           <context context-type="linenumber">133</context> | ||||
|         </context-group> | ||||
|       </trans-unit> | ||||
|       <trans-unit id="6033581412811562084" datatype="html"> | ||||
|         <source>Archive file size</source> | ||||
|         <context-group purpose="location"> | ||||
|           <context context-type="sourcefile">src/app/components/document-detail/document-detail.component.html</context> | ||||
|           <context context-type="linenumber">133</context> | ||||
|           <context context-type="linenumber">137</context> | ||||
|         </context-group> | ||||
|       </trans-unit> | ||||
|       <trans-unit id="6992781481378431874" datatype="html"> | ||||
|         <source>Original document metadata</source> | ||||
|         <context-group purpose="location"> | ||||
|           <context context-type="sourcefile">src/app/components/document-detail/document-detail.component.html</context> | ||||
|           <context context-type="linenumber">139</context> | ||||
|           <context context-type="linenumber">143</context> | ||||
|         </context-group> | ||||
|       </trans-unit> | ||||
|       <trans-unit id="2846565152091361585" datatype="html"> | ||||
|         <source>Archived document metadata</source> | ||||
|         <context-group purpose="location"> | ||||
|           <context context-type="sourcefile">src/app/components/document-detail/document-detail.component.html</context> | ||||
|           <context context-type="linenumber">140</context> | ||||
|           <context context-type="linenumber">144</context> | ||||
|         </context-group> | ||||
|       </trans-unit> | ||||
|       <trans-unit id="8191371354890763172" datatype="html"> | ||||
|         <source>Enter Password</source> | ||||
|         <context-group purpose="location"> | ||||
|           <context context-type="sourcefile">src/app/components/document-detail/document-detail.component.html</context> | ||||
|           <context context-type="linenumber">162</context> | ||||
|           <context context-type="linenumber">166</context> | ||||
|         </context-group> | ||||
|         <context-group purpose="location"> | ||||
|           <context context-type="sourcefile">src/app/components/document-detail/document-detail.component.html</context> | ||||
|           <context context-type="linenumber">192</context> | ||||
|           <context context-type="linenumber">196</context> | ||||
|         </context-group> | ||||
|       </trans-unit> | ||||
|       <trans-unit id="3823219296477075982" datatype="html"> | ||||
|         <source>Discard</source> | ||||
|         <context-group purpose="location"> | ||||
|           <context context-type="sourcefile">src/app/components/document-detail/document-detail.component.html</context> | ||||
|           <context context-type="linenumber">172</context> | ||||
|           <context context-type="linenumber">176</context> | ||||
|         </context-group> | ||||
|       </trans-unit> | ||||
|       <trans-unit id="5129524307369213584" datatype="html"> | ||||
|         <source>Save & next</source> | ||||
|         <context-group purpose="location"> | ||||
|           <context context-type="sourcefile">src/app/components/document-detail/document-detail.component.html</context> | ||||
|           <context context-type="linenumber">173</context> | ||||
|           <context context-type="linenumber">177</context> | ||||
|         </context-group> | ||||
|       </trans-unit> | ||||
|       <trans-unit id="9021887951960049161" datatype="html"> | ||||
|   | ||||
| @@ -113,6 +113,10 @@ | ||||
|                                     <td i18n>Media filename</td> | ||||
|                                     <td>{{metadata?.media_filename}}</td> | ||||
|                                 </tr> | ||||
|                                 <tr> | ||||
|                                     <td i18n>Original filename</td> | ||||
|                                     <td>{{metadata?.original_filename}}</td> | ||||
|                                 </tr> | ||||
|                                 <tr> | ||||
|                                     <td i18n>Original MD5 checksum</td> | ||||
|                                     <td>{{metadata?.original_checksum}}</td> | ||||
|   | ||||
| @@ -7,5 +7,7 @@ export interface PaperlessDocumentMetadata { | ||||
|  | ||||
|   media_filename?: string | ||||
|  | ||||
|   original_filename?: string | ||||
|  | ||||
|   has_archive_version?: boolean | ||||
| } | ||||
|   | ||||
| @@ -42,6 +42,7 @@ class DocumentAdmin(admin.ModelAdmin): | ||||
|         "checksum", | ||||
|         "archive_filename", | ||||
|         "archive_checksum", | ||||
|         "original_filename", | ||||
|     ) | ||||
|  | ||||
|     list_display_links = ("title",) | ||||
|   | ||||
| @@ -203,6 +203,7 @@ class Consumer(LoggingMixin): | ||||
|         script_env["DOCUMENT_TAGS"] = str( | ||||
|             ",".join(document.tags.all().values_list("name", flat=True)), | ||||
|         ) | ||||
|         script_env["DOCUMENT_ORIGINAL_FILENAME"] = str(document.original_filename) | ||||
|  | ||||
|         try: | ||||
|             Popen( | ||||
| @@ -475,6 +476,7 @@ class Consumer(LoggingMixin): | ||||
|                 created=create_date, | ||||
|                 modified=create_date, | ||||
|                 storage_type=storage_type, | ||||
|                 original_filename=self.filename, | ||||
|             ) | ||||
|  | ||||
|         self.apply_overrides(document) | ||||
|   | ||||
							
								
								
									
										25
									
								
								src/documents/migrations/1023_document_original_filename.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								src/documents/migrations/1023_document_original_filename.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| # Generated by Django 4.0.6 on 2022-07-25 06:34 | ||||
|  | ||||
| from django.db import migrations, models | ||||
|  | ||||
|  | ||||
| class Migration(migrations.Migration): | ||||
|  | ||||
|     dependencies = [ | ||||
|         ("documents", "1022_paperlesstask"), | ||||
|     ] | ||||
|  | ||||
|     operations = [ | ||||
|         migrations.AddField( | ||||
|             model_name="document", | ||||
|             name="original_filename", | ||||
|             field=models.CharField( | ||||
|                 default=None, | ||||
|                 editable=False, | ||||
|                 help_text="The original name of the file when it was uploaded", | ||||
|                 max_length=1024, | ||||
|                 null=True, | ||||
|                 verbose_name="original filename", | ||||
|             ), | ||||
|         ), | ||||
|     ] | ||||
| @@ -214,6 +214,16 @@ class Document(models.Model): | ||||
|         help_text=_("Current archive filename in storage"), | ||||
|     ) | ||||
|  | ||||
|     original_filename = models.CharField( | ||||
|         _("original filename"), | ||||
|         max_length=1024, | ||||
|         editable=False, | ||||
|         default=None, | ||||
|         unique=False, | ||||
|         null=True, | ||||
|         help_text=_("The original name of the file when it was uploaded"), | ||||
|     ) | ||||
|  | ||||
|     archive_serial_number = models.IntegerField( | ||||
|         _("archive serial number"), | ||||
|         blank=True, | ||||
|   | ||||
| @@ -313,6 +313,7 @@ class DocumentViewSet( | ||||
|             "original_metadata": self.get_metadata(doc.source_path, doc.mime_type), | ||||
|             "archive_checksum": doc.archive_checksum, | ||||
|             "archive_media_filename": doc.archive_filename, | ||||
|             "original_filename": doc.original_filename, | ||||
|         } | ||||
|  | ||||
|         if doc.has_archive_version: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 shamoon
					shamoon