Exemplo n.º 1
0
def label(request, name_value):
    """Find a name by label.

    If the label matches a single name, users are redirected
    to the name detail page. Otherwise, if the label
    does not exist, or the specified label matches multiple Name
    objects, a status code 404 is returned.
    """
    if not name_value:
        return http.HttpResponseNotFound()

    normalized_name = normalizeSimplified(name_value)
    try:
        name = Name.objects.get(normalized_name=normalized_name)

        return http.HttpResponseRedirect(
            reverse('name:detail', args=[name.name_id]))

    except Name.DoesNotExist:
        return http.HttpResponseNotFound(
            'No matching term found - authoritative or variant - for "{0}"'
            .format(name_value))

    except Name.MultipleObjectsReturned:
        return http.HttpResponseNotFound(
            'There are multiple Name objects with the same name: "{0}".'
            .format(normalized_name))
Exemplo n.º 2
0
def label(request, name_value):
    """Find a name by label.

    If the label matches a single name, users are redirected
    to the name detail page. Otherwise, if the label
    does not exist, or the specified label matches multiple Name
    objects, a status code 404 is returned.
    """
    if not name_value:
        return http.HttpResponseNotFound()

    normalized_name = normalizeSimplified(name_value)
    try:
        name = Name.objects.get(normalized_name=normalized_name)

        return http.HttpResponseRedirect(
            reverse('name:detail', args=[name.name_id]))

    except Name.DoesNotExist:
        return http.HttpResponseNotFound(
            'No matching term found - authoritative or variant - for "{0}"'.
            format(name_value))

    except Name.MultipleObjectsReturned:
        return http.HttpResponseNotFound(
            'There are multiple Name objects with the same name: "{0}".'.
            format(normalized_name))
Exemplo n.º 3
0
 def __normalize_name(self):
     """Normalize the name attribute and assign it the normalized_name
     attribute.
     """
     self.normalized_name = normalizeSimplified(self.name)
Exemplo n.º 4
0
 def save(self):
     self.normalized_variant = normalizeSimplified(self.variant)
     super(Variant, self).save()
Exemplo n.º 5
0
def normalize_naco(value):
    """Use NACO normalization rules from UNT Libraries pynaco"""

    value = value.strip()

    return naco.normalizeSimplified(value)
Exemplo n.º 6
0
 def __normalize_name(self):
     """Normalize the name attribute and assign it the normalized_name
     attribute.
     """
     self.normalized_name = normalizeSimplified(self.name)
Exemplo n.º 7
0
 def save(self):
     self.normalized_variant = normalizeSimplified(self.variant)
     super(Variant, self).save()