Commit c36ea1d8 authored by hynek's avatar hynek 🤤
Browse files

refactor(prep_dataset_tag_add): remove redundant ifs and elses

now easier to read
parent e66148a0
......@@ -339,35 +339,26 @@ def prep_dataset_tag_add(request, ds_uuid, object_type):
check_perms_403("edit_dsmo", request.user, ds.dataset_management_object)
if request.method == "POST":
tag = request.POST.get("%s-tag" % (object_type,), "").title()
if object_type == "language":
if len(tag) > 0:
if len(tag) > 0:
if object_type == "language":
ds.languages_of_data.add(tag)
tags = ds.get_language_tags()
elif object_type == "keyword":
if len(tag) > 0:
elif object_type == "keyword":
ds.keyword_tags.add(tag)
tags = ds.get_keyword_tags()
elif object_type == "methods_of_data_collection":
if len(tag) > 0:
elif object_type == "methods_of_data_collection":
ds.methods_of_data_collection.add(tag)
tags = ds.get_methods_of_data_collection_tags()
elif object_type == "methods_of_data_analysis":
if len(tag) > 0:
elif object_type == "methods_of_data_analysis":
ds.methods_of_data_analysis.add(tag)
tags = ds.get_methods_of_data_analysis_tags()
else:
tags = None
if object_type == "language":
tags = ds.get_language_tags()
elif object_type == "keyword":
tags = ds.get_keyword_tags()
elif object_type == "methods_of_data_collection":
tags = ds.get_methods_of_data_collection_tags()
elif object_type == "methods_of_data_analysis":
tags = ds.get_methods_of_data_analysis_tags()
else:
if object_type == "language":
tags = ds.get_language_tags()
elif object_type == "keyword":
tags = ds.get_keyword_tags()
elif object_type == "methods_of_data_collection":
tags = ds.get_methods_of_data_collection_tags()
elif object_type == "methods_of_data_analysis":
tags = ds.get_methods_of_data_analysis_tags()
else:
tags = None
tags = None
return render(
request,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment