Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Django Favicon Plus Reloaded
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
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 Favicon Plus Reloaded
Commits
39b9aca5
Commit
39b9aca5
authored
4 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Remove broken caching mechanism
parent
1ba6b773
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2
Remove broken caching mechanism
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
favicon/models.py
+2
-9
2 additions, 9 deletions
favicon/models.py
favicon/templatetags/favtags.py
+2
-7
2 additions, 7 deletions
favicon/templatetags/favtags.py
with
4 additions
and
16 deletions
favicon/models.py
+
2
−
9
View file @
39b9aca5
from
io
import
BytesIO
import
hashlib
import
json
import
sys
from
PIL
import
Image
from
django.conf
import
settings
from
django.core.cache
import
cache
from
django.core.files.storage
import
default_storage
as
storage
from
django.core.files.uploadedfile
import
InMemoryUploadedFile
from
django.db
import
models
...
...
@@ -29,7 +26,6 @@ config = getattr(settings, 'FAVICON_CONFIG', config)
if
"
shortcut icon
"
not
in
config
or
32
not
in
config
[
"
shortcut icon
"
]:
config
.
setdefault
(
"
shortcut_icon
"
,
[]).
append
(
32
)
config_cache_key
=
"
favicons_
"
+
hashlib
.
sha1
(
json
.
dumps
(
config
,
sort_keys
=
True
).
encode
()).
hexdigest
()
image_path
=
getattr
(
settings
,
"
FAVICON_PATH
"
,
"
favicon
"
)
...
...
@@ -120,13 +116,10 @@ class Favicon(models.Model):
if
self
.
isFavicon
:
Favicon
.
on_site
.
exclude
(
pk
=
self
.
pk
).
update
(
isFavicon
=
False
)
super
(
Favicon
,
self
).
save
(
*
args
,
**
kwargs
)
cache
.
delete
(
config_cache_key
)
super
().
save
(
*
args
,
**
kwargs
)
if
self
.
faviconImage
:
html
=
self
.
as_html
(
update
=
True
)
cache
.
set
(
config_cache_key
,
html
,
timeout
=
None
)
self
.
get_favicons
(
update
=
True
)
class
FaviconImg
(
models
.
Model
):
...
...
This diff is collapsed.
Click to expand it.
favicon/templatetags/favtags.py
+
2
−
7
View file @
39b9aca5
...
...
@@ -2,7 +2,7 @@ from django import template
from
django.core.cache
import
cache
from
django.utils.safestring
import
mark_safe
from
favicon.models
import
Favicon
,
config_cache_key
from
favicon.models
import
Favicon
register
=
template
.
Library
()
...
...
@@ -18,14 +18,9 @@ def place_favicon(context):
"""
html
=
cache
.
get
(
config_cache_key
)
if
html
:
return
mark_safe
(
html
)
fav
=
Favicon
.
on_site
.
filter
(
isFavicon
=
True
).
first
()
if
not
fav
:
return
mark_safe
(
'
<!-- no favicon -->
'
)
html
=
fav
.
as_html
()
cache
.
set
(
config_cache_key
,
html
,
timeout
=
None
)
return
mark_safe
(
html
)
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