Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Discuss Data Project
Discuss Data
Commits
c36ea1d8
Commit
c36ea1d8
authored
Jun 03, 2020
by
hynek
🤤
Browse files
refactor(prep_dataset_tag_add): remove redundant ifs and elses
now easier to read
parent
e66148a0
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
discuss_data/dddatasets/views_prep.py
View file @
c36ea1d8
...
...
@@ -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
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment