Created the UpdateView page for calendar

parent 81ec45c3
+{% extends 'base.html' %} {% extends 'base.html' %}
{% load static %} {% load static %}
{% block title %}Widget's Calendar of Activities{% endblock %} {% block title %}Widget's Calendar of Activities{% endblock %}
......
+{% extends 'base.html' %} {% extends 'base.html' %}
{% load static %} {% load static %}
{% block title %} Add Activity {% endblock %} {% block title %} Add Activity {% endblock %}
......
+{% extends 'base.html' %} {% extends 'base.html' %}
{% load static %} {% load static %}
{% block title %} {{ object.activity }} {% endblock %} {% block title %} {{ object.activity }} {% endblock %}
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<p> {{ event.location }} </p> <p> {{ event.location }} </p>
</div> </div>
<button onclick="window.location.href='#';"> <button onclick="window.location.href='{% url 'forum:forumpost-edit' pk=object.pk %}';">
Edit Activity Edit Activity
</button> </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 django.urls import path
from .views import index, EventDetailView, EventCreateView from .views import index, EventDetailView, EventCreateView, EventUpdateView
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='event-details'),
path('events/add', EventCreateView.as_view(), name='forumpost-add'), 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 ...@@ -8,16 +8,22 @@ from .models import Event, Location
def index(request): def index(request):
events = Event.objects.all() events = Event.objects.all()
return render(request, 'calendar/calendar.html', return render(request, 'widget_calendar/calendar.html',
{'events': events, }) {'events': events, })
class EventDetailView(DetailView): class EventDetailView(DetailView):
model = Event model = Event
template_name = 'calendar/event-details.html' template_name = 'widget_calendar/event-details.html'
class EventCreateView(CreateView): class EventCreateView(CreateView):
model = Event model = Event
template_name = 'calendar/event-add.html' template_name = 'widget_calendar/event-add.html'
fields = ["activity", "target_datetime", "estimated_hours", "location", "course"] 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