Commit e7a4085e authored by Jan Ericsson Ong Ang's avatar Jan Ericsson Ong Ang

Merge branch 'master' of to current calendar_wip

parent ce9d3a55
.env .env
__pycache__ # Created by https://www.toptal.com/developers/gitignore/api/django,macos,windows
*.pyc # Edit at https://www.toptal.com/developers/gitignore?templates=django,macos,windows
\ No newline at end of file
### Django ###
*.log
*.pot
*.pyc
__pycache__/
local_settings.py
db.sqlite3
db.sqlite3-journal
media
# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/
# in your Git repository. Update and uncomment the following line accordingly.
# <django-project-name>/staticfiles/
### Django.Python Stack ###
# Byte-compiled / optimized / DLL files
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
# Django stuff:
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### macOS Patch ###
# iCloud generated files
*.icloud
### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
# End of https://www.toptal.com/developers/gitignore/api/django,macos,windows
\ No newline at end of file
from django.contrib import admin from django.contrib import admin
from .models import Announcement, Reaction
# Register your models here.
class ReactionInline(admin.TabularInline):
model = Reaction
# admin panel for Announcemnet model
class AnnouncementAdmin(admin.ModelAdmin):
model = Announcement
search_fields = ('title', 'author',)
list_display = ('title', 'body', 'author', 'pub_datetime',)
list_filter = ('title', 'author', 'pub_datetime',)
inlines = [ReactionInline,]
# admin panel for Reaction model
class ReactionAdmin(admin.ModelAdmin):
model = Reaction
search_fields = ('name', 'announcement',)
list_display = ('name', 'tally', 'announcement',)
list_filter = ('name', 'tally',)
admin.site.register(Announcement, AnnouncementAdmin)
admin.site.register(Reaction, ReactionAdmin)
# Generated by Django 3.2 on 2023-03-05 14:28
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('dashboard', '0002_alter_widgetuser_department'),
]
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=50)),
('body', models.TextField(max_length=420)),
('pub_datetime', models.DateTimeField(auto_now_add=True)),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dashboard.widgetuser')),
],
),
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(default=1)),
('announcement', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='announcement_board.announcement')),
],
),
]
# Generated by Django 3.2 on 2023-03-05 15:19
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('announcement_board', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='reaction',
name='name',
field=models.CharField(max_length=100),
),
migrations.AlterField(
model_name='reaction',
name='tally',
field=models.IntegerField(default=0),
),
]
from django.db import models from django.db import models
from dashboard.models import WidgetUser
# Create your models here. # Announcement
# title; body; author; pub_datetime
class Announcement(models.Model):
title = models.CharField(max_length=50)
body = models.TextField(max_length=420)
author = models.ForeignKey(WidgetUser, on_delete=models.CASCADE)
pub_datetime = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.title
# Reaction
# name; tally; announcement;
class Reaction(models.Model):
name = models.CharField(max_length=100)
tally = models.IntegerField(default=0)
announcement = models.ForeignKey(Announcement, on_delete=models.CASCADE)
def __str__(self):
return self.name
from django.urls import path
from .import views
# url for announcement
urlpatterns = [
path("", views.announcement_boardIndex, name = "announcement_boardIndex")
]
app_name = "announcement_board"
\ No newline at end of file
from django.shortcuts import render from django.http import HttpResponse
from .models import Announcement, Reaction
# Create your views here.
# announcemnet view from .models
def announcement_boardIndex(request):
announcements = Announcement.objects.all()
reactions = Reaction.objects.all()
announcement_board_output = "Widget’s Announcement Board <br><br> Announcements: <br>"
for announcement in announcements:
datetime = announcement.pub_datetime.strftime("%m/%d/%Y, %I:%M %p")
announcement_board_output += (announcement.title + " by " + announcement.author.first_name +
" " + announcement.author.last_name + " published " + datetime +
": <br>" + announcement.body + "<br>"
)
like_tally = 0
love_tally = 0
angry_tally = 0
for reaction in reactions:
if reaction.announcement.title == announcement.title:
if reaction.name == "Like":
like_tally = reaction.tally
elif reaction.name == "Love":
love_tally = reaction.tally
elif reaction.name == "Angry":
angry_tally = reaction.tally
announcement_board_output = (announcement_board_output + "Like: " + str(like_tally) + "<br>Love: " +
str(love_tally) + "<br>Angry: " + str(angry_tally) + "<br><br>")
return HttpResponse(announcement_board_output)
\ No newline at end of file
from django.urls import path from django.urls import path
from . import views from . import views
# url for homepage # url for assignments
urlpatterns = [ urlpatterns = [
path('', views.index, name='index'), path('', views.assignmentIndex, name='assignmentIndex'),
] ]
\ No newline at end of file
from django.http import HttpResponse from django.http import HttpResponse
from .models import Assignment, Course from .models import Assignment
# Create your views here.
def index(request): # assignment view from .models
def assignmentIndex(request):
title = "Widget's Assignments Page" + "<br><br>" title = "Widget's Assignments Page" + "<br><br>"
assignments = Assignment.objects.all() assignments = Assignment.objects.all()
# courses = Course.objects.all()
output_view = "" output_view = ""
for assignment in assignments: for assignment in assignments:
name = "Assignment Name: " + assignment.name + "<br>" name = "Assignment Name: " + assignment.name + "<br>"
......
from django.db import models from django.db import models
from assignments.models import Course from assignments.models import Course
#Location Choices # Location Choices
location_choices = [ location_choices = [
('onsite', 'ONSITE'), ('onsite', 'ONSITE'),
('online', 'ONLINE'), ('online', 'ONLINE'),
...@@ -11,9 +11,8 @@ location_choices = [ ...@@ -11,9 +11,8 @@ location_choices = [
# Location # Location
# mode; venue; # mode; venue;
class Location(models.Model): class Location(models.Model):
mode = models.CharField(max_length=50, choices = location_choices, default = 'onsite') mode = models.CharField(max_length = 50, choices = location_choices, default = 'onsite')
venue = models.TextField(max_length=50) venue = models.TextField(max_length = 50)
def __str__(self): def __str__(self):
return self.venue return self.venue
...@@ -21,11 +20,11 @@ class Location(models.Model): ...@@ -21,11 +20,11 @@ class Location(models.Model):
# Event # Event
# target_datetime; activity; estimated_hours; location; course # target_datetime; activity; estimated_hours; location; course
class Event(models.Model): class Event(models.Model):
target_datetime = models.DateTimeField("Date and Time: ", max_length=50) target_datetime = models.DateTimeField("Date and Time: ", max_length = 50)
activity = models.CharField("Activity: ",max_length=50) activity = models.CharField("Activity: ", max_length = 50)
estimated_hours = models.FloatField("Estimated Hours: ",max_length=50) estimated_hours = models.FloatField("Estimated Hours: ", max_length = 50)
location = models.ForeignKey(Location, on_delete=models.CASCADE) location = models.ForeignKey(Location, on_delete = models.CASCADE)
course = models.ForeignKey(Course, on_delete=models.CASCADE) course = models.ForeignKey(Course, on_delete = models.CASCADE)
def __str__(self): def __str__(self):
return self.activity return self.activity
......
from django.urls import path from django.urls import path
from . import views from . import views
# url for homepage # url for calendar
urlpatterns = [ urlpatterns = [
path('', views.calendarIndex, name='calendarIndex'), path('', views.calendarIndex, name='calendarIndex'),
] ]
\ No newline at end of file
from django.http import HttpResponse from django.http import HttpResponse
from .models import Event, Location from .models import Event, Location
# calendar view from .models
def calendarIndex(request): def calendarIndex(request):
title = 'Widget’s Calendar of Activities<br><br>' title = 'Widget’s Calendar of Activities<br><br>'
events = Event.objects.all() events = Event.objects.all()
......
from django.contrib import admin from django.contrib import admin
from .models import Department, WidgetUser
# admin panel for Department model
class DepartmentAdmin(admin.ModelAdmin):
model = Department
search_fields = ("dept_name", "home_unit",)
list_display = ("dept_name", "home_unit",)
list_filter = ("dept_name",)
# admin panel for WidgetUser model
class WidgetUserAdmin(admin.ModelAdmin):
model = WidgetUser
search_fields = ("first_name", "middle_name", "last_name", "department",)
list_display = ("first_name", "middle_name", "last_name", "department",)
admin.site.register(Department, DepartmentAdmin)
admin.site.register(WidgetUser, WidgetUserAdmin)
# Register your models here.
# Generated by Django 4.1.7 on 2023-03-05 08:41
from django.db import migrations, models
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(max_length=100)),
("home_unit", models.CharField(max_length=100)),
],
),
migrations.CreateModel(
name="WidgetUser",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("first_name", models.CharField(max_length=50)),
("middle_name", models.CharField(max_length=50)),
("last_name", models.CharField(max_length=50)),
("department", models.CharField(max_length=50)),
],
),
]
# Generated by Django 4.1.7 on 2023-03-05 08:42
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
("dashboard", "0001_initial"),
]
operations = [
migrations.AlterField(
model_name="widgetuser",
name="department",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="dashboard.department"
),
),
]
from django.db import models from django.db import models
# Create your models here. # Department
# dept_name; home_unit
class Department(models.Model):
dept_name = models.CharField(max_length = 100)
home_unit = models.CharField(max_length = 100)
def __str__(self):
return self.dept_name + ', ' + self.home_unit
# WidgetUser
# first_name; middle_name; last_name; department;
class WidgetUser(models.Model):
first_name = models.CharField(max_length = 50)
middle_name = models.CharField(max_length = 50)
last_name = models.CharField(max_length = 50)
department = models.ForeignKey(Department, on_delete = models.CASCADE)
def __str__(self):
username = self.last_name + ", " + self.first_name + " " + self.middle_name
return username
#dashboard/urls.py
from django.urls import path
from .import views
# url for dashboard
urlpatterns = [
path("", views.dashboardIndex, name = "dashboardIndex")
]
app_name = "dashboard"
\ No newline at end of file
from django.shortcuts import render from django.http import HttpResponse
from .models import Department, WidgetUser
# dashboard view from .models
def dashboardIndex(request):
users = WidgetUser.objects.all()
departments = Department.objects.all()
dashboard_output = "Welcome to Widget! <br><br> WIDGET USERS: <br><br>"
for user in users:
username = str(user)
home_department = str(user.department)
dashboard_output = dashboard_output + username + ": " + home_department + "<br>"
return HttpResponse(dashboard_output)
# Create your views here.
from django.contrib import admin from django.contrib import admin
from .models import ForumPost, Reply
# Register your models here. class ReplyInLine(admin.TabularInline):
model = Reply
# admin panel for Forum model
class ForumPostAdmin(admin.ModelAdmin):
model = ForumPost
list_display = ("title", "author", "body", "pub_datetime")
inlines = [ReplyInLine]
# admin panel for Reply model
class ReplyAdmin(admin.ModelAdmin):
list_display = ("forum_post", "author", "body", "pub_datetime")
admin.site.register(ForumPost, ForumPostAdmin)
admin.site.register(Reply, ReplyAdmin)
# Generated by Django 4.1.7 on 2023-03-06 11:20
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('dashboard', '0002_alter_widgetuser_department'),
]
operations = [
migrations.CreateModel(
name='ForumPost',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=50)),
('body', models.TextField(max_length=1000)),
('pub_datetime', models.DateTimeField(auto_now_add=True, verbose_name='Published Date and Time')),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dashboard.widgetuser')),
],
),
migrations.CreateModel(
name='Reply',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('body', models.CharField(max_length=1000)),
('pub_datetime', models.DateTimeField(auto_now_add=True, verbose_name='Published Date and Time')),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dashboard.widgetuser')),
('forum_post', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='forum.forumpost')),
],
),
]
from django.db import models from django.db import models
from dashboard.models import WidgetUser
# Create your models here. # Forum Post
# title; body; author; pub_datetime;
class ForumPost(models.Model):
title = models.CharField(max_length = 50)
body = models.TextField(max_length = 1000)
author = models.ForeignKey(WidgetUser, on_delete = models.CASCADE)
pub_datetime = models.DateTimeField("Published Date and Time", auto_now_add=True)
def __str__(self):
return self.title
# Reply
# body; author; pub_datetime; forum_post;
class Reply(models.Model):
body = models.CharField(max_length=1000)
author = models.ForeignKey(WidgetUser, on_delete=models.CASCADE)
pub_datetime = models.DateTimeField("Published Date and Time", auto_now_add=True)
forum_post = models.ForeignKey(ForumPost, on_delete=models.CASCADE)
def __str__(self):
return self.body
from django.urls import path
from . import views
# url for forum
urlpatterns = [
path("", views.forumIndex, name="forumIndex"),
]
\ No newline at end of file
from django.shortcuts import render from django.http import HttpResponse
from .models import ForumPost, Reply
# Create your views here. # forum view from .models
def forumIndex(request):
# fetch forum posts and replies
forum = ForumPost.objects.all()
replies = Reply.objects.all()
forum_output = "Widget's Forum <br><br> Forum Posts:<br>"
for post in forum:
forum_output = (forum_output + post.title + " by " + post.author.first_name + " " + post.author.last_name +
" posted " + post.pub_datetime.strftime('%m/%d/%Y, %I:%M %p') + ":<br>" +
post.body + "<br>"
)
for reply in replies:
if reply.forum_post.title == post.title:
forum_output = (forum_output + "Reply by " + reply.author.first_name + " " + reply.author.last_name
+ " posted " + reply.pub_datetime.strftime('%m/%d/%Y, %I:%M %p') + ":<br>" +
reply.body + "<br>"
)
forum_output = forum_output + "<br>"
return HttpResponse(forum_output)
...@@ -18,6 +18,9 @@ from django.urls import path, include ...@@ -18,6 +18,9 @@ from django.urls import path, include
urlpatterns = [ urlpatterns = [
path("admin/", admin.site.urls), path("admin/", admin.site.urls),
path("dashboard/", include("dashboard.urls", namespace="dashboard")),
path("assignments/", include("assignments.urls")), path("assignments/", include("assignments.urls")),
path("calendar/", include("calendar_app.urls")) path("forum/", include("forum.urls")),
path("calendar/", include("calendar_app.urls")),
path("announcements/", include("announcement_board.urls", namespace="announcement_board")),
] ]
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