Branch: refs/heads/master Author: Enrico Tröger enrico.troeger@uvena.de Committer: Enrico Tröger enrico.troeger@uvena.de Date: Sun, 05 Jun 2022 11:47:08 UTC Commit: b3ecb721f714e453d6a47f3b73b44a322edbbaee https://github.com/geany/www.geany.org/commit/b3ecb721f714e453d6a47f3b73b44a...
Log Message: ----------- Add content preview to Pastebin list in Django Admin
Modified Paths: -------------- pastebin/admin.py
Modified: pastebin/admin.py 11 lines changed, 9 insertions(+), 2 deletions(-) =================================================================== @@ -13,14 +13,21 @@ # along with this program. If not, see http://www.gnu.org/licenses/.
from django.contrib import admin +from django.template.defaultfilters import truncatewords
from pastebin.models import Snippet, Spamword
class SnippetAdmin(admin.ModelAdmin): - list_display = ('published', 'expires', 'author', 'title') + list_display = ('published', 'author', 'title', 'get_content_preview') date_hierarchy = 'published' - list_filter = ('published',) + list_filter = ('published', 'lexer') + + def get_content_preview(self, obj): + return truncatewords(obj.content, 15) + + get_content_preview.allow_tags = True + get_content_preview.short_description = 'Content'
admin.site.register(Snippet, SnippetAdmin)
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).