Commit 71e1eaad authored by Neal Luigi D. Rodriguez's avatar Neal Luigi D. Rodriguez
parents 6ea5acc8 911bcc76
CSCI 40-F CSCI 40-F
Group Members: Group Members:
CASTILLO, Gareth Xerxes 205828 CASTILLO, Gareth Xerxes
GARCIA, Ann Colleen GARCIA, Ann Colleen
OLIVARES, Christian Louis 193636 OLIVARES, Christian Louis
204374 RODRIGUEZ, Neal Luigi D. 204374 RODRIGUEZ, Neal Luigi D.
204655 SEE, Eurydice Gabrielle Madison O. 204655 SEE, Eurydice Gabrielle Madison O.
...@@ -19,4 +19,8 @@ CALENDAR-Olivares ...@@ -19,4 +19,8 @@ CALENDAR-Olivares
[References] [References]
[Signatures] [Signatures]
\ No newline at end of file (sgd) Gareth Xerxes Yap Castillo March 5, 2023
(sgd) Neal Luigi RODRIGUEZ March 5, 2023
(sgd) Christian Louis Olivares March 5, 2023
(sgd) Ann Colleen Garcia March 5, 2023
\ No newline at end of file
from django.contrib import admin
from .models import Announcement, Reaction
class AnnouncementAdmin(admin.ModelAdmin):
model = Announcement
list_display = ('title','body','author','pub_datetime',)
class ReactionAdmin(admin.ModelAdmin):
model = Reaction
list_display = ('name','tally','announcement',)
admin.site.register(Announcement, AnnouncementAdmin)
admin.site.register(Reaction, ReactionAdmin)
\ No newline at end of file
from django.apps import AppConfig
class AnnouncementBoardConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'Announcement_Board'
# Generated by Django 4.1.6 on 2023-03-05 04:32
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Announcement',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=100)),
('body', models.CharField(max_length=2000)),
('author', models.CharField(max_length=50)),
('pub_datetime', models.CharField(max_length=700)),
],
),
migrations.CreateModel(
name='Reaction',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(choices=[('like', 'like'), ('love', 'love'), ('angry', 'angry')], max_length=100)),
('tally', models.IntegerField()),
('announcement', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='Announcement_Board.announcement')),
],
),
]
# Generated by Django 4.1.6 on 2023-03-05 07:46
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('Dashboard', '0001_initial'),
('Announcement_Board', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='announcement',
name='author',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='Dashboard.widgetuser'),
),
]
from django.db import models
from Dashboard.models import WidgetUser
class Announcement(models.Model):
title = models.CharField(max_length=100)
body = models.CharField(max_length=2000)
author = models.ForeignKey(WidgetUser, on_delete = models.CASCADE)
pub_datetime = models.CharField(max_length=700)
def __str__(self):
return self.title
class Reaction(models.Model):
name_choices = (
('like','like'),
('love','love'),
('angry','angry'),
)
name = models.CharField(max_length=100, choices=name_choices)
tally = models.IntegerField()
announcement = models.ForeignKey(Announcement, on_delete = models.CASCADE)
def __str__(self):
return self.name
from django.test import TestCase
# Create your tests here.
from django.urls import path
from .views import index
urlpatterns = [
path('', index, name = 'index'),
]
app_name = "AnnouncementBoard"
\ No newline at end of file
from django.shortcuts import render
from django.shortcuts import HttpResponse
from .models import Announcement, Reaction
def index(request):
return_string = '<ul>'
for announcement in Announcement.objects.all():
return_string += '{} by {}: <br> published {}:<br>{} <br>'.format(
announcement.title, announcement.author,
announcement.pub_datetime,announcement.body,
)
announced = announcement
like = 0
love = 0
angry = 0
for reaction in Reaction.objects.all():
if reaction.name == "like" and reaction.announcement == announced:
like += reaction.tally
if reaction.name == "love" and reaction.announcement == announced:
love += reaction.tally
if reaction.name == "angry" and reaction.announcement == announced:
angry += reaction.tally
return_string += 'like: {} <br> love: {} <br> angry: {}<br><br>'.format(
like, love, angry,
)
return_string += '</ul>'
html_string = '<html><head>Widget’s Announcement Board<br><br>Announcements:</head><body>{}</body><html>'.format(return_string)
return HttpResponse(html_string)
from django.contrib import admin
from .models import Department, WidgetUser
class DepartmentAdmin(admin.ModelAdmin):
model = Department
list_display = ('dept_name', 'home_unit')
class WidgetUserAdmin(admin.ModelAdmin):
model = WidgetUser
list_display = ('first_name', 'middle_name', 'last_name', 'department')
admin.site.register(Department, DepartmentAdmin)
admin.site.register(WidgetUser, WidgetUserAdmin)
\ No newline at end of file
from django.apps import AppConfig
class DashboardConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'Dashboard'
# Generated by Django 4.1.6 on 2023-03-02 13:32
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Department',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('dept_name', models.CharField(default='', max_length=50)),
('home_unit', models.CharField(default='', max_length=50)),
],
),
migrations.CreateModel(
name='WidgetUser',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('first_name', models.CharField(default='', max_length=50)),
('middle_name', models.CharField(default='', max_length=50)),
('last_name', models.CharField(default='', max_length=50)),
('department', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='Dashboard.department')),
],
),
]
from django.db import models
class Department(models.Model):
default_string = ""
dept_name = models.CharField(max_length = 50, default = default_string)
home_unit = models.CharField(max_length = 50, default = default_string)
def __str__(self):
return '{}'.format(self.dept_name)
class WidgetUser(models.Model):
default_string = ""
first_name = models.CharField(max_length = 50, default = default_string)
middle_name = models.CharField(max_length = 50, default = default_string)
last_name = models.CharField(max_length = 50, default = default_string)
department = models.ForeignKey(Department, on_delete = models.CASCADE)
def __str__(self):
return '{}'.format(self.first_name)
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
from django.urls import path
from .views import index
urlpatterns = [
path('', index, name = 'index'),
]
app_name = "Dashboard"
\ No newline at end of file
from django.shortcuts import render
from django.shortcuts import HttpResponse
from .models import Department, WidgetUser
def index(request):
return_string = '<ul>'
for user in WidgetUser.objects.all():
return_string += '<li>{}, {} {}: {}, {}</li>'.format(
user.last_name, user.first_name, user.middle_name, user.department, user.department.home_unit
)
return_string += '</ul>'
html_string = '<html><head>Welcome to Widget!<br> <br> WIDGET USERS:</head><body>{}</body><html>'.format(return_string)
return HttpResponse(html_string)
\ No newline at end of file
No preview for this file type
...@@ -40,7 +40,9 @@ INSTALLED_APPS = [ ...@@ -40,7 +40,9 @@ INSTALLED_APPS = [
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'Assignments' 'Dashboard',
'widgetcalendar',
'Announcement_Board',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
......
"""widget_gitgud URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin from django.contrib import admin
from django.urls import include, path from django.urls import include, path
urlpatterns = [ urlpatterns = [
path('Assignments', include('Assignments.urls', namespace="Assignments")), path('Dashboard/', include('Dashboard.urls', namespace="Dashboard")),
path('widgetcalendar/', include('widgetcalendar.urls', namespace="calendar")),
path('Announcement/', include('Announcement_Board.urls', namespace="Announcement_Board")),
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
] ]
\ No newline at end of file
from django.contrib import admin
from .models import Location, Event
class LocationAdmin(admin.ModelAdmin):
model = Location
list_display = ('mode', 'venue')
class Eventadmin(admin.ModelAdmin):
model = Event
list_display = ('target_datetime', 'activity', 'estimated_hours', 'location', 'course')
# registering the model and the admin is what tells
# Django that admin pages must be generated for the models specified
admin.site.register(Location, LocationAdmin)
admin.site.register(Event, Eventadmin)
\ No newline at end of file
from django.apps import AppConfig
class WidgetcalendarConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'widgetcalendar'
# Generated by Django 4.1.7 on 2023-03-02 12:44
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Location',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('mode', models.CharField(choices=[('onsite', 'onsite'), ('online', 'online'), ('hybrid', 'hybrid')], max_length=6)),
('venue', models.CharField(default='', max_length=50)),
],
),
migrations.CreateModel(
name='Event',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('target_datetime', models.DateTimeField()),
('activity', models.CharField(default='', max_length=100)),
('estimated_hours', models.FloatField()),
('course', models.CharField(max_length=50)),
('location', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='course_name', to='widgetcalendar.location')),
],
),
]
# Generated by Django 4.1.7 on 2023-03-04 06:35
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('widgetcalendar', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='location',
name='venue',
field=models.TextField(default='', max_length=200),
),
]
# Generated by Django 4.1.6 on 2023-03-05 08:38
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('widgetcalendar', '0002_alter_location_venue'),
]
operations = [
migrations.AlterField(
model_name='event',
name='activity',
field=models.TextField(default='', max_length=200),
),
]
from django.db import models
from django.urls import reverse
#FOR LUIGI: PLS UNCOMMENT WHEN YOU'RE DONE WITH YOUR APPS
#from assignments.models import Course
class Location(models.Model):
MODE_CHOICES = (
('onsite', 'onsite'),
('online', 'online'),
('hybrid', 'hybrid'),
)
mode = models.CharField(max_length=6, choices=MODE_CHOICES)
venue = models.TextField(max_length=200, default='')
def __str__(self):
return '{}, {} mode'.format(self.venue, self.mode)
def get_absolute_url(self):
return reverse('location_detail', args=[str(self.venue)])
class Event(models.Model):
target_datetime= models.DateTimeField()
activity = models.TextField(max_length=200, default='')
estimated_hours = models.FloatField()
location = models.ForeignKey(
Location,
on_delete=models.CASCADE,
related_name='course_name'
)
#FOR LUIGI: IF YOU'RE DONE PLS REPLACE THE CURRENT CODE FOR COURSE WITH THE COMMENTED ONE
# course = models.ForeignKey(
# Course,
# on_delete=models.CASCADE,
# related_name='course_name'
# )
course = models.CharField(max_length=50)
def __str__(self):
return '{}'.format(self.activity)
def get_absolute_url(self):
return reverse('event_detail', args=[str(self.activity)])
from django.test import TestCase
# Create your tests here.
from django.urls import path
from .views import index
urlpatterns = [
path('', index, name='index'),
]
app_name = "widgetcalendar"
\ No newline at end of file
from django.http import HttpResponse
from .models import Event
#Date format source: https://ourcodeworld.com/articles/read/555/how-to-format-datetime-objects-in-the-view-and-template-in-django
def index(request):
return_string = ''
for events in Event.objects.all():
return_string += 'Date and Time: {}<br>Activity: {}<br>Estimated Hours: {}<br>Course/Secion: {}<br>Mode: {}<br>Venue: {}<br></br>'.format(
events.target_datetime.strftime("%x, %I:%M %p"), events.activity, events.estimated_hours, events.course, events.location.mode, events.location.venue
)
html_string = '<html><head>Widget\'s Calendar of Activities<br></br></head><body>{}</body><html>'.format(return_string)
return HttpResponse(html_string)
\ No newline at end of file
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