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 django.urls import path
from .views import index from .views import (
calendar, EventDetailsView, EventsCreateView, EventsUpdateView
)
urlpatterns = [ 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" app_name = "widget_calendar"
\ No newline at end of file
from django.shortcuts import render 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 from .models import Event
def index(request): def calendar(request):
return_string = '<p>Widget`s Calendar of Activities<br><br>' return render(request, 'widget_calendar/calendar.html', {'name': 'Calendar Page'})
for event in Event.objects.all(): class EventDetailsView(DetailView):
event_string = ''' model = Event
Date and Time: {}, {}<br> template_name = 'widget_calendar/event-details.html'
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
return_string += '</p>' class EventsCreateView(CreateView):
html_string = '<html><body>{}</body></html>'.format(return_string) model = Event
fields = '__all__'
return HttpResponse(html_string) template_name = "widget_calendar/event-add.html"
\ 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' ...@@ -64,7 +64,7 @@ ROOT_URLCONF = 'widget_jenicaesports.urls'
TEMPLATES = [ TEMPLATES = [
{ {
'BACKEND': 'django.template.backends.django.DjangoTemplates', 'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [], 'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True, 'APP_DIRS': True,
'OPTIONS': { 'OPTIONS': {
'context_processors': [ '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