33from django .urls import reverse_lazy
44from django .views .generic import CreateView , DeleteView , DetailView , ListView , UpdateView
55
6+ from ..forms import ApplicationForm
67from ..models import get_application_model
78
9+ APPLICATION_FIELDS = (
10+ "name" ,
11+ "client_id" ,
12+ "client_secret" ,
13+ "hash_client_secret" ,
14+ "client_type" ,
15+ "authorization_grant_type" ,
16+ "redirect_uris" ,
17+ "post_logout_redirect_uris" ,
18+ "allowed_origins" ,
19+ "algorithm" ,
20+ )
21+
822
923class ApplicationOwnerIsUserMixin (LoginRequiredMixin ):
1024 """
@@ -25,24 +39,7 @@ class ApplicationRegistration(LoginRequiredMixin, CreateView):
2539 template_name = "oauth2_provider/application_registration_form.html"
2640
2741 def get_form_class (self ):
28- """
29- Returns the form class for the application model
30- """
31- return modelform_factory (
32- get_application_model (),
33- fields = (
34- "name" ,
35- "client_id" ,
36- "client_secret" ,
37- "hash_client_secret" ,
38- "client_type" ,
39- "authorization_grant_type" ,
40- "redirect_uris" ,
41- "post_logout_redirect_uris" ,
42- "allowed_origins" ,
43- "algorithm" ,
44- ),
45- )
42+ return modelform_factory (get_application_model (), form = ApplicationForm , fields = APPLICATION_FIELDS )
4643
4744 def form_valid (self , form ):
4845 form .instance .user = self .request .user
@@ -86,21 +83,4 @@ class ApplicationUpdate(ApplicationOwnerIsUserMixin, UpdateView):
8683 template_name = "oauth2_provider/application_form.html"
8784
8885 def get_form_class (self ):
89- """
90- Returns the form class for the application model
91- """
92- return modelform_factory (
93- get_application_model (),
94- fields = (
95- "name" ,
96- "client_id" ,
97- "client_secret" ,
98- "hash_client_secret" ,
99- "client_type" ,
100- "authorization_grant_type" ,
101- "redirect_uris" ,
102- "post_logout_redirect_uris" ,
103- "allowed_origins" ,
104- "algorithm" ,
105- ),
106- )
86+ return modelform_factory (get_application_model (), form = ApplicationForm , fields = APPLICATION_FIELDS )
0 commit comments