def create(cls, event):
        """Create a new Release model."""
        # Check if the release has already been received
        release_id = event.payload['release']['id']
        existing_release = Release.query.filter_by(
            release_id=release_id,
        ).first()
        if existing_release:
            raise ReleaseAlreadyReceivedError(
                u'{release} has already been received.'
                .format(release=existing_release)
            )

        # Create the Release
        repo_id = event.payload['repository']['id']
        repo = Repository.get(user_id=event.user_id, github_id=repo_id)
        if repo.enabled:
            with db.session.begin_nested():
                release = cls(
                    release_id=release_id,
                    tag=event.payload['release']['tag_name'],
                    repository=repo,
                    event=event,
                    status=ReleaseStatus.RECEIVED,
                )
                db.session.add(release)
            return release
        else:
            current_app.logger.warning(
                u'Release creation attempt on disabled {repo}.'
                .format(repo=repo)
            )
            raise RepositoryDisabledError(
                u'{repo} is not enabled for webhooks.'.format(repo=repo)
            )
Create a new Release model.