-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
938db90
commit 62dbc63
Showing
2 changed files
with
20 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,23 @@ | ||
# Get Django `models.CharField` `choices` | ||
def get_choices(choice_dict): | ||
"""Get a sequence for a Django model field choices from a dictionary. | ||
:param Dict[str, Dict[str, str]] dictionary: choice as key for dictionary of classnames and descriptions | ||
:return: a sequence for django.db.models.CharField.choices | ||
:rtype: List[Tuple[str, str], ...] | ||
""" | ||
choices = [] | ||
|
||
for key, data in choice_dict.items(): | ||
choice = (key, data['description']) | ||
choices.append(choice) | ||
|
||
return choices | ||
|
||
|
||
|
||
# Concatenate a list of CSS classes | ||
# SEE: https://github.com/django-cms/djangocms-bootstrap4/blob/master/djangocms_bootstrap4/helpers.py | ||
def concat_classnames(classes): | ||
""" | ||
Concatenates a list of classes (without failing on None) | ||
""" | ||
"""Concatenate a list of classname strings (without failing on None)""" | ||
# SEE: https://stackoverflow.com/a/20271297/11817077 | ||
return ' '.join(_class for _class in classes if _class) |