Commit 619afd5f authored by Jiuvi Anne Hu's avatar Jiuvi Anne Hu

Merge branch 'dev' of https://gitlab.discs.ateneo.edu/RJC/midterm_robo_mommy into announcementsv2

Update local repository.
parents 5a4dbbee 7811df17
......@@ -21,10 +21,3 @@ 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
from django.urls import reverse
......@@ -16,11 +12,13 @@ def Dashboard_list_view(request):
for wu in WidgetUser.objects.all():
number = str(wu.pk)
href = '<a href="/Widgetusers/' + number + '/details">'
html_string_2 += '<li>' + href + '{}, {} {}: {}, {}' .format(wu.last_name,
wu.first_name,
wu.middle_name,
wu.department.dept_name,
wu.department.home_unit)
html_string_2 += '<li>' + href + '{}, {} {}: {}, {}' .format(
wu.last_name,
wu.first_name,
wu.middle_name,
wu.department.dept_name,
wu.department.home_unit
)
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="/announcements/">Announcement Board</a><br>'
......@@ -29,17 +27,16 @@ def Dashboard_list_view(request):
html_string_3 += '<a href="/widget_Calendar/">Calendar</a><br>'
html_string_final = html_string_1 + html_string_2 + html_string_3 + '</html>'
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__'
......@@ -59,4 +56,3 @@ class WidgetUserUpdateView(generic.UpdateView):
def get_success_url(self):
return reverse('Dashboard:widgetuser-detail', kwargs={'pk': self.object.id},
current_app=self.request.resolver_match.namespace)
\ No newline at end of file
from django.db import models
from django.urls import reverse
from assignments.models import Course
......@@ -18,14 +19,22 @@ class Location(models.Model):
class Event(models.Model):
target_datetime = models.DateTimeField()
activity = models.CharField(max_length=100)
target_datetime = models.DateTimeField()
estimated_hours = models.FloatField()
location = models.ForeignKey(
Location,
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):
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 .views import index
from .views import (index, EventDetailView, EventAddView, EventUpdateView)
urlpatterns = [
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"
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 = '''
<title>robo_mommy’s Calendar of Activities</title>
<h2>robo_mommy’s Calendar of Activities</h2><ul>
'''
for eventItem in Event.objects.all():
eventId = str(eventItem.pk)
href = '<a href="widget_Calendar/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 +31,40 @@ def index(request):
eventItem.location.mode,
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)
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