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

Refactoring links forms #646

Merged
merged 15 commits into from
Sep 27, 2020
Merged

Refactoring links forms #646

merged 15 commits into from
Sep 27, 2020

Conversation

dismantl
Copy link
Member

@dismantl dismantl commented Mar 18, 2019

Status

Ready for review

Description of Changes

Fixes #574, #611.

Changes proposed in this pull request:

  • add New Link/Video button to officer profiles
  • add edit and delete buttons to links on officer profiles
  • add LinksApi for basic CRUD operations on links, including html templates
  • remove links subform from edit officer page
  • change user_id to creator_id in links table
  • add links to officer profiles in test data

Notes for Deployment

Screenshots (if appropriate)

image

image

Tests and linting

  • I have rebased my changes on current develop

  • pytests pass in the development environment on my local machine

  • flake8 checks pass

@dismantl dismantl removed this from the Baltimore launch milestone May 3, 2019
@dismantl
Copy link
Member Author

dismantl commented May 5, 2019

Restored the officer_links table and rebased on develop. Ready for review again.

@redshiftzero
Copy link
Member

status of this review: rebased on latest develop but it looks like when links are created via an officer's profile the link is indeed created but the officer_id, link_id isn't being created. Thus when you create the link you see a flashed message indicating the link now exists but one does not see the link appear on the officer profile.

dismantl added 5 commits July 6, 2020 14:50
- add New Link/Video button to officer profiles
- add edit and delete buttons to links on officer profiles
- add LinksApi for basic CRUD operations on links, including html templates
- remove links subform from edit officer page
- change user_id to creator_id in links table
- add optional officer_id to links table
- remove officer_links table
- add links to officer profiles in test data
dismantl added 2 commits July 6, 2020 18:57
@dismantl
Copy link
Member Author

dismantl commented Jul 7, 2020

Ready for review. This PR has been rebased on develop and the issue you mention @redshiftzero should be fixed. I've also added relevant unit tests.

@dismantl dismantl requested a review from brianmwaters August 12, 2020 17:05


# This API only applies to links attached to officer profiles, not links
# attached to incidents.
Copy link
Contributor

@fritzdavenport fritzdavenport Aug 15, 2020

Choose a reason for hiding this comment

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

maybe move the code comment as a doc comment inside the class? e.g.

class OfficerLinkApi:
   '''This API only....
   attached to incidents
   '''

if hasattr(form, 'creator_id') and not form.creator_id.data:
form.creator_id.data = current_user.get_id()

if form.validate_on_submit():
Copy link
Contributor

@fritzdavenport fritzdavenport Aug 15, 2020

Choose a reason for hiding this comment

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

Can you add an else to catch if there are errors and log them (or anything other than die silently?), in the spirit of #786 ?

Copy link
Member Author

Choose a reason for hiding this comment

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

The ModelView class it inherits from is written in the same way, so I wouldn't want to break that pattern here without doing it elsewhere, to keep things consistent. And I think it would be best to come to consensus on a solution for #786 and apply it in a separate PR.

fritzdavenport
fritzdavenport previously approved these changes Aug 16, 2020
Copy link
Contributor

@fritzdavenport fritzdavenport left a comment

Choose a reason for hiding this comment

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

LGTM. Code looks good, and poking around right now in the interface. Looks good to both add, remove, and with none/one/many. Add Link+Video is a little weird when they are two different categories, but I think I don't hate the fact that the add button is conjoined. I gave to my partner to poke around too and got a 👍 from them :)

Improvement request: Can we do more in-line form editing rather than as a separate page? That's maybe more of a general thing if nothing else really has that.

@dismantl
Copy link
Member Author

LGTM. Code looks good, and poking around right now in the interface. Looks good to both add, remove, and with none/one/many. Add Link+Video is a little weird when they are two different categories, but I think I don't hate the fact that the add button is conjoined. I gave to my partner to poke around too and got a 👍 from them :)

Improvement request: Can we do more in-line form editing rather than as a separate page? That's maybe more of a general thing if nothing else really has that.

Yes I like that idea for inline forms rather than separate pages! Thanks for the review @fritzdavenport!

Copy link
Collaborator

@abandoned-prototype abandoned-prototype left a comment

Choose a reason for hiding this comment

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

Thanks @dismantl this looks great. Sorry, I seemed to have missed this PR earlier.
One minor thing: Since you changed the field that the advanced-csv-import expects for links, could you also update the field in the documentation: https://github.com/lucyparsons/OpenOversight/blob/develop/docs/advanced_csv_import.rst#links-csv?

@dismantl dismantl force-pushed the links-refactor branch 4 times, most recently from 879a850 to bcb6b4f Compare September 27, 2020 02:59
Copy link
Collaborator

@abandoned-prototype abandoned-prototype left a comment

Choose a reason for hiding this comment

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

Re-approving. And thanks for adding the documentation-changes @dismantl!

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.

Add Link button on officer profile page
4 participants