File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change 1
1
from django .contrib import admin
2
2
from django .conf import settings
3
3
from django .contrib import messages
4
- from django .template .defaultfilters import linebreaks
4
+ from django .template .defaultfilters import linebreaksbr
5
5
from django .utils import timezone
6
6
from django .utils .translation import gettext
7
7
from django .utils .translation import gettext_lazy as _
@@ -106,7 +106,24 @@ def content_type_name(instance):
106
106
@staticmethod
107
107
@admin .display (description = _ ('notification' ))
108
108
def notification (instance ):
109
- return mark_safe (linebreaks (instance .report ))
109
+ report = instance .report or ""
110
+ lines = report .count ('\n ' ) + 1 if report else 0
111
+ content = linebreaksbr (report )
112
+ style = (
113
+ "overflow:auto; max-height:200px;"
114
+ "white-space:pre-wrap;"
115
+ ) if lines >= 20 else "white-space:pre-wrap;"
116
+ custom_scrollbar = (
117
+ "<style>"
118
+ "div.mailingout-scroll::-webkit-scrollbar {width:10px;}"
119
+ "div.mailingout-scroll::-webkit-scrollbar-thumb {background:#ccc; border-radius:3px;}"
120
+ "</style>"
121
+ if lines >= 20 else ""
122
+ )
123
+ div_class = "mailingout-scroll" if lines >= 20 else ""
124
+ return mark_safe (
125
+ f'{ custom_scrollbar } <div class="{ div_class } " style="{ style } ">{ content } </div>'
126
+ )
110
127
111
128
@staticmethod
112
129
@admin .display (description = progress_safe_str )
You can’t perform that action at this time.
0 commit comments