def perform_create(self, ser): try: project = ser.save(organization=self.request.user.active_organization) except IntegrityError as e: if str(e) == 'UNIQUE constraint failed: project.title, project.created_by_id': raise ProjectExistException('Project with the same name already exists: {}'. format(ser.validated_data.get('title', ''))) raise LabelStudioDatabaseException('Database error during project creation. Try again.')
def perform_create(self, ser): # get organization org_pk = self.request.session.get('organization_pk') org = get_object_with_check_and_log(self.request, Organization, pk=org_pk) self.check_object_permissions(self.request, org) try: project = ser.save(organization=org) except IntegrityError as e: if str(e) == 'UNIQUE constraint failed: project.title, project.created_by_id': raise ProjectExistException('Project with the same name already exists: {}'. format(ser.validated_data.get('title', ''))) raise LabelStudioDatabaseException('Database error during project creation. Try again.')