Created the per activity details view page

parent fa6faa1a
......@@ -12,7 +12,6 @@ class Location(models.Model):
return '{} {}'.format(self.mode, self.venue)
class Event(models.Model):
target_datetime = models.DateTimeField(default=datetime.now())
activity = models.CharField(max_length=100, default="")
......@@ -31,4 +30,4 @@ class Event(models.Model):
return "{} {} {} {}".format(self.target_datetime, self.activity, self.estimated_hours, self.location)
def get_absolute_url(self):
return reverse('calendar:calender-details', kwargs={'pk': self.pk})
return reverse('calendar:event-details', kwargs={'pk': self.pk})
......@@ -8,8 +8,8 @@
<ul>
{% for event in events %}
<li>
<a href="#">
{{ event }}</a>
<a href="event.get_absolute_url">
{{ event.activity }}</a>
</li>
{% endfor %}
</ul>
......
+{% extends 'base.html' %}
{% load static %}
{% block title %} {{ event.activity }} {% endblock %}
{% block heading %}
<p id="uppercase">
<span id="white">
{{ event.activity}}
</span>
</p>
{% endblock %}
{% block content %}
<div id="main">
<p id="subheading"> {{ event.target_datetime }} </p>
<p> {{ event.estimated_hours }} </p>
<p> {{ event.course }} </p>
<p> {{ event.estimated_hours }} </p>
<p> {{ event.location }} </p>
</div>
<button onclick="window.location.href='#';">
Edit Activity
</button>
{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import index
from .views import index, EventDetailView
urlpatterns = [
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'),
]
app_name = "widget_calendar"
......@@ -8,3 +8,8 @@ def index(request):
events = Event.objects.all()
return render(request, 'calendar/calendar.html',
{'events': events, })
class EventDetailView(DetailView):
model = Event
template_name = 'calendar/event-details.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