Exemplo n.º 1
0
 def clean_slug(self):
     slug = self.cleaned_data['slug']
     client = get_atom_client()
     try:
         client.find_parent_id_for_component(slug)
     except (Timeout, ConnectionError):
         raise forms.ValidationError(
             _('Connection establishment failed: AtoM server cannot be reached.'
               ))
     except CommunicationError as e:
         if '404' in e.message:
             raise forms.ValidationError(
                 _('Description with slug %(slug)s not found!'),
                 code='notfound',
                 params={'slug': slug})
         raise forms.ValidationError(_('Unknown error: %(error)s'),
                                     code='error',
                                     params={'error': e.message})
     return slug
Exemplo n.º 2
0
 def clean_slug(self):
     slug = self.cleaned_data["slug"]
     client = get_atom_client()
     try:
         client.find_parent_id_for_component(slug)
     except (Timeout, ConnectionError):
         raise forms.ValidationError(
             _("Connection establishment failed: AtoM server cannot be reached."
               ))
     except CommunicationError as e:
         if "404" in e.message:
             raise forms.ValidationError(
                 _("Description with slug %(slug)s not found!"),
                 code="notfound",
                 params={"slug": slug},
             )
         raise forms.ValidationError(_("Unknown error: %(error)s"),
                                     code="error",
                                     params={"error": e.message})
     return slug