コード例 #1
0
ファイル: views.py プロジェクト: fondrenlibrary/django-name
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))
コード例 #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))
コード例 #3
0
ファイル: models.py プロジェクト: rubinsztajn/django-name
 def __normalize_name(self):
     """Normalize the name attribute and assign it the normalized_name
     attribute.
     """
     self.normalized_name = normalizeSimplified(self.name)
コード例 #4
0
ファイル: models.py プロジェクト: rubinsztajn/django-name
 def save(self):
     self.normalized_variant = normalizeSimplified(self.variant)
     super(Variant, self).save()
コード例 #5
0
def normalize_naco(value):
    """Use NACO normalization rules from UNT Libraries pynaco"""

    value = value.strip()

    return naco.normalizeSimplified(value)
コード例 #6
0
ファイル: models.py プロジェクト: unt-libraries/django-name
 def __normalize_name(self):
     """Normalize the name attribute and assign it the normalized_name
     attribute.
     """
     self.normalized_name = normalizeSimplified(self.name)
コード例 #7
0
ファイル: models.py プロジェクト: unt-libraries/django-name
 def save(self):
     self.normalized_variant = normalizeSimplified(self.variant)
     super(Variant, self).save()