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
9020a682
Commit
9020a682
authored
Apr 11, 2024
by
Ciella Francisco
😵
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Edited views.py to enable creation of events via forms under the EventCreateView class
parent
7f897ace
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
9 deletions
+22
-9
views.py
redbrickboard/event_management/views.py
+22
-9
No files found.
redbrickboard/event_management/views.py
View file @
9020a682
from
django.shortcuts
import
render
from
typing
import
Any
from
django.http
import
HttpResponse
from
django.shortcuts
import
render
,
redirect
from
django.views.generic.detail
import
DetailView
from
django.views.generic.list
import
ListView
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
.models
import
Event
def
event_view
(
request
):
events
=
Event
.
objects
.
all
()
context
=
{
'events'
:
events
}
return
render
(
request
,
'event_management/events.html'
,
context
)
from
.forms
import
EventForm
from
.models
import
Event
class
EventDetailView
(
DetailView
):
model
=
Event
...
...
@@ -16,14 +14,29 @@ class EventDetailView(DetailView):
class
EventListView
(
ListView
):
model
=
Event
fields
=
'__all__'
template_name
=
'event_management/event-list.html'
class
EventCreateView
(
CreateView
):
model
=
Event
fields
=
'__all__'
template_name
=
'event_management/event-create.html'
def
get_context_data
(
self
,
**
kwargs
:
Any
)
->
dict
[
str
,
Any
]:
context
=
super
()
.
get_context_data
(
**
kwargs
)
context
[
'form'
]
=
EventForm
()
return
context
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
form
=
EventForm
(
request
.
POST
)
if
form
.
is_valid
():
return
self
.
get
(
request
,
*
args
,
**
kwargs
)
else
:
return
render
(
request
,
self
.
template_name
,
{
'form'
:
form
})
template_name
=
'event_management/event-form.html'
class
EventUpdateView
(
UpdateView
):
model
=
Event
fields
=
'__all__'
template_name
=
'event/event-update.html'
\ No newline at end of file
template_name
=
'event_management/event-form.html'
\ No newline at end of file
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