Skip to content

Instantly share code, notes, and snippets.

@mekhami
Created October 21, 2015 16:21
Show Gist options
  • Select an option

  • Save mekhami/3b9058d879218f4b71c2 to your computer and use it in GitHub Desktop.

Select an option

Save mekhami/3b9058d879218f4b71c2 to your computer and use it in GitHub Desktop.
def clean(self):
""" Validate site and people resource ids with Doorman """
if settings.FEATURE_DOORMAN_VALIDATION_ON:
doorman = DoormanClient()
if hasattr(self, 'site'):
if not doorman.resource_exists(resource='sites', resource_id=self.site):
raise ValidationError('Invalid site id: {0}'.format(self.site))
if hasattr(self, 'editor'):
if not doorman.resource_exists(resource='people', resource_id=self.editor):
raise ValidationError('Invalid editor id: {0}'.format(self.editor))
if hasattr(self, 'author'):
if not doorman.resource_exists(resource='author-profiles', resource_id=self.author):
raise ValidationError('Invalid author id: {0}'.format(self.author))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment