Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_nicsbabes
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
0
Merge Requests
0
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
Nics De Vega
midterm_nicsbabes
Commits
4cd49e56
Commit
4cd49e56
authored
May 10, 2023
by
Gabriel Geraldo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented add activity function
parent
8dac69ae
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
6 deletions
+45
-6
forms.py
widget_nicsbabes/widget_calendar/forms.py
+11
-0
models.py
widget_nicsbabes/widget_calendar/models.py
+7
-3
event-add.html
.../widget_calendar/templates/widget_calendar/event-add.html
+15
-0
urls.py
widget_nicsbabes/widget_calendar/urls.py
+4
-2
views.py
widget_nicsbabes/widget_calendar/views.py
+8
-1
No files found.
widget_nicsbabes/widget_calendar/forms.py
0 → 100644
View file @
4cd49e56
from
django
import
forms
from
.models
import
Event
class
EventCreateForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
Event
fields
=
[
'activity'
,
'target_datetime'
,
'estimated_hours'
,
'location'
,
'course'
]
widgets
=
{
'target_datetime'
:
forms
.
DateTimeInput
(
attrs
=
{
'type'
:
'datetime-local'
})
}
widget_nicsbabes/widget_calendar/models.py
View file @
4cd49e56
...
@@ -20,7 +20,7 @@ class Location(models.Model):
...
@@ -20,7 +20,7 @@ class Location(models.Model):
venue
=
models
.
CharField
(
max_length
=
255
)
venue
=
models
.
CharField
(
max_length
=
255
)
def
__str__
(
self
):
def
__str__
(
self
):
return
'{}
({})
'
.
format
(
return
'{}
- {}
'
.
format
(
self
.
venue
,
self
.
venue
,
self
.
mode
self
.
mode
)
)
...
@@ -38,7 +38,11 @@ class Event(models.Model):
...
@@ -38,7 +38,11 @@ class Event(models.Model):
self
.
activity
,
self
.
activity
,
self
.
course
self
.
course
)
)
def
get_absolute_url
(
self
):
def
get_absolute_url
(
self
):
return
reverse
(
"widget_calendar:event_details"
,
kwargs
=
{
"pk"
:
self
.
pk
})
return
reverse
(
"widget_calendar:event_details"
,
kwargs
=
{
"pk"
:
self
.
pk
})
def
get_date
(
self
):
return
self
.
target_datetime
.
strftime
(
"
%
m/
%
d/
%
Y"
)
def
get_time
(
self
):
return
self
.
target_datetime
.
strftime
(
"
%
I:
%
M
%
p"
)
\ No newline at end of file
widget_nicsbabes/widget_calendar/templates/widget_calendar/event-add.html
0 → 100644
View file @
4cd49e56
{% extends 'base.html' %}
{% load static %}
{% block title %}Add Activity{% endblock %}
{% block content %}
<h1>
Add a new activity:
</h1>
<div
class=
"new_user"
>
<form
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<button
type=
"submit"
>
Save New Activity
</button>
</form>
</div>
{% endblock %}
widget_nicsbabes/widget_calendar/urls.py
View file @
4cd49e56
from
django.urls
import
path
from
django.urls
import
path
from
.views
import
index
,
EventDetailView
from
.views
import
index
,
EventDetailView
,
EventCreateFormView
urlpatterns
=
[
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index'
),
path
(
''
,
index
,
name
=
'index'
),
path
(
'events/<int:pk>/details'
,
EventDetailView
.
as_view
(),
name
=
'event_details'
),
path
(
'events/<int:pk>/details'
,
EventDetailView
.
as_view
(),
name
=
'event_details'
),
path
(
'events/add'
,
EventCreateFormView
.
as_view
(),
name
=
'event_add'
),
]
]
app_name
=
"widget_calendar"
app_name
=
"widget_calendar"
\ No newline at end of file
widget_nicsbabes/widget_calendar/views.py
View file @
4cd49e56
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
.models
import
Event
,
Location
from
.models
import
Event
,
Location
from
.forms
import
EventCreateForm
from
django.views.generic.edit
import
CreateView
,
FormView
from
django.views.generic.detail
import
DetailView
from
django.views.generic.detail
import
DetailView
def
index
(
HttpRequest
):
def
index
(
HttpRequest
):
...
@@ -11,3 +13,8 @@ def index(HttpRequest):
...
@@ -11,3 +13,8 @@ def index(HttpRequest):
class
EventDetailView
(
DetailView
):
class
EventDetailView
(
DetailView
):
model
=
Event
model
=
Event
template_name
=
"widget_calendar/event-details.html"
template_name
=
"widget_calendar/event-details.html"
class
EventCreateFormView
(
CreateView
):
form_class
=
EventCreateForm
# taken from: https://stackoverflow.com/questions/27321692/override-a-django-generic-class-based-view-widget
template_name
=
"widget_calendar/event-add.html"
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