Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
site-kwei
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mediatek
site-kwei
Commits
f07a8634
Commit
f07a8634
authored
3 years ago
by
Dorian Lesbre
Browse files
Options
Downloads
Patches
Plain Diff
Reworked file upload
parent
8ac2ed95
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.md
+1
-0
1 addition, 0 deletions
CHANGELOG.md
site_settings/models.py
+21
-0
21 additions, 0 deletions
site_settings/models.py
with
22 additions
and
0 deletions
CHANGELOG.md
+
1
−
0
View file @
f07a8634
...
...
@@ -5,6 +5,7 @@
-
Custom title to error pages
-
Update FAQ
-
More captions for planning
-
Reworked file upload to allow for file replacement (and not just upload to a new unique name)
-
Fix bugs
## Version 1.2.3 - 2021-04-25
...
...
This diff is collapsed.
Click to expand it.
site_settings/models.py
+
21
−
0
View file @
f07a8634
from
datetime
import
timedelta
from
pathlib
import
Path
from
django.db
import
models
from
django.core.cache
import
cache
from
django.core.files.storage
import
FileSystemStorage
from
django.utils.timezone
import
now
class
OverwriteStorage
(
FileSystemStorage
):
"""
used to enforcing a fixed filename to upload file
This allow for a constant link to a changeable file
"""
filename
=
"
PlanningInterludes
"
def
get_available_name
(
self
,
name
,
**
kwargs
):
"""
Returns a filename that
'
s free on the target storage system, and
available for new content to be written to.
"""
# If the filename already exists, remove it as if it was a true file system
extension
=
Path
(
name
).
suffix
new_name
=
self
.
filename
+
extension
if
self
.
exists
(
new_name
):
self
.
delete
(
new_name
)
return
super
(
FileSystemStorage
,
self
).
get_available_name
(
new_name
,
**
kwargs
)
class
SingletonModel
(
models
.
Model
):
"""
Table de la BDD qui ne possède qu
'
un seul élément
"""
class
Meta
:
...
...
@@ -54,6 +74,7 @@ class SiteSettings(SingletonModel):
display_planning
=
models
.
BooleanField
(
"
Afficher le planning
"
,
default
=
False
)
planning_file
=
models
.
FileField
(
verbose_name
=
"
Version PDF du planning
"
,
null
=
True
,
blank
=
True
,
storage
=
OverwriteStorage
(),
)
activities_allocated
=
models
.
BooleanField
(
...
...
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