Commit feb3c692 authored by Angelo Alvarez's avatar Angelo Alvarez

Added Feature: Adding Activities

parent 0f8ec36f
...@@ -33,3 +33,4 @@ class Event(models.Model): ...@@ -33,3 +33,4 @@ class Event(models.Model):
def get_absolute_url(self): def get_absolute_url(self):
return reverse('calendar_app:events-details', kwargs={'pk': self.pk}) return reverse('calendar_app:events-details', kwargs={'pk': self.pk})
{% extends 'base.html' %}
{% load static %}
{% block title %} Add Activity {% endblock %}
{% block content %}
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<button type="Submit">Save New Activity</button>
</form>
{% endblock %}
\ No newline at end of file
# <appname>/urls.py # <appname>/urls.py
from django.urls import path from django.urls import path
from .views import calendar, EventDetailView from .views import calendar, EventDetailView, EventCreateView
urlpatterns = [ urlpatterns = [
path('', calendar, name='calendar'), path('', calendar, name='calendar'),
path('events/<int:pk>/details/', EventDetailView.as_view(), name='events-details'), path('events/<int:pk>/details/', EventDetailView.as_view(), name='events-details'),
path('events/add/', EventCreateView.as_view(), name='add-event'),
] ]
app_name = "calendar_app" app_name = "calendar_app"
\ No newline at end of file
...@@ -3,6 +3,7 @@ from django.http import HttpResponse ...@@ -3,6 +3,7 @@ from django.http import HttpResponse
from .models import Event from .models import Event
from django.utils import timezone from django.utils import timezone
from django.views.generic.detail import DetailView from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView
# Create your views here. # Create your views here.
...@@ -16,3 +17,7 @@ class EventDetailView(DetailView): ...@@ -16,3 +17,7 @@ class EventDetailView(DetailView):
template_name = 'calendar_app/event-details.html' template_name = 'calendar_app/event-details.html'
model = Event model = Event
class EventCreateView(CreateView):
template_name = 'calendar_app/event-add.html'
model = Event
fields = ['activity', 'target_datetime', 'estimated_hours', 'location', 'course']
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment