Commit 54ffcbea authored by Raul Jarod Conanan's avatar Raul Jarod Conanan

Merge branch '5-Calendarv2' into 'dev'

5 calendarv2

See merge request !20
parents b4aaf490 c892e129
...@@ -21,10 +21,3 @@ class WidgetUser(models.Model): ...@@ -21,10 +21,3 @@ class WidgetUser(models.Model):
def get_absolute_url(self): def get_absolute_url(self):
return reverse('widgetuser-detail', kwargs={'pk': self.pk}) 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
...@@ -10,7 +10,6 @@ urlpatterns = [ ...@@ -10,7 +10,6 @@ urlpatterns = [
name='widgetuser-add'), name='widgetuser-add'),
path('Widgetusers/<int:pk>/edit/', WidgetUserUpdateView.as_view(), path('Widgetusers/<int:pk>/edit/', WidgetUserUpdateView.as_view(),
name='widgetuser-edit') name='widgetuser-edit')
] ]
app_name = "Dashboard" app_name = "Dashboard"
import string from .models import WidgetUser
from .models import WidgetUser, Department
from django.http import HttpResponse 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 from django.views import generic
from django.urls import reverse from django.urls import reverse
...@@ -16,11 +12,13 @@ def Dashboard_list_view(request): ...@@ -16,11 +12,13 @@ def Dashboard_list_view(request):
for wu in WidgetUser.objects.all(): for wu in WidgetUser.objects.all():
number = str(wu.pk) number = str(wu.pk)
href = '<a href="/Widgetusers/' + number + '/details">' href = '<a href="/Widgetusers/' + number + '/details">'
html_string_2 += '<li>' + href + '{}, {} {}: {}, {}' .format(wu.last_name, html_string_2 += '<li>' + href + '{}, {} {}: {}, {}' .format(
wu.last_name,
wu.first_name, wu.first_name,
wu.middle_name, wu.middle_name,
wu.department.dept_name, wu.department.dept_name,
wu.department.home_unit) wu.department.home_unit
)
html_string_2 += '</ul></li>' html_string_2 += '</ul></li>'
html_string_3 = '<a href="/Widgetusers/add"><button value="click here" > Add Widget User</button></a><br><br>' html_string_3 = '<a href="/Widgetusers/add"><button value="click here" > Add Widget User</button></a><br><br>'
html_string_3 += '<a href="/announcements/">Announcement Board</a><br>' html_string_3 += '<a href="/announcements/">Announcement Board</a><br>'
...@@ -29,17 +27,16 @@ def Dashboard_list_view(request): ...@@ -29,17 +27,16 @@ def Dashboard_list_view(request):
html_string_3 += '<a href="/widget_Calendar/">Calendar</a><br>' html_string_3 += '<a href="/widget_Calendar/">Calendar</a><br>'
html_string_final = html_string_1 + html_string_2 + html_string_3 + '</html>' html_string_final = html_string_1 + html_string_2 + html_string_3 + '</html>'
return HttpResponse(html_string_final) return HttpResponse(html_string_final)
class WidgetUserDetailView(generic.DetailView): class WidgetUserDetailView(generic.DetailView):
model = WidgetUser model = WidgetUser
template_name = 'widgetuser-details.html' template_name = 'widgetuser-details.html'
queryset = WidgetUser.objects.all() queryset = WidgetUser.objects.all()
context_object_name = 'widgetuser-detail' context_object_name = 'widgetuser-detail'
class WidgetUserAddView(generic.CreateView): class WidgetUserAddView(generic.CreateView):
model = WidgetUser model = WidgetUser
fields = '__all__' fields = '__all__'
...@@ -59,4 +56,3 @@ class WidgetUserUpdateView(generic.UpdateView): ...@@ -59,4 +56,3 @@ class WidgetUserUpdateView(generic.UpdateView):
def get_success_url(self): def get_success_url(self):
return reverse('Dashboard:widgetuser-detail', kwargs={'pk': self.object.id}, return reverse('Dashboard:widgetuser-detail', kwargs={'pk': self.object.id},
current_app=self.request.resolver_match.namespace) current_app=self.request.resolver_match.namespace)
\ No newline at end of file
from django.db import models from django.db import models
from django.urls import reverse
from assignments.models import Course from assignments.models import Course
...@@ -18,14 +19,22 @@ class Location(models.Model): ...@@ -18,14 +19,22 @@ class Location(models.Model):
class Event(models.Model): class Event(models.Model):
target_datetime = models.DateTimeField()
activity = models.CharField(max_length=100) activity = models.CharField(max_length=100)
target_datetime = models.DateTimeField()
estimated_hours = models.FloatField() estimated_hours = models.FloatField()
location = models.ForeignKey( location = models.ForeignKey(
Location, Location,
on_delete=models.CASCADE on_delete=models.CASCADE
) )
course = models.ForeignKey(Course, related_name='event', on_delete=models.CASCADE, null=True) course = models.ForeignKey(
Course,
related_name='event',
on_delete=models.CASCADE,
null=True
)
def __str__(self): def __str__(self):
return '{} on {}'.format(self.activity, self.target_datetime) return '{} on {}'.format(self.activity, self.target_datetime)
def get_absolute_url(self):
return reverse('event-detail', kwargs={'pk': self.pk})
{% extends "base.html" %}
{% load static %}
{% block content %}
<title>Add Activity</title>
Add a new activity:
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<a href="/Events/{{Event.pk}}/details">
<button type="submit">Save New Activity</button>
</a>
</form>
{% endblock content %}
\ No newline at end of file
{% extends "base.html" %}
{% load static %}
{% block content %}
<title>{{object.activity}}</title>
<h2>{{object.activity}}</h2>
<br>Date and Time: {{object.target_datetime|date:"m/d/y, h:i A"}}<br>
<br>Estimated Hours: {{object.estimated_hours}}<br>
<br>{{object.course.code}} {{object.course.title}} - {{object.course.section}}<br>
<br>Mode: {{object.location.mode}}<br>
<br>Venue: {{object.location.venue}}<br>
<br><br>
<a href="edit">
<input type="button" value="Edit Activity">
</a>
{% endblock content %}
\ No newline at end of file
{% extends "base.html" %}
{% load static %}
{% block content %}
<title>Edit Activity</title>
Edit Activity:<br>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Save New Activity" />
</a>
</form>
{% endblock content %}
\ No newline at end of file
from django.urls import path from django.urls import path
from .views import index from .views import (index, EventDetailView, EventAddView, EventUpdateView)
urlpatterns = [ urlpatterns = [
path('', index, name='index'), path('', index, name='index'),
path('widget_Calendar/Events/<int:pk>/details', EventDetailView.as_view(),
name='event-detail'),
path('widget_Calendar/Events/add/', EventAddView.as_view(),
name='event-add'),
path('widget_Calendar/Events/<int:pk>/edit/', EventUpdateView.as_view(),
name='event-edit')
] ]
app_name = "widget_Calendar" app_name = "widget_Calendar"
from .models import Event, Location from .models import Event
from django.http import HttpResponse from django.http import HttpResponse
from forum.views import convert_utc_to_local from forum.views import convert_utc_to_local
from django.views import generic
from django.urls import reverse
def index(request): def index(request):
html_string = 'robo_mommy’s Calendar of Activities<br>' html_string = '''
<title>robo_mommy’s Calendar of Activities</title>
<h2>robo_mommy’s Calendar of Activities</h2><ul>
'''
for eventItem in Event.objects.all(): for eventItem in Event.objects.all():
eventId = str(eventItem.pk)
href = '<a href="widget_Calendar/Events/'+eventId+'/details">'
html_string += ''' html_string += '''
<br> <br><li> {}
Date and Time: {}<br> Date and Time: {}<br>
Activity: {}<br> Activity: {}<br>
Estimated Hours: {}<br> Estimated Hours: {}<br>
Course/Section: {}<br> Course/Section: {}<br>
Mode: {}<br> Mode: {}<br>
Venue: {}<br><br> Venue: {}<br>
</li><br>
'''.format( '''.format(
href,
convert_utc_to_local(eventItem.target_datetime, '%d/%m/%Y|%I:%M %p'), convert_utc_to_local(eventItem.target_datetime, '%d/%m/%Y|%I:%M %p'),
eventItem.activity, eventItem.activity,
eventItem.estimated_hours, eventItem.estimated_hours,
...@@ -22,4 +31,40 @@ def index(request): ...@@ -22,4 +31,40 @@ def index(request):
eventItem.location.mode, eventItem.location.mode,
eventItem.location.venue, eventItem.location.venue,
) )
html_string += '''
</ul>
<a href="widget_Calendar/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) return HttpResponse(html_string)
class EventDetailView(generic.DetailView):
model = Event
template_name = 'widget_Calendar/event-details.html'
queryset = Event.objects.all()
context_object_name = 'event-detail'
class EventAddView(generic.CreateView):
model = Event
fields = '__all__'
template_name = 'widget_Calendar/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 = 'widget_Calendar/event-edit.html'
fields = '__all__'
success_url = "widget_Calendar/"
def get_success_url(self):
return reverse('widget_Calendar:event-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