Skip to content
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

Update form for adding distribution #639

Merged
merged 2 commits into from
Oct 26, 2018
Merged

Conversation

Zlopez
Copy link
Contributor

@Zlopez Zlopez commented Oct 17, 2018

This PR implements #594.

What was changed:

  • To add distribution through distros page user no longer needs to be admin
  • Distribution in mapping page is now selected from dropdown, not automatically created if it doesn't exists
  • Add confirmation dialog to /distro/add page if there are distributions with similar names (this is also showed on the page itself before submit)
  • Polished /distro/add and /project/<id>/map pages to look a little better
  • Add information where user can add new distribution directly to /project/<id>/map
  • Fix failing test

This changes should prevent making distributions containing typos and duplicates of already existing distributions.

@codecov-io
Copy link

codecov-io commented Oct 17, 2018

Codecov Report

Merging #639 into master will decrease coverage by <.01%.
The diff coverage is 96.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #639      +/-   ##
==========================================
- Coverage   90.55%   90.54%   -0.01%     
==========================================
  Files          56       56              
  Lines        2690     2698       +8     
  Branches      352      355       +3     
==========================================
+ Hits         2436     2443       +7     
  Misses        197      197              
- Partials       57       58       +1
Impacted Files Coverage Δ
anitya/admin.py 82.87% <ø> (-1.39%) ⬇️
anitya/ui.py 79.37% <100%> (+1.74%) ⬆️
anitya/forms.py 79.06% <66.66%> (-1.42%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9c58c68...95f7337. Read the comment docs.

@@ -0,0 +1 @@
Update form for adding new distribution

Choose a reason for hiding this comment

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

Suggested change
Update form for adding new distribution
Update form for adding new distributions

anitya/forms.py Outdated
distro = SelectField(
'Distribution',
[validators.DataRequired()],
choices=[(item, item) for item in []])

Choose a reason for hiding this comment

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

What express it this way? Isn't this basically just saying choices=[]?

"""Assert admins can add distributions."""
with login_user(self.flask_app, self.user):
output = self.client.get('/distro/add')
print(output.data)

Choose a reason for hiding this comment

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

Suggested change
print(output.data)


output = self.client.post('/distro/add', data=data, follow_redirects=True)

# self.assertEqual(201, output.status_code)

Choose a reason for hiding this comment

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

Suggested change
# self.assertEqual(201, output.status_code)

b'name="csrf_token" type="hidden" value="')[1].split(b'">')[0]
data = {'name': 'Fedora', 'csrf_token': csrf_token}

output = self.client.post('/distro/add', data=data, follow_redirects=True)

Choose a reason for hiding this comment

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

Does self.client.post() assert that the return code is 200 by default?

dup_output = self.client.post('/distro/add', data=data, follow_redirects=True)

self.assertTrue(b'Distribution added' in create_output.data)
self.assertTrue(b'Could not add this distro' in dup_output.data)

Choose a reason for hiding this comment

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

It seems like it'd be good to assert that an HTTP error code was used here. Perhaps 409 (conflict)?

Suggested change
self.assertTrue(b'Could not add this distro' in dup_output.data)
self.assertTrue(b'Could not add this distro' in dup_output.data)
self.assertEqual(409, output.status_code)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The user is redirected to /distros page, so the user gets 301 redirect.

Copy link

@bowlofeggs bowlofeggs left a comment

Choose a reason for hiding this comment

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

It would also be helpful to give more information in the commit message, and to make the title more descriptive. What are we updating it to do that it doesn't do now?

Copy link

@bowlofeggs bowlofeggs left a comment

Choose a reason for hiding this comment

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

LGTM, though I recommend squashing the commits before merging.

@Zlopez
Copy link
Contributor Author

Zlopez commented Oct 24, 2018

squash

bowlofeggs
bowlofeggs previously approved these changes Oct 24, 2018
Copy link

@bowlofeggs bowlofeggs left a comment

Choose a reason for hiding this comment

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

This one also fails in Travis - does the master branch fail linting?

* To add distribution through distros page user no longer needs to be admin
* Distribution in mapping page is now selected from dropdown, not
automatically created if it doesn't exists
* Add confirmation dialog to `/distro/add` page if there are
distributions with similar names (this is also showed on the page itself
before submit)
* Polished `/distro/add` and `/project/<id>/map` pages to look a little
better
* Add information where user can add new distribution directly to
`/project/<id>/map`
* Fix failing test
@Zlopez
Copy link
Contributor Author

Zlopez commented Oct 25, 2018

The PR fixing the lint issue was merged, so I'm doing a rebase to fix also this PR.

@mergify mergify bot merged commit 0994242 into fedora-infra:master Oct 26, 2018
@Zlopez Zlopez deleted the distro_form branch October 29, 2018 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants