Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support HTML tags for Django 2.0 #74

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion django_celery_monitor/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.utils.encoding import force_text
from django.utils.html import escape
from django.utils.html import escape, mark_safe
from django.utils.translation import ugettext_lazy as _

from celery import current_app
Expand Down Expand Up @@ -40,6 +40,7 @@ def __init__(self, *args, **kwargs):
self.title = self.model_admin.list_page_title


@mark_safe
@display_field(_('state'), 'state')
def colored_state(task):
"""Return the task state colored with HTML/CSS according to its level.
Expand All @@ -51,6 +52,7 @@ def colored_state(task):
return '<b><span style="color: {0};">{1}</span></b>'.format(color, state)


@mark_safe
@display_field(_('state'), 'last_heartbeat')
def node_state(node):
"""Return the worker state colored with HTML/CSS according to its level.
Expand All @@ -62,6 +64,7 @@ def node_state(node):
return '<b><span style="color: {0};">{1}</span></b>'.format(color, state)


@mark_safe
@display_field(_('ETA'), 'eta')
def eta(task):
"""Return the task ETA as a grey "none" if none is provided."""
Expand All @@ -70,6 +73,7 @@ def eta(task):
return escape(make_aware(task.eta))


@mark_safe
@display_field(_('when'), 'tstamp')
def tstamp(task):
"""Better timestamp rendering.
Expand All @@ -83,6 +87,7 @@ def tstamp(task):
)


@mark_safe
@display_field(_('name'), 'name')
def name(task):
"""Return the task name and abbreviates it to maximum of 16 characters."""
Expand Down
4 changes: 2 additions & 2 deletions django_celery_monitor/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from django.conf import settings
from django.db.models import DateTimeField, Func
from django.utils import timezone
from django.utils.html import escape
from django.utils.html import escape, mark_safe

try:
from django.db.models.functions import Now
Expand Down Expand Up @@ -109,4 +109,4 @@ def f(task):
escape(val[:255]), pt, escape(shortval),
)
return styled.replace('|br/|', '<br/>')
return f
return mark_safe(f)
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[tox]
envlist =
tests-py{py,27,34,35}-dj{18,19,110}
tests-py36-dj111
tests-py{py,27,34,35,36}-dj111
tests-py{34,35,36}-dj20
apicheck
builddocs
flake8
Expand All @@ -28,6 +29,7 @@ deps=
dj19: django>=1.9,<1.10
dj110: django>=1.10,<1.11
dj111: django>=1.11,<2
dj20: django>=2.0,<2.1

apicheck,builddocs,linkcheck: -r{toxinidir}/requirements/docs.txt
flake8,flakeplus,manifest,pydocstyle,readme: -r{toxinidir}/requirements/pkgutils.txt
Expand Down