Commit ac6aefdc authored by Gabriel Geraldo's avatar Gabriel Geraldo

implemented edit activity page and function

parent 4cd49e56
......@@ -15,7 +15,7 @@
Venue: {{ object.location.venue }}
</h2>
<form action="../edit/">
<form action="edit">
<input type="submit" value="Edit Activity">
</form>
......
{% extends 'base.html' %}
{% load static %}
{% block title %}Edit Activity{% endblock %}
{% block content %}
<h1>Edit Activity:</h1>
<div class="new_user">
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Save New Activity</button>
</form>
</div>
{% endblock %}
from django.urls import path
from .views import index, EventDetailView, EventCreateFormView
from .views import index, EventDetailView, EventCreateView, EventUpdateView
urlpatterns = [
path('', index, name='index'),
path('events/<int:pk>/details', EventDetailView.as_view(), name='event_details'),
path('events/add', EventCreateFormView.as_view(), name='event_add'),
path('events/<int:pk>/edit', EventUpdateView.as_view(), name='event_edit'),
path('events/add', EventCreateView.as_view(), name='event_add'),
]
......
......@@ -2,7 +2,7 @@ from django.shortcuts import render
from django.http import HttpResponse
from .models import Event, Location
from .forms import EventCreateForm
from django.views.generic.edit import CreateView, FormView
from django.views.generic.edit import CreateView, UpdateView
from django.views.generic.detail import DetailView
def index(HttpRequest):
......@@ -14,7 +14,12 @@ class EventDetailView(DetailView):
model = Event
template_name = "widget_calendar/event-details.html"
class EventCreateFormView(CreateView):
class EventCreateView(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"
class EventUpdateView(UpdateView):
model = Event
form_class = EventCreateForm
template_name="widget_calendar/event-edit.html"
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