Skip to content

Commit

Permalink
Iff CC-0 or CC-BY, add licensed element.
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-ide committed Nov 27, 2024
1 parent aab6297 commit a4ab67d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions webapp/home/utils/create_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,25 @@ def create_abstract(filename:str=None, abstract:str=None):
flash(texttype_node_processing.invalid_xml_error_message(msg), 'error')


def add_licensed_elements(dataset_node, rights):
licensed_node = dataset_node.find_child(names.LICENSED)
if licensed_node:
dataset_node.remove_child(licensed_node)
if rights == INTELLECTUAL_RIGHTS_CC0 or rights == INTELLECTUAL_RIGHTS_CC_BY:
licensed_node = new_child_node(names.LICENSED, parent=dataset_node)
license_name_node = new_child_node(names.LICENSENAME, parent=licensed_node)
url_node = new_child_node(names.URL, parent=licensed_node)
identifier_node = new_child_node(names.IDENTIFIER, parent=licensed_node)
if rights == INTELLECTUAL_RIGHTS_CC0:
license_name_node.content = 'Creative Commons Zero v1.0 Universal'
url_node.content = 'https://spdx.org/licenses/CC0-1.0'
identifier_node.content = 'CC0-1.0'
elif rights == INTELLECTUAL_RIGHTS_CC_BY:
license_name_node.content = 'Creative Commons Attribution 4.0 International'
url_node.content = 'https://spdx.org/licenses/CC-BY-4.0'
identifier_node.content = 'CC-BY-4.0'


def create_intellectual_rights(filename:str=None, intellectual_rights:str=None):
"""
Create an intellectualRights node in the EML document, filling it in with the provided value.
Expand Down Expand Up @@ -645,6 +664,9 @@ def create_intellectual_rights(filename:str=None, intellectual_rights:str=None):
return
else:
flash(texttype_node_processing.invalid_xml_error_message(msg), 'error')

add_licensed_elements(dataset_node, intellectual_rights)

try:
load_and_save.save_both_formats(filename=filename, eml_node=eml_node)
except Exception as e:
Expand Down
1 change: 1 addition & 0 deletions webapp/views/resources/templates/intellectual_rights.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ <h5>Choose from one of the intellectual rights options shown below:</h5>
<span style="font-family:{{ font_family }}">
{{ macros.check_xml_start() }}{{ wtf.form_field(form.intellectual_rights, rows=6) }}
{{ macros.check_xml_end('check_xml', model_has_complex_texttypes) }}
</span>

<br/>
<input class="btn btn-primary" name="Next" type="submit" value="Save and Continue"/>
Expand Down

0 comments on commit a4ab67d

Please sign in to comment.