Created the UpdateView page for calendar

parent 81ec45c3
+{% extends 'base.html' %}
{% extends 'base.html' %}
{% load static %}
{% block title %}Widget's Calendar of Activities{% endblock %}
......
+{% extends 'base.html' %}
{% extends 'base.html' %}
{% load static %}
{% block title %} Add Activity {% endblock %}
......
+{% extends 'base.html' %}
{% extends 'base.html' %}
{% load static %}
{% block title %} {{ object.activity }} {% endblock %}
......@@ -20,7 +20,7 @@
<p> {{ event.location }} </p>
</div>
<button onclick="window.location.href='#';">
<button onclick="window.location.href='{% url 'forum:forumpost-edit' pk=object.pk %}';">
Edit Activity
</button>
......
{% extends 'base.html' %}
{% load static %}
{% block title %} Edit Activity {% endblock %}
{% block heading %}
<h1 class="subheader"> Edit Activity: </h1>
{% endblock %}
{% block content %}
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<div class="separator-bar"></div>
<input type="submit" value="Save New Activity" class="action-button">
</form>
{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import index, EventDetailView, EventCreateView
from .views import index, EventDetailView, EventCreateView, EventUpdateView
urlpatterns = [
path('', index, name='index'),
path('calendar/', index, name='index'),
path('events/<int:pk>/details', EventDetailView.as_view(), name='user-details'),
path('events/add', EventCreateView.as_view(), name='forumpost-add'),
path('events/<int:pk>/details', EventDetailView.as_view(), name='event-details'),
path('events/add', EventCreateView.as_view(), name='event-add'),
path('events/<int:pk>/edit', EventUpdateView.as_view(), name='event-edit'),
]
......
......@@ -8,16 +8,22 @@ from .models import Event, Location
def index(request):
events = Event.objects.all()
return render(request, 'calendar/calendar.html',
return render(request, 'widget_calendar/calendar.html',
{'events': events, })
class EventDetailView(DetailView):
model = Event
template_name = 'calendar/event-details.html'
template_name = 'widget_calendar/event-details.html'
class EventCreateView(CreateView):
model = Event
template_name = 'calendar/event-add.html'
template_name = 'widget_calendar/event-add.html'
fields = ["activity", "target_datetime", "estimated_hours", "location", "course"]
class EventUpdateView(UpdateView):
model = Event
template_name = 'widget_calendar/event-edit.html'
fields = '__all__'
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