Updated Calendar widget to new specifications

parent 510374f1
......@@ -21,10 +21,6 @@ class WidgetUser(models.Model):
def get_absolute_url(self):
return reverse('widgetuser-detail', kwargs={'pk': self.pk})
def get_absolute_url(self):
return reverse('widgetuser-add', kwargs={'pk': self.pk})
\ No newline at end of file
......@@ -6,11 +6,10 @@ urlpatterns = [
path('Dashboard/', Dashboard_list_view, name='Dashboard_list_view'),
path('Widgetusers/<int:pk>/details', WidgetUserDetailView.as_view(),
name='widgetuser-detail'),
path('Widgetusers/add/', WidgetUserAddView.as_view(),
path('Widgetusers/add/', WidgetUserAddView.as_view(),
name='widgetuser-add'),
path('Widgetusers/<int:pk>/edit/', WidgetUserUpdateView.as_view(),
name='widgetuser-edit')
]
app_name = "Dashboard"
\ No newline at end of file
app_name = "Dashboard"
import string
from .models import WidgetUser, Department
from .models import WidgetUser
from django.http import HttpResponse
from django.shortcuts import render
from django.views.generic.detail import DetailView
from django.views.generic.list import ListView
from django.views import generic
......@@ -33,13 +31,13 @@ def Dashboard_list_view(request):
return HttpResponse(html_string_final)
class WidgetUserDetailView(generic.DetailView):
model = WidgetUser
template_name = 'widgetuser-details.html'
queryset = WidgetUser.objects.all()
context_object_name = 'widgetuser-detail'
class WidgetUserAddView(generic.CreateView):
model = WidgetUser
fields = '__all__'
......
{% extends "base.html" %}
{% load static %}
{% block content %}
<h1>Add Event</h1>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<a href="/Events/{{Event.pk}}/details">
<button type="submit">Add Event</button>
</a>
</form>
{% endblock content %}
\ No newline at end of file
{% extends "base.html" %}
{% load static %}
{% block content %}
<title>Event</title>
<br><br>
<h2>{{object.activity}}</h2>
<h3>Date and Time: {{object.target_datetime}}</h3>
<h3>Estimated Hours: {{object.estimated_hours}}</h3>
<h3>{{course}}</h3>
<h3>Mode: {{location.mode}}</h3>
<h3>Venue: {{location.venue}}</h3>
<a href="/Events/{{ object.id }}/edit">
<input type="button" value="Edit Event">
</a>"
{% endblock content %}
\ No newline at end of file
{% extends "base.html" %}
{% load static %}
{% block content %}
<h1>Edit Event</h1>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Edit Event" />
</a>
</form>
{% endblock content %}
\ No newline at end of file
from django.db import models
from django.urls import reverse
from Assignments.models import Course
......@@ -29,3 +30,10 @@ class Event(models.Model):
def __str__(self):
return '{} on {}'.format(self.activity, self.target_datetime)
def get_absolute_url(self):
return reverse('event-detail', kwargs={'pk': self.pk})
def get_absolute_url(self):
return reverse('event-add', kwargs={'pk': self.pk})
from django.urls import path
from .views import index
from .views import (index, EventDetailView, EventAddView, EventUpdateView)
urlpatterns = [
path('', index, name='index'),
path('Events/<int:pk>/details', EventDetailView.as_view(),
name='event-detail'),
path('Events/add/', EventAddView.as_view(),
name='event-add'),
path('Events/<int:pk>/edit/', EventUpdateView.as_view(),
name='event-edit')
]
app_name = "widget_Calendar"
from .models import Event, Location
from .models import Event
from django.http import HttpResponse
from forum.views import convert_utc_to_local
from django.views import generic
from django.urls import reverse
def index(request):
html_string = 'robo_mommy’s Calendar of Activities<br>'
html_string = 'robo_mommy’s Calendar of Activities<br><ul>'
for eventItem in Event.objects.all():
eventId = str(eventItem.pk)
href = '<a href="/Events/'+eventId+'/details">'
html_string += '''
<br>
<br><li> {}
Date and Time: {}<br>
Activity: {}<br>
Estimated Hours: {}<br>
Course/Section: {}<br>
Mode: {}<br>
Venue: {}<br><br>
Venue: {}<br>
</li><br>
'''.format(
href,
convert_utc_to_local(eventItem.target_datetime, '%d/%m/%Y|%I:%M %p'),
eventItem.activity,
eventItem.estimated_hours,
......@@ -22,4 +28,40 @@ def index(request):
eventItem.location.mode,
eventItem.location.venue,
)
html_string += '''
</ul>
<a href="/Events/add"><button value="click here">New Activity</button></a><br><br>
<a href="/Dashboard/">Dashboard</a><br>
<a href="/announcements/">Announcements</a><br>
<a href="/forum/">Forum</a><br>
<a href="/Assignments">Assignments</a><br>
'''
return HttpResponse(html_string)
class EventDetailView(generic.DetailView):
model = Event
template_name = 'event-details.html'
queryset = Event.objects.all()
context_object_name = 'event-detail'
class EventAddView(generic.CreateView):
model = Event
fields = '__all__'
template_name = 'event-add.html'
def get_success_url(self):
return reverse('widget_Calendar:event-detail', kwargs={'pk': self.object.id},
current_app=self.request.resolver_match.namespace)
class EventUpdateView(generic.UpdateView):
model = Event
template_name = 'event-edit.html'
fields = '__all__'
success_url = "widget_Calendar/"
def get_success_url(self):
return reverse('widget_Calendar:eventuser-detail', kwargs={'pk': self.object.id},
current_app=self.request.resolver_match.namespace)
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