democrasite.webiscite.webhooks module¶
Views for processing webhooks.
Each service that sends webhooks should have its own class-based view.
- class democrasite.webiscite.webhooks.GithubWebhookView(**kwargs)¶
Bases:
ViewView for GitHub webhook alerts
Verifies that the request is valid and, if so, creates a Celery task to process it
- dispatch(request, *args, **kwargs)¶
- http_method_names = ['post']¶
- post(request: HttpRequest, *args, **kwargs) HttpResponse¶
- pull_request = <democrasite.webiscite.webhooks.PullRequestHandler object>¶
- class democrasite.webiscite.webhooks.PullRequestHandler¶
Bases:
objectHandle pull requests from GitHub webhooks
- closed(pr: dict[str, Any]) tuple[PullRequest | None, Bill | None]¶
Disables the open bill associated with the pull request
- Parameters:
pr – The parsed JSON object representing the pull request
- opened(pr: dict[str, Any]) tuple[PullRequest, Bill | None]¶
Create a
PullRequestand, if the creator has an account,Billinstance from a pull request- Parameters:
pr – The parsed JSON object representing the pull request
- Returns:
A tuple containing the pull request and bill, if applicable
- ready_for_review(pr: dict[str, Any]) tuple[PullRequest | None, Bill | None]¶
Publish the draft bill associated with the pull request
- Parameters:
pr – The parsed JSON object representing the pull request
- synchronize(pr: dict[str, Any]) tuple[PullRequest, Bill | None]¶
Handle new commits pushed to an open pull request.
Updates the pull request with the new SHA and closes any active bill as amended, since votes on the old version no longer apply.
- Parameters:
pr – The parsed JSON object representing the pull request
- Returns:
A tuple containing the updated pull request and the closed bill, if any
- democrasite.webiscite.webhooks.github_webhook_view(self, request, *args, **kwargs)¶
View for GitHub webhook alerts
Verifies that the request is valid and, if so, creates a Celery task to process it