from .models import Alert
-admin.site.register(Alert)
+@admin.register(Alert)
+class AlertAdmin(admin.ModelAdmin):
+ list_display = ['book', 'tag']
+ list_filter = ['tag']
--- /dev/null
+# Generated by Django 3.2.12 on 2022-05-23 11:58
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('alerts', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='alert',
+ name='comment',
+ field=models.TextField(blank=True),
+ ),
+ ]
class Alert(models.Model):
book = models.ForeignKey('documents.Book', models.CASCADE)
tag = models.CharField(max_length=32)
+ comment = models.TextField(blank=True)
+
+ def get_absolute_url(self):
+ return self.book.get_absolute_url()
@property
def rule(self):
cls.objects.filter(book=book).delete()
try:
wlbook = book.wldocument(publishable=False, librarian2=True)
- except:
- cls.objects.create(book=book, tag='parse')
+ except Exception:
+ cls.objects.create(book=book, tag='parse', comment=str(e))
return
+ try:
+ meta = wlbook.meta
+ except Exception as e:
+ cls.objects.create(book=book, tag='meta', comment=str(e))
+ return
+
for rule in rules:
- if rule.check_meta(wlbook.meta):
+ if rule.check_meta(meta):
print(rule.tag, book)
cls.objects.create(book=book, tag=rule.tag)
description = _('Book parse error.')
+class CheckMeta(Check):
+ tag = 'meta'
+ description = _('Metadata parse error.')
+
+
class CheckCoverLocal(Check):
tag = 'cover-local'
description = _('Cover is not local')
rules = [
CheckParse(),
+ CheckMeta(),
CheckCoverLocal(),
]