Skip to content

Commit

Permalink
Merge pull request #2017 from laws-africa/indigo-resolver-translations
Browse files Browse the repository at this point in the history
translations: indigo-resolver/models.py
  • Loading branch information
longhotsummer authored Mar 7, 2024
2 parents 519ff2b + 2d4dd10 commit 85d08f4
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions indigo_resolver/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding=utf-8
import re

from django.db import models
Expand All @@ -19,14 +18,15 @@ class Authority(models.Model):
""" Authority that knows how to resolve
FRBR URIs into real-world URLs.
"""
name = models.CharField(max_length=255, unique=True, help_text="Descriptive name of this resolver")
url = models.URLField(help_text="Website for this authority (optional)", blank=True, null=True)
not_found_url = models.URLField(help_text="URL of a 404 page (optional)", null=True, blank=True)
slug = models.CharField(null=False, blank=False, validators=[validate_slug], max_length=50, unique=True)
priority = models.IntegerField(null=False, default=10, help_text="When multiple resolvers match, highest priority wins")
name = models.CharField(_("name"), max_length=255, unique=True, help_text=_("Descriptive name of this resolver"))
url = models.URLField(_("URL"), help_text=_("Website for this authority (optional)"), blank=True, null=True)
not_found_url = models.URLField(_("not found URL"), help_text=_("URL of a 404 page (optional)"), null=True, blank=True)
slug = models.CharField(_("slug"), null=False, blank=False, validators=[validate_slug], max_length=50, unique=True)
priority = models.IntegerField(_("priority"), null=False, default=10, help_text=_("When multiple resolvers match, highest priority wins"))

class Meta:
verbose_name_plural = "Authorities"
verbose_name = _("authority")
verbose_name_plural = _("authorities")

def get_references(self, frbr_uri):
# TODO: handle expression URIs and dates?
Expand All @@ -49,20 +49,21 @@ def __str__(self):


class AuthorityReference(models.Model):
""" Reference to a particular document,
belonging to a resolver.
""" Reference to a particular document, belonging to a resolver.
"""
frbr_uri = models.CharField(max_length=255, db_index=True, help_text="FRBR Work or Expression URI to match on")
title = models.CharField(max_length=255, help_text="Document title")
url = models.URLField(max_length=1024, help_text="URL from which this document can be retrieved")
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
priority = models.IntegerField(null=True, blank=True, help_text="Priority for this URL. If unset, uses the authority's priority")
frbr_uri = models.CharField(_("FRBR URI"), max_length=255, db_index=True, help_text=_("FRBR Work or Expression URI to match on"))
title = models.CharField(_("title"), max_length=255, help_text=_("Document title"))
url = models.URLField(_("URL"), max_length=1024, help_text=_("URL from which this document can be retrieved"))
created_at = models.DateTimeField(_("created at"), auto_now_add=True)
updated_at = models.DateTimeField(_("updated at"), auto_now=True)
priority = models.IntegerField(_("priority"), null=True, blank=True, help_text=_("Priority for this URL. If unset, uses the authority's priority"))

authority = models.ForeignKey(Authority, related_name='references', on_delete=models.CASCADE)
authority = models.ForeignKey(Authority, related_name='references', on_delete=models.CASCADE, verbose_name=_("authority"))

class Meta:
unique_together = ('authority', 'frbr_uri')
verbose_name = _("authority reference")
verbose_name_plural = _("authority references")

def authority_name(self):
if self.authority.url:
Expand Down

0 comments on commit 85d08f4

Please sign in to comment.