def restore_object(self, attrs, instance=None): request_user = self.context['request'].user mnemonic = attrs.get('mnemonic', None) if Organization.objects.filter(mnemonic=mnemonic).exists(): self._errors['mnemonic'] = 'Organization with mnemonic %s already exists.' % mnemonic return None organization = Organization(name=attrs.get('name'), mnemonic=mnemonic) organization.created_by = request_user organization.updated_by = request_user organization.public_access = attrs.get('public_access', DEFAULT_ACCESS_TYPE) organization.company = attrs.get('company', None) organization.website = attrs.get('website', None) organization.location = attrs.get('location', None) organization.extras = attrs.get('extras', None) return organization
def restore_object(self, attrs, instance=None): request_user = self.context['request'].user mnemonic = attrs.get('mnemonic', None) if Organization.objects.filter(mnemonic=mnemonic).exists(): self._errors[ 'mnemonic'] = 'Organization with mnemonic %s already exists.' % mnemonic return None organization = Organization(name=attrs.get('name'), mnemonic=mnemonic) organization.created_by = request_user organization.updated_by = request_user organization.public_access = attrs.get('public_access', DEFAULT_ACCESS_TYPE) organization.company = attrs.get('company', None) organization.website = attrs.get('website', None) organization.location = attrs.get('location', None) organization.extras = attrs.get('extras', None) return organization