Skip to content

Commit 2b86b4f

Browse files
dull7295DullaMuraliKrishna Dulla
authored
Remove unnecessary fields from Register an App form BB2-2660 (#1203)
* Remove unnecessary fields from Register an App form BB2-2660 * Assign the default values for hidden fields BB2-2660 * Cleaned up the code BB2-2660 * Cleaned up the code BB2-2660 * Fixed Unit test cases and cleaned BB2-2660 * Fixed Unit test cases and cleaned BB2-2660 * Removed Blank Lines BB2-2660 --------- Co-authored-by: Dulla <[email protected]> Co-authored-by: MuraliKrishna Dulla <[email protected]>
1 parent f495561 commit 2b86b4f

File tree

3 files changed

+8
-54
lines changed

3 files changed

+8
-54
lines changed

apps/dot_ext/forms.py

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ def __init__(self, user, *args, **kwargs):
5959
self.fields["name"].label = "Name*"
6060
self.fields["name"].required = True
6161
self.fields["client_type"].label = "Client Type*"
62+
self.fields["client_type"].required = False
6263
self.fields["authorization_grant_type"].label = "Authorization Grant Type*"
64+
self.fields["authorization_grant_type"].required = False
6365
self.fields["redirect_uris"].label = "Redirect URIs*"
6466
self.fields["logo_uri"].disabled = True
6567

@@ -86,29 +88,6 @@ class Meta:
8688
required_css_class = "required"
8789

8890
def clean(self):
89-
client_type = self.cleaned_data.get("client_type")
90-
authorization_grant_type = self.cleaned_data.get("authorization_grant_type")
91-
92-
msg = ""
93-
validate_error = False
94-
95-
# Validate choices
96-
if not (
97-
client_type == "confidential"
98-
and authorization_grant_type == "authorization-code"
99-
):
100-
validate_error = True
101-
msg += (
102-
"Only a confidential client and "
103-
"authorization-code grant type are allowed at this time."
104-
)
105-
106-
if validate_error:
107-
msg_output = _(msg)
108-
raise forms.ValidationError(msg_output)
109-
else:
110-
pass
111-
11291
return self.cleaned_data
11392

11493
def clean_name(self):
@@ -176,6 +155,8 @@ def clean_require_demographic_scopes(self):
176155
return require_demographic_scopes
177156

178157
def save(self, *args, **kwargs):
158+
self.instance.client_type = "confidential"
159+
self.instance.authorization_grant_type = "authorization-code"
179160
app = self.instance
180161
# Only log agreement from a Register form
181162
if app.agree and type(self) == CustomRegisterApplicationForm:

apps/dot_ext/tests/test_form_application.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -258,33 +258,6 @@ def test_update_form_edit(self):
258258
form = CustomRegisterApplicationForm(user, passing_app_fields)
259259
self.assertTrue(form.is_valid())
260260

261-
# Test client_type = 'confidential' and authorization_grant_type = 'implicit' not allowed.
262-
data = passing_app_fields
263-
data['client_type'] = 'confidential'
264-
data['authorization_grant_type'] = 'implicit'
265-
form = CustomRegisterApplicationForm(user, data)
266-
self.assertFalse(form.is_valid())
267-
self.assertIn('Only a confidential client and authorization-code grant type are allowed at this time.',
268-
str(form.errors.get('__all__')))
269-
270-
# Test client_type = 'public' and grant_type = 'authorization-code' not allowed.
271-
data = passing_app_fields
272-
data['client_type'] = 'public'
273-
data['authorization_grant_type'] = 'authorization-code'
274-
form = CustomRegisterApplicationForm(user, data)
275-
self.assertFalse(form.is_valid())
276-
self.assertIn('Only a confidential client and authorization-code grant type are allowed at this time.',
277-
str(form.errors.get('__all__')))
278-
279-
# Test client_type = 'public' and grant_type = 'implicit' not allowed.
280-
data = passing_app_fields
281-
data['client_type'] = 'public'
282-
data['authorization_grant_type'] = 'implicit'
283-
form = CustomRegisterApplicationForm(user, data)
284-
self.assertFalse(form.is_valid())
285-
self.assertIn('Only a confidential client and authorization-code grant type are allowed at this time.',
286-
str(form.errors.get('__all__')))
287-
288261
def test_create_applications_with_logo(self):
289262
"""
290263
regression test: BB2-66: Fix-logo-display-in-Published-Applications-API

templates/include/app-form-required-info.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ <h2>App Details - Required Info</h2>
66
<input type="text" name="name" maxlength="255" required="" id="id_name" value="{{ application.name }}" autocomplete="turn_autocomplete_off">
77

88
<!-- App Client Type -->
9-
<label for="id_client_type">OAuth - Client Type</label>
9+
<!-- <label for="id_client_type">OAuth - Client Type</label>
1010
<select name="client_type" required="" id="id_client_type">
1111
<option value="confidential" {% if application.client_type != "public" %} selected {% endif %}>Confidential</option>
12-
</select>
12+
</select> -->
1313

1414
<!-- App Grant Type -->
15-
<label for="id_authorization_grant_type">Authorization Grant Type*</label>
15+
<!-- <label for="id_authorization_grant_type">Authorization Grant Type*</label>
1616
<select name="authorization_grant_type" id="id_authorization_grant_type">
1717
<option value="authorization-code" {% if application.authorization_grant_type != "implicit" %} selected {% endif %}>Authorization code</option>
18-
</select>
18+
</select> -->
1919

2020
<!-- App Redirect URIs -->
2121
<label for="id_redirect_uris">Callback URLs / Redirect URIs</label>

0 commit comments

Comments
 (0)