Commit 45a09d38 authored by Raul Jarod Conanan's avatar Raul Jarod Conanan

Merge branch 'dev' into 'master'

Dev

See merge request !22
parents a8941716 a939c3d1
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (midterm_robo_mommy)" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
......@@ -3,4 +3,4 @@ from django.apps import AppConfig
class AssignmentsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'Assignments'
name = 'assignments'
from django.forms import ModelForm
from .models import Assignment
from django import forms
class AssignmentForm(ModelForm):
class Meta:
model = Assignment
fields = "__all__"
labels = {
'name': '',
'description': '',
'course': 'Course: ',
'perfect_score': '',
}
widgets = {
'name': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Assignment Name'}),
'description': forms.Textarea(attrs={'class': 'form-control', 'placeholder': 'Description'}),
'course': forms.Select(attrs={'class': 'form-control', 'placeholder': 'Course'}),
'perfect_score': forms.NumberInput(attrs={'class': 'form-control', 'placeholder': 'Perfect Score'}),
'passing_score': forms.HiddenInput(),
}
\ No newline at end of file
......@@ -7,13 +7,13 @@ import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('Assignments', '0001_initial'),
('assignments', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='assignment',
name='course',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='Assignments.course'),
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='assignments.course'),
),
]
from django.db import models
from django.urls import reverse
class Course(models.Model):
......@@ -6,6 +7,9 @@ class Course(models.Model):
title = models.CharField(max_length=255, blank=True, null=True)
section = models.CharField(max_length=3, blank=True, null=True)
def __str__(self):
return self.code + '-' + self.section
class Assignment(models.Model):
name = models.CharField(max_length=255, blank=True, null=True)
......@@ -17,3 +21,12 @@ class Assignment(models.Model):
def save(self, *args, **kwargs):
self.passing_score = int(self.perfect_score * 0.60)
super(Assignment, self).save(*args, **kwargs)
def __str__(self):
return self.name
def get_absolute_url(self):
return reverse('assignments:assignments-item', kwargs={'pk': self.pk})
def get_update_url(self):
return reverse('assignments:assignments-edit', kwargs={'pk': self.pk})
from django.urls import path
from .views import index
from .views import (
index, AssignmentDetailsView,
AddAssignmentView, EditAssignmentView
)
urlpatterns = [
path('', index, name='index'),
path('add/', AddAssignmentView.as_view(), name='assignments-add'),
path('<int:pk>/edit/', EditAssignmentView.as_view(), name='assignments-edit'),
path('<int:pk>/details/', AssignmentDetailsView.as_view(), name='assignments-item'),
]
app_name = "Assignments"
app_name = "assignments"
from django.http import HttpResponse
from django.shortcuts import render
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from .models import Assignment
from .forms import AssignmentForm
class AssignmentDetailsView(DetailView):
model = Assignment
template_name = 'assignments/assignment-details.html'
class AddAssignmentView(CreateView):
model = Assignment
form_class = AssignmentForm
template_name = 'assignments/assignment-add.html'
class EditAssignmentView(UpdateView):
model = Assignment
form_class = AssignmentForm
template_name = 'assignments/assignment-edit.html'
def index(request):
output = f"Widget's Assignments Page<br><br>"
count = Assignment.objects.all().count()
for i in range(1, count + 1):
assignments = Assignment.objects.get(id=i)
output += f"""Assignment Name: {assignments.name}<br>
Description: {assignments.description}<br>
Perfect Score: {assignments.perfect_score}<br>
Passing Score: {assignments.passing_score}<br>
Course/Section: {assignments.course.code} {assignments.course.title}-{assignments.course.section}<br>
<br>"""
return HttpResponse(output)
assignments = Assignment.objects.all()
context = {
'assignments': assignments
}
return render(request, 'assignments/assignments.html', context)
# Generated by Django 3.2 on 2023-05-11 11:03
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('Dashboard', '0002_widgetuser'),
]
operations = [
migrations.AlterField(
model_name='widgetuser',
name='department',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='department', to='Dashboard.department'),
),
]
......@@ -16,12 +16,8 @@ class WidgetUser(models.Model):
last_name = models.CharField(max_length=50)
department = models.ForeignKey(Department, related_name="department", on_delete=models.CASCADE)
def __str__(self) -> str:
return str(self.last_name + ', ' + self.first_name)
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,30 +12,31 @@ 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>'
html_string_3 += '<a href="/Forum/">Forum</a><br>'
html_string_3 += '<a href="/Assignments">Assignment</a><br>'
html_string_3 += '<a href="/Calendar/">Calendar</a><br>'
html_string_3 += '<a href="/announcements/">Announcement Board</a><br>'
html_string_3 += '<a href="/forum/">Forum</a><br>'
html_string_3 += '<a href="/assignments">Assignment</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>'
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
# Generated by Django 3.2 on 2023-05-13 14:43
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('announcements', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='reaction',
name='announcement',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='react', to='announcements.announcement'),
),
]
......@@ -19,6 +19,6 @@ class Reaction(models.Model):
name = models.CharField(max_length=5, default=LIKE, null=True, blank=True)
tally = models.IntegerField(default=0 ,null=True, blank=True)
announcement = models.ForeignKey(Announcement, on_delete=models.CASCADE, null=True)
announcement = models.ForeignKey(Announcement, related_name="react", on_delete=models.CASCADE, null=True)
# Create your models here.
{% extends 'base.html' %}
{% load static %}
{% block content %}
<title>Add Announcement</title>
<h1>Add a new announcement:</h1>
<form action="" method=POST>
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Add Announcement">
</form>
{% endblock content %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block content %}
<title>{{ announce.title }}</title>
<h1>{{ announce.title }}</h1>
<h2>by {{ announce.author.first_name }} {{ announce.author.last_name }}</h2>
<p>{{ announce.pub_datetime|date:'m/d/Y, h:i A' }}</p>
<p>{{ announce.body }}</p>
<p>
{% for react in announce.react.all %}
{{ react.name }}: {{ react.tally }}<br>
{% endfor %}
</p>
<a href = "/announcements/{{ announce.pk }}/edit/"><button value="">Edit Announcement</button></a>
{% endblock content %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block content %}
<title>Edit Announcement</title>
<h1>Edit announcement:</h1>
<form action="" method=POST>
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Save Changes to Announcement">
</form>
{% endblock content %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block content %}
<title>Widget's Announcement Board</title>
<h1>Welcome to Widget's Announcement Board!</h1>
<h3>Announcements:</h3>
{% for announce in announcement %}
<a href = "{{ announce.pk }}/details/">{{ announce.title }} by {{ announce.author.first_name }} {{ announce.author.last_name }}</a><br>
{% endfor %} <br>
<a href="add/"><button value="click here">Add Announcement</button></a><br><br>
<a href = "/Dashboard/">Dashboard</a><br>
<a href = "/forum/">Forum</a><br>
<a href = "/assignments/">Assignments</a><br>
<a href = "/widget_Calendar/">Calendar</a>
{% endblock content %}
\ No newline at end of file
from django.urls import path
from .views import index
from .views import index, AnnouncementDetailView, AnnouncementAddView, AnnouncementEditView
urlpatterns = [
path('', index, name='index'),
path('announcements/', index, name='index'),
path('announcements/<int:pk>/details/', AnnouncementDetailView.as_view(), name='announcementdetailview'),
path('announcements/add/', AnnouncementAddView.as_view(), name='announcement-add'),
path('announcements/<int:pk>/edit/', AnnouncementEditView.as_view(), name='announcement-edit'),
]
app_name = "announcements"
\ 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.edit import CreateView, UpdateView
from django.urls import reverse
from .models import Announcement, Reaction
import pytz
from django.utils import timezone
def convert_to_localtime(utctime):
format = '%d/%m/%Y %I:%M %p'
format = '%m/%d/%Y %I:%M %p'
utc = utctime.replace(tzinfo=pytz.UTC)
localtz = utc.astimezone(timezone.get_current_timezone())
return localtz.strftime(format)
def index(request):
html_string_1 = '<html lang="en"><head><meta charset="UTF-8"></head>\
<b><h1>Widget\'s Announcement Board</h1></b>\
<h2>Announcements:</h2><br/>'
announcement = Announcement.objects.all().order_by('-pub_datetime')
context = {
'announcement': announcement
}
html_string_2 = ""
for announced in Announcement.objects.all():
html_string_2 += "{} by {} {} published {}:<br />\
{}<br/>".format(announced.title, announced.author.first_name,
announced.author.last_name,
convert_to_localtime(announced.pub_datetime), announced.body)
for reacts in announced.reaction_set.all():
html_string_2 += "{}: {}<br/>".format(reacts.name, reacts.tally)
html_string_2 += '<br/>'
html_string_final = html_string_1 + html_string_2 + "</html>"
return render(request, 'announcements/announcements.html', context)
class AnnouncementDetailView(DetailView):
model = Announcement
template_name = 'announcements/announcement-details.html'
queryset = Announcement.objects.all()
context_object_name = 'announce'
class AnnouncementAddView(CreateView):
model = Announcement
fields = ['title', 'body', 'author']
template_name = 'announcements/announcement-add.html'
return HttpResponse(html_string_final)
def get_success_url(self):
return reverse('announcement:announcementdetailview', kwargs={'pk': self.object.id},
current_app=self.request.resolver_match.namespace)
class AnnouncementEditView(UpdateView):
model = Announcement
template_name = 'announcements/announcement-edit.html'
fields = ['title', 'body', 'author']
def get_success_url(self):
return reverse('announcement:announcementdetailview', kwargs={'pk': self.object.id},
current_app=self.request.resolver_match.namespace)
# Create your views here.
{% extends 'base.html' %}
{% block content %}
<title>Add Assignment</title>
<h1>Add a new assignment:</h1>
<form action="" method=POST>
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Save New Assignment">
</form>
{% endblock content %}
{% extends 'base.html' %}
{% block content %}
<title>{{ assignment.name }}</title>
<h1>{{ assignment.name }}</h1>
<p>
{{ assignment.course.code }} {{ assignment.course.title }}-{{ assignment.course.section }} <br><br>
Description: {{ assignment.description }} <br>
Perfect Score: {{ assignment.perfect_score }} <br>
Passing Score: {{ assignment.passing_score }} <br>
</p>
<li>
<a href="{{ assignment.get_update_url }}">Edit Assignment</a>
</li>
{% endblock %}
{% extends 'base.html' %}
{% block content %}
<title>Edit Assignment</title>
<h1>Edit Assignment.</h1>
<form action="" method=POST>
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Save Changes to Assignment">
</form>
{% endblock content %}
{% extends 'base.html' %}
{% block content %}
<title>Widget's Assignments</title>
<h1>Welcome to Widget's Assignments!</h1>
{% for assignment in assignments %}
<a href="{{ assignment.pk }}/details/">{{ assignment.name }}</a><br>
{% endfor %}
<br>
<a href="add/"><button value="click here">New Assignment</button></a><br><br>
<a href="/Dashboard/">Dashboard</a><br>
<a href="/announcements/">Announcements</a><br>
<a href="/forum/">Forum</a><br>
<a href="/widget_Calendar/">Calendar</a><br>
{% endblock content %}
{% extends 'base.html' %}
{% load static %}
{% block content %}
<title>Widget's Forum</title>
<h1>Welcome to Widget's Forum</h1>
<h2>Forum posts:</h2>
{% for post in posts %}
<a href="forumposts/{{ post.pk }}/details/">{{ post.title }} by {{ post.author.first_name }} {{ post.author.last_name }}</a><br>
{% endfor %}
<br><br>
<a href="forumposts/add/"><button value="click here">New Post</button></a><br><br>
<a href="/Dashboard/">Dashboard</a><br>
<a href="/announcements/">Announcements</a><br>
<a href="/assignments/">Assignments</a><br>
<a href="/widget_Calendar/">Calendar</a><br>
{% endblock content %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block content %}
<title>Add Post</title>
<h1>Add a new post:</h1>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Save New Post">
</form>
{% endblock content %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block content %}
<title>{{ posts.title }}</title>
<h1>{{ posts.title }}</h1>
<h2>by {{ posts.author.first_name }} {{ posts.author.last_name }}</h2>
<p>{{ posts.pub_datetime|date:"M/d/Y, f A"}}</p>
<p>{{ posts.body }}</p>
<h3>POST REPLIES:</h3>
{% for reply in posts.reply.all %}
by {{ reply.author.first_name }} {{ reply.author.last_name }}<br>
{{ reply.pub_datetime|date:"M/d/Y, f A"}}<br>
{{ reply.body }}<br><br>
{% endfor %}
<a href="/forum/forumposts/{{ posts.pk }}/edit/"><button value="click here">Edit Post</button></a>
{% endblock content %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block content %}
<title>Edit Post</title>
<h1>Edit post:</h1>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Save Changes to Post">
</form>
{% endblock content %}
\ No newline at end of file
......@@ -2,5 +2,10 @@ from django.urls import path
from .views import *
urlpatterns = [
path('forum/', forum_post_list_view, name='forum_post_list_view')
path('forum/', forum_post_list_view, name='forum_post_list_view'),
path('forum/forumposts/<int:pk>/details/', ForumPostDetailView.as_view(), name='forumpostdetailview'),
path('forum/forumposts/add/', ForumPostCreateView.as_view(), name='forumpostcreateview'),
path('forum/forumposts/<int:pk>/edit/', ForumPostUpdateView.as_view(), name='forumpostupdateview'),
]
app_name = 'forum'
from django.shortcuts import render
from django.http import HttpResponse
from django.views import generic
from django.urls import reverse
from .models import ForumPost
import pytz
from django.utils import timezone
# helper function to convert utc datetime object to local time
def convert_utc_to_local(utctime, format):
datetime_format = format
......@@ -13,26 +15,35 @@ def convert_utc_to_local(utctime, format):
def forum_post_list_view(request):
html_string_1 = '<html lang="en"><head><meta charset="UTF-8"><title>Forum Post List</title>' \
'<h1>Forum Post List</h1></head><ul>'
html_string_2 = ''
for fp in ForumPost.objects.all():
html_string_2 += '<li><b style="font-size: 30px">{}</b>' \
' by <b style="font-size: large">{} {}</b>' \
' posted <b>{}</b><p>{}</p><ul>'.format(fp.title,
fp.author.first_name,
fp.author.last_name,
convert_utc_to_local(fp.pub_datetime,
'%d/%m/%Y %I:%M %p'),
fp.body)
for replies in fp.reply.all():
html_string_2 += '<li> Reply by <b>{} {}</b> ' \
'posted <b>{}</b><p>{}</p></li>'.format(replies.author.first_name,
replies.author.last_name,
convert_utc_to_local(replies.pub_datetime,
'%d/%m/%Y %I:%M %p'),
replies.body)
html_string_2 += '</ul></li>'
html_string_final = html_string_1 + html_string_2 + '</ul></html>'
return HttpResponse(html_string_final)
posts = ForumPost.objects.all().order_by('-pub_datetime')
context = {
'posts': posts
}
return render(request, 'forum/forum.html', context)
class ForumPostDetailView(generic.DetailView):
model = ForumPost
template_name = 'forum/forumpost-details.html'
queryset = ForumPost.objects.all()
context_object_name = 'posts'
class ForumPostCreateView(generic.CreateView):
model = ForumPost
template_name = 'forum/forumpost-add.html'
fields = '__all__'
def get_success_url(self):
return reverse('forum:forumpostdetailview', kwargs={ 'pk': self.object.id},
current_app=self.request.resolver_match.namespace)
class ForumPostUpdateView(generic.UpdateView):
model = ForumPost
template_name = 'forum/forumpost-edit.html'
fields = '__all__'
def get_success_url(self):
return reverse('forum:forumpostdetailview', kwargs={ 'pk': self.object.id},
current_app=self.request.resolver_match.namespace)
\ No newline at end of file
SECRET_KEY = 'django-insecure-t*s#_++5=ze%3#*ns6vcmt8a5bw6249en-!ek7*#3=p-dkhl_f'
\ No newline at end of file
......@@ -7,7 +7,7 @@ import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('Assignments', '0002_alter_assignment_course'),
('assignments', '0002_alter_assignment_course'),
('widget_Calendar', '0002_event_location_delete_indexcard_event_location'),
]
......@@ -15,6 +15,6 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='event',
name='course',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='event', to='Assignments.course'),
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='event', to='assignments.course'),
),
]
from django.db import models
from Assignments.models import Course
from django.urls import reverse
from assignments.models import Course
MODE_TYPES = (
......@@ -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)
......@@ -38,7 +38,7 @@ ALLOWED_HOSTS = []
INSTALLED_APPS = [
'announcements',
'Assignments',
'assignments',
'forum.apps.ForumConfig',
'Dashboard.apps.DashboardConfig',
'django.contrib.admin',
......
......@@ -18,11 +18,11 @@ from django.urls import include, path
urlpatterns = [
path('announcements/', include('announcements.urls', namespace="announcements")),
path('', include('announcements.urls', namespace="announcements")),
path('widget_Calendar/', include('widget_Calendar.urls', namespace="widget_Calendar")),
path('', include('Dashboard.urls', namespace="Dashboard")),
path('admin/', admin.site.urls),
path('Assignments/', include('Assignments.urls', namespace="Assignments")),
path('assignments/', include('assignments.urls', namespace="assignments")),
path('', include(('forum.urls', 'forum'), namespace='forum')),
path('Dashboard/', include('Dashboard.urls', namespace="Dashboard")),
# path('Dashboard/', include('Dashboard.urls', namespace="Dashboard")),
]
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