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))
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))
def __normalize_name(self): """Normalize the name attribute and assign it the normalized_name attribute. """ self.normalized_name = normalizeSimplified(self.name)
def save(self): self.normalized_variant = normalizeSimplified(self.variant) super(Variant, self).save()
def normalize_naco(value): """Use NACO normalization rules from UNT Libraries pynaco""" value = value.strip() return naco.normalizeSimplified(value)