Skip to content

Add separate version create view and create view URL #7595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 6, 2021

Conversation

agjohnson
Copy link
Contributor

This is not currently used outside the new theme, but enables the
solution for #6238 -- latest master of the new theme already expects
this code.

For now, the create URL does throw and exception, because we are
rendering template code inside the version form. I'm not going to
address this as the create view is not linked and unused, and we
probably shouldn't be rendering templates inside form instantiation
anyways.

The edit version URL does change with this, to append the /edit/
postfix. This was done to match similar URL patterns, and to give a path
for the create view URL that does not match the edit URL pattern.

@agjohnson agjohnson requested a review from a team October 23, 2020 01:34
@agjohnson agjohnson added the Improvement Minor improvement to code label Oct 23, 2020
Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems simple enough 👍

@agjohnson
Copy link
Contributor Author

I seem to recall @humitos having feedback on the URL structure, I'll wait for his feedback here.

@agjohnson agjohnson requested a review from humitos November 19, 2020 16:35
@agjohnson
Copy link
Contributor Author

agjohnson commented Nov 20, 2020

Found the conversation, it was here: #7594 (comment)

My opinion is still that ../edit/ makes the most sense

This is not currently used outside the new theme, but enables the
solution for #6238 -- latest `master` of the new theme already expects
this code.

For now, the create URL does throw and exception, because we are
rendering template code inside the version form. I'm not going to
address this as the create view is not linked and unused, and we
probably shouldn't be rendering templates inside form instantiation
anyways.

The edit version URL does change with this, to append the `/edit/`
postfix. This was done to match similar URL patterns, and to give a path
for the create view URL that does not match the edit URL pattern.
@agjohnson agjohnson force-pushed the agj/add-version-create-url branch from 15e10c6 to 0fe01f6 Compare November 20, 2020 20:47
@agjohnson
Copy link
Contributor Author

The additional URL for the create view was causing errors with tests, so i did the more correct thing and made the URL conditional. Test look good now 👍

@humitos
Copy link
Member

humitos commented Nov 23, 2020

I don't want to block this work, but I made a comment with maybe a better explanation about why I think the /edit/ on the URL shouldn't be used at #7594 (comment)

It's not wrong using it, but I just find it easier to follow the conventions that Django and DRF are already using for these URLs.

@stale
Copy link

stale bot commented Jan 17, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: stale Issue will be considered inactive soon label Jan 17, 2021
@agjohnson agjohnson added Accepted Accepted issue on our roadmap and removed Status: stale Issue will be considered inactive soon labels Jan 19, 2021
@agjohnson
Copy link
Contributor Author

This is blocking continuing to work on templates so I'd like to get this merged. To resurrect this discussion, some added context: the reason for the /edit/ postfix is because we need a corresponding URL for the create version view. Following patterns for other create/form views, there is a project version create URL:

/dashboard/pip/version/create/

However, if we don't change the edit form URL to ../edit/ postfix, the above URL for ProjectVersionCreate collides with the URL for ProjectVersionDetail where version=create. Adding an explicit ../edit/ postfix removes this overlap.

Using the ../edit/ postfix for update views is also an existing pattern we use, so nothing really new here.

If we want this to be even clearer, ProjectVersionDetail should really be ProjectVersionUpdate. This view is not a detail view at all, it is an admin only form view. I won't take this chunk on just yet, but can if it seems important to getting this merged.

@ericholscher
Copy link
Member

I don't think the URL's matter nearly as much for the dashboard as the API, so I'm fine with whatever is most obvious, and hopefully we can standardize on it.

Copy link
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I re-read the whole conversation and I think Anthony is right 😄

As an example of this, Django Admin uses:

  • /admin/auth/user/ to list all the users
  • /admin/auth/user/add/ to create a new user
  • /admin/auth/user/<pk>/change/ to edit a user

I understand that we are going to follow the same pattern but using /create/ and /edit/ instead of /add/ and /change/, so 👍

@ericholscher ericholscher merged commit ba22f16 into master Apr 6, 2021
@ericholscher ericholscher deleted the agj/add-version-create-url branch April 6, 2021 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Accepted issue on our roadmap Improvement Minor improvement to code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants