1
0
Fork 0
mirror of https://github.com/Findus23/acronomy.git synced 2024-09-19 15:33:45 +02:00

add datacheck for empty tags

fixes #12
This commit is contained in:
Lukas Winkler 2020-08-03 21:27:26 +02:00
parent 70953c8419
commit 6db948631b
Signed by: lukas
GPG key ID: 54DE4D798D244853
4 changed files with 28 additions and 6 deletions

View file

@ -11,9 +11,15 @@
<strong>{{ error.obj }}</strong>:
{{ error.msg }}
<br>
{% if error.obj.get_absolute_url %}
<a href="{{ error.obj.get_absolute_url }}" class="alert-link">View</a>
{% endif %}
{% if error.edit_url %}
<a href="{{ error.edit_url }}" class="alert-link">Edit</a>
{% endif %}
{% if error.admin_edit_url %}
<a href="{{ error.admin_edit_url }}" class="alert-link">Admin-Edit</a>
{% endif %}
</div>
{% empty %}
<div class="alert alert-success" role="alert">

View file

@ -3,3 +3,4 @@ from .check_registry import CheckRegistry, registry
from .messages import DEBUG, INFO, WARNING, ERROR, CRITICAL, CheckMessage, CheckWarning, CheckInfo
from .checks.acronym import *
from .checks.image import *
from .checks.tags import *

View file

@ -0,0 +1,13 @@
from acros.models import Tag
from acros.utils.checks import BaseCheck, CheckWarning, registry
class TagsCheck(BaseCheck):
def run(self):
for tag in Tag.objects.filter(acronyms=None):
yield CheckWarning(
"Tag is unused",
obj=tag)
registry.register(TagsCheck)

View file

@ -1,6 +1,6 @@
from django.urls import reverse
from acros.models import Acronym
from acros.models import Acronym, Tag
DEBUG = 10
INFO = "info"
@ -30,6 +30,8 @@ class CheckMessage:
def admin_edit_url(self):
if isinstance(self.obj, Acronym):
return reverse("admin:acros_acronym_change", args=[self.obj.id])
if isinstance(self.obj, Tag):
return reverse("admin:acros_tag_change", args=[self.obj.id])
return None