Allows user to unset the license field on versions using UI.
Code Changes
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).
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)
Description
Allows user to unset the license field on versions using UI.
Code Changes
{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).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: