Add a user-editable OAuth2 Application form
Review Request #9013 — Created June 13, 2017 and submitted
The
UserApplicationForm
is identical to theApplicationForm
, except
that it stops the user from directly editing special fields, such as:
local_site
, since we do not expose Local Site behaviour by default;user
, so they cannot re-assign the application to another users;extra_data
, since this is only meant for internal use; andskip_authorization
, since this is only intended for trusted apps.
This form is accessible via the user's profile under the "OAuth2
Applications" page.
- Ran unit tests.
- Created, edited, deleted applicaitons.
Description | From | Last Updated |
---|---|---|
Can we have some kind of empty state here that says there are no configured applications? |
david | |
W391 blank line at end of file |
reviewbot | |
F811 redefinition of unused 'test_set_local_site' from line 155 |
reviewbot | |
F811 redefinition of unused 'test_set_local_site' from line 201 |
reviewbot | |
Docstring? |
david | |
Docstring? |
david | |
Needs to include the local_site_name parameter. |
david | |
Needs Returns: |
david | |
Docstring? |
david | |
Docstring? |
david | |
Module docstring? |
david | |
Docstring? |
david | |
We should use </div> instead of the XHTML syntax. |
david | |
W292 no newline at end of file |
reviewbot | |
W292 no newline at end of file |
reviewbot | |
Col: 52 Missing semicolon. |
reviewbot | |
This URL isn't on a Local Site, and we're not providing Local Site information, so reverse is fine. |
chipx86 | |
We should provide the request as an argument, so feature checkers can factor it in. |
chipx86 | |
It's not immediately clear what this is for. Can you elaborate? |
chipx86 | |
This can be condensed: url(r'^preferences/oauth2-application/((?P<app_id>[0-9]+)/)?$', accounts_views.edit_oauth_app, name='edit-oauth-app'), |
chipx86 | |
Alphabetical order. |
chipx86 | |
Two blank lines. |
chipx86 | |
Swap these. We want to test for login first. |
chipx86 | |
You should use get_object_or_404 instead. |
chipx86 | |
This and the other Local Site-related code below will never work. This URL isn't under a /s/<localsite>/ URL, so there's … |
chipx86 | |
This doesn't seem to match what's in the form. Let's import the form and make sure we're always using the … |
chipx86 | |
No blank line here. |
chipx86 | |
No trailing comma after form. Or if this is meant to be a tuple, it should be wrapped in parens. |
chipx86 | |
This is probably best moved to djblets.forms somewhere. We have a get_fieldsets template tag as well, but it's a bit … |
chipx86 | |
We don't always necessarily want this. This should be up to callers. |
chipx86 | |
I don't think we want to assume that all collapsed content should be excluded. Seems like that should be a … |
chipx86 | |
Swap these. |
chipx86 | |
"or" |
chipx86 | |
How about: instance = super(UserApplicationForm, self).save(commit=False) if not self.instance.pk: instance.user = self.user if commit: instance.save() |
chipx86 | |
No parens. |
chipx86 | |
This is being overrided below. |
chipx86 | |
Why do we need to override this? Input classes should generally be left alone. |
chipx86 | |
Similarly here (and for other common styles), we ideally shouldn't have versions specific to the OAuth2 page. We should have … |
chipx86 | |
render() chains, so you can include this in the chain. We usually do it as one entry as render().$el. |
chipx86 | |
This is really going to be tough to maintain. Can we split across lines? We can use {% spaceless %}. |
chipx86 | |
So ideally we'd use the djblets_forms/admin/form_fieldsets.html template here. There are two things that prevent this, though: It uses the get_fieldsets … |
chipx86 | |
Save and Cancel need to be localized. |
chipx86 | |
This doesn't match the anchor used in the form. We should provide that to the template. |
chipx86 | |
No blank line needed. |
chipx86 | |
E501 line too long (81 > 79 characters) |
reviewbot | |
F841 local variable 'local_site' is assigned to but never used |
reviewbot | |
Mind making this alphabetical? |
david | |
e before o |
david | |
Doc comment? |
david | |
Doc comment? |
david | |
Trailing whitespace. |
david | |
Trailing whitespace. |
david | |
Doc comment? |
david | |
Col: 52 Missing semicolon. |
reviewbot | |
Doc comment? |
david | |
Doc comment? |
david | |
Doc comment? |
david | |
Trailing comma. |
david | |
No blank lines here. |
david | |
Doc comment? |
david | |
I don't see this file in your change. |
david | |
Col: 6 Expected '}' to match '{' from line 211 and instead saw ';'. |
reviewbot | |
Col: 2 Missing semicolon. |
reviewbot | |
Col: 2 Expected an identifier and instead saw ')'. |
reviewbot | |
Col: 2 Expected an assignment or function call and instead saw an expression. |
reviewbot | |
Col: 1 Expected ')' and instead saw '}'. |
reviewbot | |
Col: 6 Expected '}' to match '{' from line 211 and instead saw ';'. |
reviewbot | |
Col: 1 Expected ')' and instead saw '}'. |
reviewbot | |
Col: 2 Missing semicolon. |
reviewbot | |
Col: 2 Expected an identifier and instead saw ')'. |
reviewbot | |
Col: 2 Expected an assignment or function call and instead saw an expression. |
reviewbot |
- Change Summary:
-
- Address David's issues.
- Disable
skip_authorization
field. - Improve the UI.
- Description:
-
The
UserApplicationForm
is identical to theApplicationForm
, exceptthat it stops the user from directly editing special fields, such as: local_site
, since we do not expose Local Site behaviour by default;
~ user
, so they cannot re-assign the application to another user; and
~ extra_data
, since this is only meant for internal use.
~ user
, so they cannot re-assign the application to another users;
~ extra_data
, since this is only meant for internal use; and
+ skip_authorization
, since this is only intended for trusted apps.
This form is accessible via the user's profile under the "OAuth2
Applications" page. - Diff:
-
Revision 3 (+735 -7)
- Removed Files:
- Added Files:
- Change Summary:
-
reverse() over local_site_reverse() when no local site
Checks run (2 succeeded)
- Change Summary:
-
OOPS that change didnt belong here :)
Checks run (2 succeeded)
-
-
-
-
-
This can be condensed:
url(r'^preferences/oauth2-application/((?P<app_id>[0-9]+)/)?$', accounts_views.edit_oauth_app, name='edit-oauth-app'),
-
-
-
-
-
This and the other Local Site-related code below will never work. This URL isn't under a
/s/<localsite>/
URL, so there's never going to be a Local Site listed.I think what's going to have to happen is you'll have to fetch without the Local Site, then check if there is a Local Site and that the user has access to it (covering the case where a user has created one but since left the company -- we don't want them sabotaging something).
Then we'll have to include the local_site in the form data, but validate that the user has access to it.
-
This doesn't seem to match what's in the form.
Let's import the form and make sure we're always using the value it defines.
-
-
-
This is probably best moved to
djblets.forms
somewhere.We have a
get_fieldsets
template tag as well, but it's a bit different in what it returns. -
-
I don't think we want to assume that all collapsed content should be excluded. Seems like that should be a flag, like
ignore_collapsed
.Also,
tuple()
can just be()
. -
-
-
How about:
instance = super(UserApplicationForm, self).save(commit=False) if not self.instance.pk: instance.user = self.user if commit: instance.save()
-
-
-
-
Similarly here (and for other common styles), we ideally shouldn't have versions specific to the OAuth2 page. We should have consistent definitions that apply to all relevant pages.
-
render()
chains, so you can include this in the chain. We usually do it as one entry asrender().$el
. -
This is really going to be tough to maintain. Can we split across lines? We can use
{% spaceless %}
. -
So ideally we'd use the
djblets_forms/admin/form_fieldsets.html
template here. There are two things that prevent this, though:- It uses the
get_fieldsets
filter, which doesn't exclude or remove collapsed entries. - It doesn't use
fieldset.name
, sinceget_fieldsets
returns a tuple of(name, fieldset)
.
I think the best route to go (since I really don't want to duplicate fieldset rendering logic) is to split the fieldset rendering of
form_fieldsets.html
into aform_fieldset.html
. Then you could easily use it with:{% for fieldset in fieldsets %} {% include "djblets_forms/admin/form_fieldset.html" with fieldset_title=fieldset.name %} {% endfor %}
(Also, can we change
fieldset.name
tofieldset.title
? It's more correct.) - It uses the
-
-
-
- Change Summary:
-
Addressed Christian's issues
- Depends On:
-
- Diff:
Revision 8 (+687 -11)
- Change Summary:
-
Address David's remaining issues