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

Bug/sc 28696/allow unsetting the license field on versions #2002

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

stevekaplan123
Copy link
Contributor

Description

Allows user to unset the license field on versions using UI.

Code Changes

  1. Front-end changes -- The code already had built-in half the code necessary for this feature:
    The existing line {licenses.map(v => <option key={v} value={v}>{v?v:"(None Listed)"}</option>)} means that a license value of "" will be shown as "(None Listed)", so I just had to add the line:
    let licenses = [...Object.keys(Sefaria.getLicenseMap()), ""]; to make sure the licenses array contained an empty string. (By the way, to make sure we don't end with two empty strings, I removed the property 'license' when its value was the empty string for 8 versions on prod).
  2. Back-end changes -- I modified the flag_text_api in two ways. First of all, there was a lot of duplication of code so I re-factored it by creating a function update_version that gets called from two places in the API. Second, I added a line so that if license is set to the empty string, the property will be removed from the Version:
if flag == 'license' and flags[flag] == "":
         delattr(vobj, flag)

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.

1 participant