mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-28 03:46:06 -05:00 
			
		
		
		
	Prettied up the admin
This commit is contained in:
		| @@ -1,5 +1,6 @@ | |||||||
| from django.conf import settings | from django.conf import settings | ||||||
| from django.contrib import admin | from django.contrib import admin | ||||||
|  | from django.templatetags.static import static | ||||||
|  |  | ||||||
| from .models import Document | from .models import Document | ||||||
|  |  | ||||||
| @@ -7,10 +8,15 @@ from .models import Document | |||||||
| class DocumentAdmin(admin.ModelAdmin): | class DocumentAdmin(admin.ModelAdmin): | ||||||
|  |  | ||||||
|     search_fields = ("sender", "title", "content",) |     search_fields = ("sender", "title", "content",) | ||||||
|     list_display = ("created", "sender", "title", "thumbnail", "pdf") |     list_display = ("edit", "created", "sender", "title", "thumbnail", "pdf") | ||||||
|     list_filter = ("created", "sender") |     list_filter = ("created", "sender") | ||||||
|     save_on_top = True |     save_on_top = True | ||||||
|  |  | ||||||
|  |     def edit(self, obj): | ||||||
|  |         return '<img src="{}" width="64" height="64" alt="Edit icon" />'.format( | ||||||
|  |             static("documents/img/edit.png")) | ||||||
|  |     edit.allow_tags = True | ||||||
|  |  | ||||||
|     def thumbnail(self, obj): |     def thumbnail(self, obj): | ||||||
|         return '<a href="{media}documents/img/{pk:07}.jpg" target="_blank">' \ |         return '<a href="{media}documents/img/{pk:07}.jpg" target="_blank">' \ | ||||||
|                  '<img src="{media}documents/img/{pk:07}.jpg" width="100" />' \ |                  '<img src="{media}documents/img/{pk:07}.jpg" width="100" />' \ | ||||||
| @@ -18,8 +24,13 @@ class DocumentAdmin(admin.ModelAdmin): | |||||||
|     thumbnail.allow_tags = True |     thumbnail.allow_tags = True | ||||||
|  |  | ||||||
|     def pdf(self, obj): |     def pdf(self, obj): | ||||||
|         return '<a href="{}documents/pdf/{:07}.pdf">Download</a>'.format( |         return '<a href="{}documents/pdf/{:07}.pdf">' \ | ||||||
|             settings.MEDIA_URL, obj.pk) |                  '<img src="{}" width="64" height="64" alt="PDF icon">' \ | ||||||
|  |                '</a>'.format( | ||||||
|  |                     settings.MEDIA_URL, | ||||||
|  |                     obj.pk, | ||||||
|  |                     static("documents/img/application-pdf.png") | ||||||
|  |                 ) | ||||||
|     pdf.allow_tags = True |     pdf.allow_tags = True | ||||||
|  |  | ||||||
| admin.site.register(Document, DocumentAdmin) | admin.site.register(Document, DocumentAdmin) | ||||||
|   | |||||||
							
								
								
									
										
											BIN
										
									
								
								src/documents/static/documents/img/application-pdf.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								src/documents/static/documents/img/application-pdf.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 4.5 KiB | 
							
								
								
									
										
											BIN
										
									
								
								src/documents/static/documents/img/edit.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								src/documents/static/documents/img/edit.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 3.8 KiB | 
| @@ -19,5 +19,5 @@ from django.conf.urls import url, static | |||||||
| from django.contrib import admin | from django.contrib import admin | ||||||
|  |  | ||||||
| urlpatterns = [ | urlpatterns = [ | ||||||
|     url(r'^admin/', admin.site.urls), |     url(r'', admin.site.urls), | ||||||
| ] + static.static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) | ] + static.static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Daniel Quinn
					Daniel Quinn