Commit 6093a2f3 authored by Rau Layug's avatar Rau Layug

Merge branch 'layug/calendar' into 'master'

Layug/calendar

See merge request !11
parents ad9ba74c 34729f85
# Generated by Django 4.0.3 on 2022-05-15 09:07
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')),
('course_code', models.CharField(max_length=10)),
('course_title', models.CharField(max_length=50)),
('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=50)),
('description', models.CharField(max_length=500)),
('max_points', models.IntegerField(default=0)),
('passing_score', models.IntegerField(default=0, editable=False)),
('course_code', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='assignments.course')),
],
),
]
# Generated by Django 4.0.3 on 2022-05-15 18:33
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('calendarapp', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='location',
name='image',
field=models.ImageField(default='temp', upload_to='uploads/'),
preserve_default=False,
),
]
......@@ -12,6 +12,8 @@ class Location(models.Model):
]
mode = models.CharField(max_length=3, choices=MODE_CHOICES)
venue = models.CharField(max_length=150)
image = models.ImageField(upload_to='widget_group_25/widget_group_25/static/calendarapp/img', height_field=None, width_field=None, max_length=100)
def __str__(self):
return self.venue
......
from django.urls import path
from .views import index
from . import views
urlpatterns = [
path('', index, name='index')
path('', views.calendar, name='calendar')
]
app_name = "calendar"
from django.http import HttpResponse
from django.shortcuts import render
from .models import Event
from assignments.models import Course
# Create your views here.
def index(request):
response = "This is the Calendar page!<br><br>"
events = Event.objects.all()
def calendar(request):
return render(request, 'calendarapp/calendar.html', {'Courses': Course.objects.all().order_by('course_code'), 'Events': Event.objects.all().order_by('target_date')})
for event in events:
location = event.location
course = event.course
target_date = event.target_date
activity = event.activity
estimated_hours = event.estimated_hours
course_section = "{} {} {}".format(course.course_code,
course.course_title,
course.section)
mode = location.get_mode_display()
venue = location.venue
def events(request, id):
return render(request, 'calendarapp/events.html', {'event': Event.objects.get(id=id)})
response_string = "Target Date: {}<br>Activity: {}<br>Estimated " \
"Hours: {}<br>Course/Section: {}<br>Mode: {" \
"}<br>Venue: {}<br><br>"
response += response_string.format(target_date, activity,
estimated_hours, course_section,
mode, venue)
return HttpResponse(response)
......@@ -62,7 +62,7 @@ ROOT_URLCONF = 'widget_group_25.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': ['widget_group_25/widget_group_25/templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
......@@ -124,6 +124,9 @@ USE_TZ = True
# https://docs.djangoproject.com/en/4.0/howto/static-files/
STATIC_URL = 'static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'widget_group_25/static'),
)
# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
......
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;500;700&display=swap');
* {
box-sizing: border-box;
}
#content {
padding: 0 2em;
}
body {
background-color: aliceblue;
border: 1em solid aquamarine;
font-family: 'Roboto', sans-serif;
font-weight: 300;
color: rgb(51, 51, 51);
line-height: 1.6;
text-align: left;
margin: 0 auto;
}
b {
color: mediumpurple;
font-weight: 700;
}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>{% block title %}BASE HTML{% endblock %}</title>
{% block styles %}{% endblock %}
</head>
<body>
<div id="content">
{% block content %}This is the base html{% endblock %}
</div>
{% block scripts %}{% endblock %}
</body>
</html>
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Calendar{% endblock %}
{% block styles %}
<link rel="stylesheet" href="{% static 'calendarapp/styles.css' %}">
{% endblock %}
{% block content %}
<h1>Calendar Events Per Course</h1>
<h3>List of Courses:</h3>
<ul>
{% for course in Courses %}
<li>{{ course.course_code }} {{ course.course_title }} {{ course.section }}
<ul>
{% for event in Events %}
{% if event.course == course %}
<li><a href="http://127.0.0.1:8000/events/{{ event.id }}/details"> {{ event.activity }}, {{ event.target_date|date:"d/m/Y" }}</a></li>
{% endif %}
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Calendar{% endblock %}
{% block styles %}
<link rel="stylesheet" href="{% static 'calendarapp/styles.css' %}">
{% endblock %}
{% block content %}
<h1>{{ event.activity }}</h1>
<ul>
<li><b>Course & Section:</b> {{ event.course.course_code }} {{ event.course.course_title }} {{ event.course.section }}</li>
<li><b>Date:</b> {{ event.target_date }}</li>
<li><b>Estimated Hours:</b> {{ event.estimated_hours }} hours</li>
<li><b>Mode:</b> {{ event.location.get_mode_display }}</li>
<li><b>Venue:</b> {{ event.location.venue }}</li>
<li><b>Image:</b> <img src="{% static event.location.image.url|slice:'40:' %}" alt="{{ event.location.image.url|slice:'40:' }}" /></li>
<li><b>ID:</b> {{ event.id }}</li>
</ul>
{% endblock %}
\ No newline at end of file
......@@ -14,13 +14,15 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import include,path
from django.urls import include, path
from calendarapp import views
urlpatterns = [
path('homepage/', include('homepage.urls', namespace="homepage")),
path('announcements/', include('announcementboard.urls', namespace="announcementboard")),
path('forum/', include('forum.urls', namespace="forum")),
path('calendar/', include('calendarapp.urls', namespace="calendar")),
path('events/<int:id>/details/', views.events, name="events"),
path('assignments/', include('assignments.urls', namespace="assignments")),
path('admin/', admin.site.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