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
b476f48b
Commit
b476f48b
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
02f05d88
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 @
b476f48b
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.detail
import
DetailView
from
django.views.generic.list
import
ListView
from
django.views.generic.list
import
ListView
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
.models
import
Event
from
.forms
import
EventForm
from
.models
import
Event
def
event_view
(
request
):
events
=
Event
.
objects
.
all
()
context
=
{
'events'
:
events
}
return
render
(
request
,
'event_management/events.html'
,
context
)
class
EventDetailView
(
DetailView
):
class
EventDetailView
(
DetailView
):
model
=
Event
model
=
Event
...
@@ -16,14 +14,29 @@ class EventDetailView(DetailView):
...
@@ -16,14 +14,29 @@ class EventDetailView(DetailView):
class
EventListView
(
ListView
):
class
EventListView
(
ListView
):
model
=
Event
model
=
Event
fields
=
'__all__'
template_name
=
'event_management/event-list.html'
template_name
=
'event_management/event-list.html'
class
EventCreateView
(
CreateView
):
class
EventCreateView
(
CreateView
):
model
=
Event
model
=
Event
fields
=
'__all__'
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
):
class
EventUpdateView
(
UpdateView
):
model
=
Event
model
=
Event
fields
=
'__all__'
fields
=
'__all__'
template_name
=
'event/event-update.html'
template_name
=
'event_management/event-form.html'
\ No newline at end of file
\ 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