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
8c875a66
Commit
8c875a66
authored
Apr 13, 2024
by
Ciella Francisco
😵
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added event_description field and removed image size restriction and rename_image for event_header
parent
544894fe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
14 deletions
+2
-14
models.py
redbrickboard/event_management/models.py
+2
-14
No files found.
redbrickboard/event_management/models.py
View file @
8c875a66
...
...
@@ -8,24 +8,12 @@ from uuid import uuid4
# from datetime import timedelta
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_description
=
models
.
TextField
(
default
=
''
,
max_length
=
255
)
event_datetime_start
=
models
.
DateTimeField
(
default
=
timezone
.
now
,
null
=
False
)
event_datetime_end
=
models
.
DateTimeField
(
default
=
None
,
null
=
True
)
event_organizer
=
models
.
ForeignKey
(
accounts
.
CustomUser
,
on_delete
=
models
.
CASCADE
,
related_name
=
'events_organized'
)
event_header
=
ResizedImageField
(
size
=
[
815
,
315
],
crop
=
[
'middle'
,
'center'
],
quality
=
75
,
force_format
=
'WebP'
,
upload_to
=
rename_image
(
'headers/'
)
)
event_header
=
ResizedImageField
(
quality
=
75
,
force_format
=
'WebP'
,
upload_to
=
'headers/'
)
last_time_bumped
=
models
.
DateTimeField
()
def
__str__
(
self
):
...
...
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