Commit 6d286e50 authored by Deokhyun Lee's avatar Deokhyun Lee

Merge branch 'master' into 'forum_wip'

# Conflicts:
#   widget_aguandhischipmunks/widget_aguandhischipmunks/urls.py
parents ebcfc55a dc43d21b
.env .env
__pycache__
*.pyc
\ No newline at end of file
# Generated by Django 4.1.7 on 2023-03-06 10:10
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Course',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('code', models.CharField(max_length=10)),
('title', models.CharField(max_length=100)),
('section', models.CharField(max_length=3)),
],
),
migrations.CreateModel(
name='Assignment',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
('description', models.CharField(max_length=1000)),
('perfect_score', models.IntegerField(default=0)),
('passing_score', models.IntegerField(default=0)),
('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assignments.course')),
],
),
]
from django.contrib import admin from django.contrib import admin
from .models import Event, Location
# Register your models here. # admin panel for Location model
class LocationAdmin(admin.ModelAdmin):
model = Location
list_display = ("mode", "venue",)
search_fields = ("mode", "venue",)
list_filter = ("venue",)
# admin panel for Event model
class EventAdmin(admin.ModelAdmin):
model = Event
list_display = ("target_datetime", "activity", "estimated_hours", "course", "location",)
search_fields = ("activity", "course", "location",)
admin.site.register(Event, EventAdmin)
admin.site.register(Location, LocationAdmin)
# Generated by Django 4.1.7 on 2023-03-05 15:02
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')], default='onsite', max_length=50)),
('venue', models.TextField(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(max_length=50)),
('activity', models.CharField(max_length=50)),
('estimated_hours', models.FloatField(max_length=50)),
('course', models.CharField(default='', max_length=69)),
('location', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='calendar_app.location')),
],
),
]
# Generated by Django 4.1.7 on 2023-03-06 10:07
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('assignments', '__first__'),
('calendar_app', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='event',
name='activity',
field=models.CharField(max_length=50, verbose_name='Activity: '),
),
migrations.AlterField(
model_name='event',
name='course',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assignments.course'),
),
migrations.AlterField(
model_name='event',
name='estimated_hours',
field=models.FloatField(max_length=50, verbose_name='Estimated Hours: '),
),
migrations.AlterField(
model_name='event',
name='target_datetime',
field=models.DateTimeField(max_length=50, verbose_name='Date and Time: '),
),
]
from django.db import models from django.db import models
from assignments.models import Course
# Create your models here. #Location Choices
location_choices = [
('onsite', 'ONSITE'),
('online', 'ONLINE'),
('hybrid', 'HYBRID'),
]
# Location
# mode; venue;
class Location(models.Model):
mode = models.CharField(max_length=50, choices = location_choices, default = 'onsite')
venue = models.TextField(max_length=50)
def __str__(self):
return self.venue
# Event
# target_datetime; activity; estimated_hours; location; course
class Event(models.Model):
target_datetime = models.DateTimeField("Date and Time: ", max_length=50)
activity = models.CharField("Activity: ",max_length=50)
estimated_hours = models.FloatField("Estimated Hours: ",max_length=50)
location = models.ForeignKey(Location, on_delete=models.CASCADE)
course = models.ForeignKey(Course, on_delete=models.CASCADE)
def __str__(self):
return self.activity
#refernce for location_choices: https://stackoverflow.com/questions/31130706/dropdown-in-django-model
\ No newline at end of file
from django.urls import path
from . import views
# url for homepage
urlpatterns = [
path('', views.calendarIndex, name='calendarIndex'),
]
\ No newline at end of file
from django.shortcuts import render from django.http import HttpResponse
from .models import Event, Location
# Create your views here. def calendarIndex(request):
title = 'Widget’s Calendar of Activities<br><br>'
events = Event.objects.all()
output_view = ""
for event in events:
date_and_time = "Date and Time: " + event.target_datetime.strftime("%m/%d/%Y, %I:%M %p") + "<br>"
event_activity = "Activity: " + event.activity + "<br>"
estimated_duration = "Estimated Hours: " + str(event.estimated_hours) + "<br>"
course_section = "Course/Section: " + event.course.code + " " + event.course.title + "-" + event.course.section + "<br>"
event_mode = "Mode: " + event.location.mode + "<br>"
event_venue = "Venue: " + event.location.venue + "<br><br>"
output_view = output_view + date_and_time + event_activity + estimated_duration + course_section + event_mode + event_venue
return HttpResponse(title + output_view)
\ No newline at end of file
...@@ -21,4 +21,5 @@ urlpatterns = [ ...@@ -21,4 +21,5 @@ urlpatterns = [
path("dashboard/", include("dashboard.urls", namespace="dashboard")), path("dashboard/", include("dashboard.urls", namespace="dashboard")),
path("assignments/", include("assignments.urls")), path("assignments/", include("assignments.urls")),
path("forum/", include("forum.urls")), path("forum/", include("forum.urls")),
path("calendar/", include("calendar_app.urls"))
] ]
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