X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/deabe6b4d1a81b2f553526a6172227dd00fe8817..9d0a4f124c6b0dca121206c8b4f12826c510906a:/src/alerts/rules.py diff --git a/src/alerts/rules.py b/src/alerts/rules.py new file mode 100644 index 00000000..c7903f1a --- /dev/null +++ b/src/alerts/rules.py @@ -0,0 +1,35 @@ +import re +from django.utils.translation import gettext_lazy as _ + + +class Check: + def check_meta(self, meta): + return False + + +class CheckParse(Check): + tag = 'parse' + description = _('Book parse error.') + + +class CheckCoverLocal(Check): + tag = 'cover-local' + description = _('Cover is not local') + + def check_meta(self, meta): + print(meta) + if meta.cover_source is None: + print('no cover_source') + return False + return not re.match(r'https?://redakcja.wolnelektury.pl/cover/image/', meta.cover_source) + + +rules = [ + CheckParse(), + CheckCoverLocal(), +] + +rules_by_tag = { + r.tag: r + for r in rules +}