Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
red_brick_board
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ciella Francisco
red_brick_board
Commits
c85226b3
Commit
c85226b3
authored
Apr 11, 2024
by
Ciella Francisco
😵
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enabled renaming of images filename once uploaded in creating an event
parent
1ac116b5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
models.py
redbrickboard/event_management/models.py
+15
-0
No files found.
redbrickboard/event_management/models.py
View file @
c85226b3
import
os
from
django.db
import
models
from
django.db
import
models
from
django_resized
import
ResizedImageField
from
django_resized
import
ResizedImageField
from
django.utils
import
timezone
from
django.utils
import
timezone
from
django.urls
import
reverse
from
django.urls
import
reverse
from
accounts
import
models
as
accounts
from
accounts
import
models
as
accounts
from
uuid
import
uuid4
# from datetime import timedelta
# from datetime import timedelta
class
Event
(
models
.
Model
):
class
Event
(
models
.
Model
):
def
rename_image
(
path
):
def
wrapper
(
instance
,
filename
):
ext
=
filename
.
split
(
'.'
)[
-
1
]
# get filename
if
instance
.
pk
:
filename
=
'event{}header.{}'
.
format
(
instance
.
pk
,
ext
)
else
:
# set filename as random string
filename
=
'{}.{}'
.
format
(
uuid4
()
.
hex
,
ext
)
# return the whole path to the file
return
os
.
path
.
join
(
path
,
filename
)
return
wrapper
event_name
=
models
.
CharField
(
default
=
''
,
max_length
=
150
)
event_name
=
models
.
CharField
(
default
=
''
,
max_length
=
150
)
event_datetime_start
=
models
.
DateTimeField
(
default
=
timezone
.
now
,
null
=
False
)
event_datetime_start
=
models
.
DateTimeField
(
default
=
timezone
.
now
,
null
=
False
)
event_datetime_end
=
models
.
DateTimeField
(
default
=
None
,
null
=
True
)
event_datetime_end
=
models
.
DateTimeField
(
default
=
None
,
null
=
True
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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