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

Allow marking a casebook to be "not publicly listed" in the admin #2000

Closed lizadaly closed 1 year ago

lizadaly commented 1 year ago

This adds a field to the Casebook model to set a casebook as "not publicly listed". This is distinct from whether it is published—a casebook can be published but not listed (an unpublished casebook is already effectively unlisted).

Setting the listed_publicly field to False in the Django admin will make a published casebook drop out of the search index, and also set as disallowed in robots.txt, removing it from Google's search.

Also fixes #1990 because that was blocking access to the Casebook admin page.

Effect on robots.txt

User-Agent: *
Disallow: /*/export

After, when casebooks have the listed_publicly field toggled, the change to robots.txt will happen immediately because the exclusion filter is always run when the page is accessed (since it's indexed, this should always be fast):

User-Agent: *
Disallow: /*/export

Disallow: /casebooks/399-cybersecurity-101-three-part-introductory-section/*

Disallow: /casebooks/302-cybersecurity-curriculum/*
codecov-commenter commented 1 year ago

Codecov Report

Merging #2000 (8df9438) into develop (652c1fa) will increase coverage by 0.04%. The diff coverage is 92.30%.

@@             Coverage Diff             @@
##           develop    #2000      +/-   ##
===========================================
+ Coverage    76.79%   76.83%   +0.04%     
===========================================
  Files           62       62              
  Lines         6904     6916      +12     
===========================================
+ Hits          5302     5314      +12     
  Misses        1602     1602              
Impacted Files Coverage Δ
web/main/admin.py 69.39% <ø> (ø)
web/main/urls.py 100.00% <ø> (ø)
web/main/models.py 73.94% <50.00%> (+0.01%) :arrow_up:
web/main/test/test_search.py 100.00% <100.00%> (ø)

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