Commit 690fa709 authored by Rau Layug's avatar Rau Layug

Added calendarapp calendar and events templates

parent 2aade1d3
# 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-04-02 19:29 # Generated by Django 4.0.3 on 2022-05-15 09:07
from django.db import migrations, models from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
......
# 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): ...@@ -12,6 +12,8 @@ class Location(models.Model):
] ]
mode = models.CharField(max_length=18, choices=MODE_CHOICES) mode = models.CharField(max_length=18, choices=MODE_CHOICES)
venue = models.CharField(max_length=150) 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): def __str__(self):
return self.venue return self.venue
......
from django.urls import path from django.urls import path
from .views import index from . import views
urlpatterns = [ urlpatterns = [
path('', index, name='index') path('', views.calendar, name='calendar')
] ]
app_name = "calendar" app_name = "calendar"
from django.http import HttpResponse from django.http import HttpResponse
from django.shortcuts import render
from .models import Event from .models import Event
from assignments.models import Course
# Create your views here. # Create your views here.
def index(request): def calendar(request):
response = "This is the Calendar page!<br><br>" return render(request, 'calendarapp/calendar.html', {'Courses': Course.objects.all().order_by('course_code'), 'Events': Event.objects.all().order_by('target_date')})
events = Event.objects.all()
for event in events:
location = event.location
course = event.course
target_date = event.target_date def events(request, id):
activity = event.activity return render(request, 'calendarapp/events.html', {'event': Event.objects.get(id=id)})
estimated_hours = event.estimated_hours
course_section = "{} {} {}".format(course.course_code,
course.course_title, course.section)
mode = location.get_mode_display()
venue = location.venue
response += "Target Date: {}<br>Activity: {}<br>Estimated Hours: {}<br>Course/Section: {}<br>Mode: {}<br>Venue: {}<br><br>".format(
target_date, activity, estimated_hours, course_section, mode,
venue)
return HttpResponse(response)
def index_view(request):
return render(request, 'index.html', {'name': Rau})
...@@ -62,7 +62,7 @@ ROOT_URLCONF = 'widget_group_25.urls' ...@@ -62,7 +62,7 @@ ROOT_URLCONF = 'widget_group_25.urls'
TEMPLATES = [ TEMPLATES = [
{ {
'BACKEND': 'django.template.backends.django.DjangoTemplates', 'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [], 'DIRS': ['widget_group_25/widget_group_25/templates'],
'APP_DIRS': True, 'APP_DIRS': True,
'OPTIONS': { 'OPTIONS': {
'context_processors': [ 'context_processors': [
...@@ -123,8 +123,10 @@ USE_TZ = True ...@@ -123,8 +123,10 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images) # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/ # https://docs.djangoproject.com/en/4.0/howto/static-files/
STATIC_URL = '/static/' STATIC_URL = 'static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'project/static')] STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'widget_group_25/static'),
)
# Default primary key field type # Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field # 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
{% extends 'base.html' %}
{% load static %}
{% block title %}Index Card{% endblock %}
{% block styles %}
<link rel="stylesheet" href="{% static 'css/styles.css' %">
{% endblock %}
{% block content %}
<form action="/index_card" method="post">
{% csrf_token %}
{{ form }}
<input type="submit" value="Submit">
</form>
\ 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 ...@@ -14,13 +14,15 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 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
from calendarapp import views
urlpatterns = [ urlpatterns = [
path('homepage/', include('homepage.urls', namespace="homepage")), path('homepage/', include('homepage.urls', namespace="homepage")),
path('announcements/', include('announcementboard.urls', namespace="announcementboard")), path('announcements/', include('announcementboard.urls', namespace="announcementboard")),
path('forum/', include('forum.urls', namespace="forum")), path('forum/', include('forum.urls', namespace="forum")),
path('calendar/', include('calendarapp.urls', namespace="calendar")), path('calendar/', include('calendarapp.urls', namespace="calendar")),
path('events/<int:id>/details/', views.events, name="events"),
path('assignments/', include('assignments.urls', namespace="assignments")), path('assignments/', include('assignments.urls', namespace="assignments")),
path('admin/', admin.site.urls) 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