Add signal for new OAuth applications

This commit is contained in:
Raphael Michel
2018-06-05 15:47:13 +02:00
parent b40100f78b
commit b4d97d9432
3 changed files with 12 additions and 1 deletions
+1 -1
View File
@@ -48,7 +48,7 @@ Backend
-------
.. automodule:: pretix.control.signals
:members: nav_event, html_head, quota_detail_html, nav_topbar, nav_global, nav_organizer, nav_event_settings, order_info, event_settings_widget
:members: nav_event, html_head, quota_detail_html, nav_topbar, nav_global, nav_organizer, nav_event_settings, order_info, event_settings_widget, oauth_application_registered
.. automodule:: pretix.base.signals
+7
View File
@@ -232,3 +232,10 @@ styles. It is advisable to set a prefix for your form to avoid clashes with othe
As with all plugin signals, the ``sender`` keyword argument will contain the event.
"""
oauth_application_registered = Signal(
providing_args=["user", "application"]
)
"""
This signal will be called whenever a user registers a new OAuth application.
"""
+4
View File
@@ -18,6 +18,7 @@ from oauth2_provider.views import (
from pretix.api.models import (
OAuthAccessToken, OAuthApplication, OAuthRefreshToken,
)
from pretix.control.signals import oauth_application_registered
logger = logging.getLogger(__name__)
@@ -43,6 +44,9 @@ class OAuthApplicationRegistrationView(ApplicationRegistration):
def form_valid(self, form):
form.instance.client_type = 'confidential'
form.instance.authorization_grant_type = 'authorization-code'
oauth_application_registered.send(
sender=self.request, user=self.request.user, application=form.instance
)
return super().form_valid(form)