Created event-add page html with create view

parent 84f882ed
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
{% endfor %} {% endfor %}
</ul> </ul>
<button onclick="window.location.href='#';"> <button onclick="window.location.href='{% url 'calendar:event-add' %}';">
New Activity New Activity
</button> </button>
......
+{% extends 'base.html' %}
{% load static %}
{% block title %} Add Activity {% endblock %}
{% block heading %}
<h1 class="subheader"> Add a new activity: </h1>
{% endblock %}
{% block content %}
<form method="post">
{% csrf_token %}
<div class="form-fields"> {{ form.as_p }} </div>
<div class="separator-bar"></div>
<input class="action-button" type="submit" value="Save New Activity">
</form>
{% endblock %}
\ No newline at end of file
+{% extends 'base.html' %} +{% extends 'base.html' %}
{% load static %} {% load static %}
{% block title %} {{ event.activity }} {% endblock %} {% block title %} {{ object.activity }} {% endblock %}
{% block heading %} {% block heading %}
<p id="uppercase"> <p id="uppercase">
<span id="white"> <span id="white">
{{ event.activity}} {{ object.activity }}
</span> </span>
</p> </p>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<div id="main"> <div id="main">
{% for event in object.events.all %}
<p id="subheading"> {{ event.target_datetime }} </p> <p id="subheading"> {{ event.target_datetime }} </p>
<p> {{ event.estimated_hours }} </p> <p> {{ event.estimated_hours }} </p>
<p> {{ event.course }} </p> <p> {{ event.course }} </p>
......
from django.urls import path from django.urls import path
from .views import index, EventDetailView from .views import index, EventDetailView, EventCreateView
urlpatterns = [ urlpatterns = [
path('', index, name='index'), path('', index, name='index'),
path('calendar/', index, name='index'), path('calendar/', index, name='index'),
path('events/<int:pk>/details', EventDetailView.as_view(), name='user-details'), path('events/<int:pk>/details', EventDetailView.as_view(), name='user-details'),
path('events/add', EventCreateView.as_view(), name='forumpost-add'),
] ]
......
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse from django.http import HttpResponse
from django.views.generic.detail import DetailView from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from .models import Event, Location from .models import Event, Location
...@@ -13,3 +15,9 @@ def index(request): ...@@ -13,3 +15,9 @@ def index(request):
class EventDetailView(DetailView): class EventDetailView(DetailView):
model = Event model = Event
template_name = 'calendar/event-details.html' template_name = 'calendar/event-details.html'
class EventCreateView(CreateView):
model = Event
template_name = 'calendar/event-add.html'
fields = ["activity", "target_datetime", "estimated_hours", "location", "course"]
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