Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
django-iconify
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Libraries
django-iconify
Commits
5c18e15c
Verified
Commit
5c18e15c
authored
3 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Implement icon_choices
parent
dfc3b4e3
No related branches found
No related tags found
1 merge request
!6
Resolve "Export django model choices for icons"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dj_iconify/util.py
+14
-1
14 additions, 1 deletion
dj_iconify/util.py
with
14 additions
and
1 deletion
dj_iconify/util.py
+
14
−
1
View file @
5c18e15c
"""
Utility code used by other parts of django-iconify.
"""
import
os
import
re
from
.conf
import
COLLECTIONS_ALLOWED
,
COLLECTIONS_DISALLOWED
from
.conf
import
COLLECTIONS_ALLOWED
,
COLLECTIONS_DISALLOWED
,
JSON_ROOT
def
split_css_unit
(
string
:
str
):
...
...
@@ -33,3 +34,15 @@ def collection_allowed(collection: str) -> bool:
return
False
return
True
def
icon_choices
(
collection
:
str
)
->
list
[
tuple
[
str
,
str
]]:
"""
Get Django model/form choices for icons in one collection.
"""
from
.types
import
IconifyJSON
# Load icon set through Iconify types
collection_file
=
os
.
path
.
join
(
JSON_ROOT
,
"
json
"
,
f
"
{
collection
}
.json
"
)
icon_set
=
IconifyJSON
.
from_file
(
collection_file
)
return
[(
name
,
name
)
for
name
in
icon_set
.
icons
.
keys
()]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment