Created calendar html files and set up urls

parent 3505d8fc
{% extends 'base.html' %}
{% load static %}
{% block title %}Widget's Calendar of Activities{% endblock %}
{% block content %}
<h1>Widget's Calendar of Activities</h1>
{% endblock %}s
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}This is the page title{% endblock %}
{% block content %}
<h1>Add Event</h1>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}This is the page title{% endblock %}
{% block content %}
<h1>Event Details</h1>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}This is the page title{% endblock %}
{% block content %}
<h1>Event Edit</h1>
{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import index
from .views import (
calendar, EventDetailsView, EventsCreateView, EventsUpdateView
)
urlpatterns = [
path('', index, name='index'),
path('', calendar, name='calendar home'),
path('events/<pk>/details/', EventDetailsView.as_view(), name='event-details'),
path('events/add/', EventsCreateView.as_view(),name='add-event'),
path('events/<pk>/edit/',EventsUpdateView.as_view(),name='update-event'),
]
app_name = "widget_calendar"
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
from django.views.generic.detail import DetailView
#from django.views.generic.list import ListView
from django.views.generic.edit import CreateView, UpdateView
from .models import Event
def index(request):
return_string = '<p>Widget`s Calendar of Activities<br><br>'
def calendar(request):
return render(request, 'widget_calendar/calendar.html', {'name': 'Calendar Page'})
for event in Event.objects.all():
event_string = '''
Date and Time: {}, {}<br>
Activity: {}<br>
Estimated Hours: {}<br>
Course/Section: {}<br>
Mode: {}<br>
Venue: {}<br>
'''.format(
event.target_datetime.strftime("%m/%d/%y"),
event.target_datetime.strftime("%I:%M %p"),
event.activity,
event.estimated_hours,
event.course,
event.location.mode,
event.location.venue
)
return_string += event_string
class EventDetailsView(DetailView):
model = Event
template_name = 'widget_calendar/event-details.html'
return_string += '</p>'
html_string = '<html><body>{}</body></html>'.format(return_string)
class EventsCreateView(CreateView):
model = Event
fields = '__all__'
template_name = "widget_calendar/event-add.html"
return HttpResponse(html_string)
\ No newline at end of file
class EventsUpdateView(UpdateView):
model = Event
fields = '__all__'
template_name = "widget_calendar/event-edit.html"
\ No newline at end of file
......@@ -64,7 +64,7 @@ ROOT_URLCONF = 'widget_jenicaesports.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
......
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