harvard-lil / h2o

H2O is a web app for creating and reading open educational resources, primarily in the legal field
https://opencasebook.org
GNU Affero General Public License v3.0
36 stars 30 forks source link

Add endpoint that will fetch and add a resource to a casebook in one roundtrip #1956

Closed lizadaly closed 1 year ago

lizadaly commented 1 year ago

To optimize the add-legal-doc workflow, this adds a new API endpoint that performs the work of currently done by https://github.com/harvard-lil/h2o/blob/develop/web/main/views.py#L2591-L2630 and https://github.com/harvard-lil/h2o/blob/develop/web/main/views.py#L1915-L1939 as separate HTTP requests.

This endpoint simplifies and optimizes that flow in these ways:

It includes the same logic as the dual endpoint it replaces, including accepting an optional section to add the new resource in a particular part of the casebook, or default to adding it at the end.

This doesn't add the frontend consumer for this endpoint, but does include a number of tests which should fully cover its functionality.

codecov-commenter commented 1 year ago

Codecov Report

Merging #1956 (44bb970) into develop (f00fb96) will increase coverage by 0.21%. The diff coverage is 100.00%.

@@             Coverage Diff             @@
##           develop    #1956      +/-   ##
===========================================
+ Coverage    76.70%   76.92%   +0.21%     
===========================================
  Files           60       60              
  Lines         6775     6839      +64     
===========================================
+ Hits          5197     5261      +64     
  Misses        1578     1578              
Impacted Files Coverage Δ
web/main/urls.py 100.00% <ø> (ø)
web/conftest.py 91.36% <100.00%> (ø)
web/main/test/test_editing.py 100.00% <100.00%> (ø)
web/main/views.py 72.04% <100.00%> (+0.57%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.