Commit 13d6fb18 authored by Rau Layug's avatar Rau Layug

Merging with master

parents 9c1fd25f e5e74568
...@@ -13,21 +13,25 @@ class Announcement(models.Model): ...@@ -13,21 +13,25 @@ class Announcement(models.Model):
def __str__(self): def __str__(self):
return '"{}" published {}'.format(self.announcement_title, self.pub_date) return '"{}" published {}'.format(self.announcement_title, self.pub_date)
class Reaction(models.Model): class Reaction(models.Model):
announcement = models.ForeignKey( announcement = models.ForeignKey(
Announcement, Announcement,
on_delete=models.CASCADE, on_delete=models.CASCADE,
related_name='reactions' related_name='reactions'
) )
LIKE = 'Like'
LOVE = 'Love'
ANGRY = 'Angry'
REACTION_CHOICES = [ REACTION_CHOICES = [
('Like', 'Like'), (LIKE, 'Like'),
('Love', 'Love'), (LOVE, 'Love'),
('Angry', 'Angry') (ANGRY, 'Angry')
] ]
reaction_name = models.CharField( reaction_name = models.CharField(
max_length=5, max_length=5,
choices=REACTION_CHOICES, choices=REACTION_CHOICES,
default='Like' default=LIKE
) )
tally = models.IntegerField(default=1, editable=False) tally = models.IntegerField(default=1, editable=False)
......
from django.urls import path from django.urls import path
from .views import index from .views import announcement_list_view, announcement_detail_view
urlpatterns = [ urlpatterns = [
path('', index, name='index') # path('', index, name='index')
path('', announcement_list_view, name='announcement-list'),
path('<int:pk>/details', announcement_detail_view, name='announcement-detail'),
] ]
app_name = "announcementboard" app_name = "announcementboard"
\ No newline at end of file
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse from django.http import HttpResponse
from .models import Announcement from .models import Announcement
def index(request):
heading = 'ANNOUNCEMENTS:<br>' def announcement_list_view(request):
all_announcements = Announcement.objects.all() context = {}
body = '' context['object_list'] = Announcement.objects.order_by('-pub_date').all()
for announcement in all_announcements: return render(request, 'announcementboard/announcement_list.html', context)
count_like = announcement.reactions.filter(reaction_name='Like').count()
count_love = announcement.reactions.filter(reaction_name='Love').count()
count_angry = announcement.reactions.filter(reaction_name='Angry').count() def announcement_detail_view(request, pk):
body += '{} by {} {} dated {}:<br>{}<br>Like: {}<br>Love: {}<br>Angry: {}<br><br>'.format( announcement = Announcement.objects.get(pk=pk)
announcement.announcement_title, announcement.author.first_name, context = {'announcement': announcement,
announcement.author.last_name, announcement.pub_date, 'count_like': announcement.reactions.filter(reaction_name='Like').count(),
announcement.announcement_body, count_like, 'count_love': announcement.reactions.filter(reaction_name='Love').count(),
count_love, count_angry 'count_angry': announcement.reactions.filter(reaction_name='Angry').count()
) }
return HttpResponse(heading + body) return render(request, 'announcementboard/announcement_detail.html', context)
\ No newline at end of file \ No newline at end of file
# 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')),
],
),
]
...@@ -3,7 +3,8 @@ from django.urls import path ...@@ -3,7 +3,8 @@ from django.urls import path
from . import views from . import views
urlpatterns = [ urlpatterns = [
path('', views.index, name="index") path('', views.index, name="assignment-list"),
path('<int:pk>/details', views.detail, name="assignment-detail"),
] ]
app_name = "assignments" app_name = "assignments"
...@@ -5,18 +5,35 @@ from .models import Assignment, Course ...@@ -5,18 +5,35 @@ from .models import Assignment, Course
# Create your views here. # Create your views here.
def index(request): def index(request):
heading = 'ASSIGNMENTS:<br><br>' course_list = Course.objects.order_by("course_code")
assignments = Assignment.objects.all() assignments_list = Assignment.objects.order_by("name")
body = '' context = {
"course_list": course_list,
"assignments_list": assignments_list,
}
return render(request, "assignments/assignments_list.html", context)
for assignment in assignments: # heading = 'ASSIGNMENTS:<br><br>'
courses = Course.objects.filter(course_code__exact=assignment.course_code) # assignments = Assignment.objects.all()
body += 'Assignment Name: {}<br>Description: {}<br>Perfect Score: {}<br>Passing Score: {}<br>'.format( # body = ''
assignment.name, assignment.description, assignment.max_points, assignment.passing_score #
) # for assignment in assignments:
for course in courses: # courses = Course.objects.filter(course_code__exact=assignment.course_code)
body += 'Course/Section: {} {} {}<br><br>'.format( # body += 'Assignment Name: {}<br>Description: {}<br>Perfect Score: {}<br>Passing Score: {}<br>'.format(
course.course_code, course.course_title, course.section # assignment.name, assignment.description, assignment.max_points, assignment.passing_score
) # )
# for course in courses:
# body += 'Course/Section: {} {} {}<br><br>'.format(
# course.course_code, course.course_title, course.section
# )
#
# return HttpResponse(heading + body)
return HttpResponse(heading + body) def detail(request, pk):
assignment = Assignment.objects.get(pk=pk)
course = Course.objects.get(course_code__exact=assignment.course_code)
context = {
"assignment": assignment,
"course": course,
}
return render(request, "assignments/assignments_detail.html", context)
# 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,
),
]
from django.urls import path from django.urls import path
from .views import index from .views import post_list_view, post_detail_view
urlpatterns = [ urlpatterns = [
path('', index, name='index'), path('', post_list_view, name='post-list'),
path('<int:post_id>/details', post_detail_view, name='post-details'),
] ]
app_name = 'forum' app_name = 'forum'
\ No newline at end of file
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse from django.http import HttpResponse
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from .models import Post, Reply from .models import Post, Reply
def index(request):
heading = 'FORUM POSTS:<br>' def post_list_view(request):
posts = Post.objects.all() context = {}
body = '' context['post_list'] = Post.objects.order_by('-pub_date').all()
for post in posts: return render(request, 'forum/forum_list.html', context)
post_replies = Reply.objects.filter(original_post=post)
body += '{} by {} {} dated {}:<br>{}<br>'.format(
post.post_title, post.author.first_name, post.author.last_name, def post_detail_view(request, post_id):
post.pub_date, post.post_body post = Post.objects.get(id=post_id)
) reply_list = Reply.objects.filter(original_post=post).order_by('-pub_date').all()
for post_reply in post_replies: context = {'post': post,
body += 'Reply by {} {} dated {}:<br>{}<br>'.format( 'reply_list': reply_list
post_reply.author.first_name, post_reply.author.last_name, }
post_reply.pub_date, post_reply.reply_body return render(request, 'forum/forum_details.html', context)
)
body += '<br>'
return HttpResponse(heading + body)
from django.urls import path from django.urls import path
from homepage import views
from .views import index
urlpatterns = [ urlpatterns = [
path('', index, name='index'), path('', views.index, name='index'),
path('users/<str:user_id>/details', views.details, name='details'),
] ]
app_name = "homepage" app_name = "homepage"
\ No newline at end of file
from re import A, template
from django.shortcuts import render from django.shortcuts import render
from django.template import loader
from django.http import HttpResponse from django.http import HttpResponse
from .models import WidgetUser from .models import WidgetUser
# Create your views here. # Create your views here.
def index(request): def index(request):
model = WidgetUser user_list = WidgetUser.objects.order_by("last_name")
widget_users = model.objects.all() template = loader.get_template("homepage/homepage.html")
homepage_response = "WIDGET USERS: </br>" context = {
"user_list" : user_list,
}
return HttpResponse(template.render(context,request))
for user in widget_users:
homepage_response += user.get_user_info()
return HttpResponse(homepage_response) def details(request,user_id):
\ No newline at end of file user = WidgetUser.objects.get(id_num=user_id)
template = loader.get_template("homepage/details.html")
context = {
"user" : user,
}
return HttpResponse(template.render(context,request))
\ No newline at end of file
...@@ -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': ['widget_group_25/widget_group_25/templates'], 'DIRS': [os.path.join(BASE_DIR, 'widget_group_25/templates')],
'APP_DIRS': True, 'APP_DIRS': True,
'OPTIONS': { 'OPTIONS': {
'context_processors': [ 'context_processors': [
...@@ -123,10 +123,8 @@ USE_TZ = True ...@@ -123,10 +123,8 @@ 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 = ( STATICFILES_DIRS = [os.path.join(BASE_DIR, 'widget_group_25/static')]
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
......
h1 {
color: #393d3f;
font-family: 'Tahoma';
font-size: 35pt;
line-height: 10px;
}
h2 {
color: #546a7b;
font-family: 'Tahoma';
font-size: 20pt;
}
h3 {
color: #546a7b;
font-family: 'Trebuchet MS';
font-size: 16pt;
font-style: italic;
}
body {
color: #393d3f;
font-family: 'Trebuchet MS';
font-size: 12pt;
line-height: 15px;
}
img {
height: 2cm;
}
\ No newline at end of file
h1 {
color: #22223b;
font-family: 'Tahoma';
font-size: 38pt;
}
h3 {
color: #4a4e69;
font-family: 'Trebuchet MS';
font-size: 18pt;
}
body {
color: #4a4e69;
font-family: 'Trebuchet MS';
font-size: 12pt;
}
a:visited {
color: #723d46;
}
\ No newline at end of file
.center {
display: block;
margin-left: auto;
margin-right: auto;
width: 50%;
}
h1 {
color: cornflowerblue;
font-family: 'Futura';
text-align: center;
}
h3 {
color: rgb(45, 101, 205);
font-family: 'Futura';
text-align: center;
}
h4 {
color: black;
font-family: 'Futura';
text-align: center;
font-weight: 200;
}
.replies {
text-align: left;
font-family: 'Futura';
}
h2 {
font-size: 22px;
color: rgb(94, 214, 218);
}
li {
font-size: 16px;
font-weight: 100;
}
p {
color: darkslategrey;
font-size: 14px;
}
body {
background-color: rgb(221, 249, 249);
}
\ No newline at end of file
header {
color: white;
background-color: pink;
font-family: 'Futura';
font-size: 50px;
text-align: center;
}
h1 {
color: rgb(94, 214, 218);
font-family: 'Futura';
text-align: center;
}
li {
color: cornflowerblue;
font-family: 'Futura';
font-size: 18px;
text-align: center;
}
a:visited {
color: black;
}
body {
background-color: azure;
}
\ No newline at end of file
@import url('https://fonts.googleapis.com/css?family=Klavika&display=swap');
body {
background-color: rgb(227,229,231);
font-family: Helvetica, Arial, sans-serif;
}
header{
padding: 70px;
background-color:rgb(35,116,225);
margin: -9px;
margin-bottom: 0px;
}
wid {
float: left;
margin-top: 50px;
margin-left: 10px;
color: white;
font-family: Klavika, Helvetica, Arial, sans-serif;
font-size: 25px;
font-weight: bold;
}
infohead{
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
line-height: 10px;
color: black;
font-size: 20px;
line-height: 40px;
font-weight: bold;
}
info{
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
line-height: 10px;
color: black;
font-size: large;
line-height: 40px;
}
img {
border: 5px solid rgb(227,229,231);
border-radius: 50%;
float: right;
margin-top: -100px;
margin-right: 50px;
}
@import url('https://fonts.googleapis.com/css?family=Klavika&display=swap');
body {
background-color: rgb(227,229,231);
}
header {
margin-top: -10px;
margin-left: -10px;
margin-right: -10px;
padding: 30px;
background-color: rgb(35,116,225);
text-align: center;
color: white;
font-size: 200%;
font-family: Klavika, Arial, Helvetica, sans-serif;
font-weight: bold;
}
p {
color: black;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif, Arial, sans-serif;
text-align: center;
}
wu {
font-size: 25px;
font-weight: 500;
}
a {
color: black;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
text-decoration: none;
font-size: large;
}
{% extends 'base.html' %}
{% load static %}
{% block title %}{{ announcement.announcement_title }}{% endblock %}
{% block styles %}
<link rel="stylesheet" href="{% static 'announcementboard/css/detail_styles.css' %}">
{% endblock %}
{% block content %}
{% if announcement.id == 1 or announcement.id == 4 %}
<img src="{% static 'announcementboard/css/quiz.png' %}" alt="quiz">
{% endif %}
{% if announcement.id == 2 %}
<img src="{% static 'announcementboard/css/laptop.png' %}" alt="synch">
{% endif %}
{% if announcement.id == 3 %}
<img src="{% static 'announcementboard/css/project.png' %}" alt="project">
{% endif %}
<h1>{{ announcement.announcement_title }}</h1>
<h2>
by {{ announcement.author.first_name }} {{ announcement.author.last_name }}, {{ announcement.pub_date|date:'d/m/Y' }}
</h2>
{{ announcement.announcement_body }}
<h3>Reactions:</h3>
Like: {{ count_like }}<br>
Love: {{ count_love }}<br>
Angry: {{ count_angry }}
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Announcement Board{% endblock %}
{% block styles %}
<link rel="stylesheet" href="{% static 'announcementboard/css/list_styles.css' %}">
{% endblock %}
{% block content %}
<h1>Announcement Board</h1>
<h3>Important announcements:</h3>
{% for object in object_list %}
<li>
<a href="{% url 'announcementboard:announcement-detail' pk=object.pk %}">
{{ object.announcement_title }} by {{ object.author.first_name }} {{ object.author.last_name }} dated {{ object.pub_date|date:"d/m/Y" }}
</a>
</li>
{% endfor %}
{% endblock %}
{% extends 'base.html' %}
{% load static %}
{% block title %}Assignments{% endblock %}
{% block styles %}
<link rel="stylesheet" href="{% static 'assignments/css/list_styles.css' %}">
{% endblock %}
{% block content %}
<h1>{{ assignment.name }}</h1>
<ul>
<li><b>Course & Section:</b> {{ course.course_code }} {{ course.course_title }} {{ course.section }}</li>
<li><b>Description:</b> {{ assignment.description }}</li>
<li><b>Perfect score:</b> {{ assignment.max_points }}</li>
<li><b>Passing score:</b> {{ assignment.passing_score }}</li>
<li><img src="{% static 'assignments/css/assignment.png' %}" alt="assignment"></li>
</ul>
{% endblock %}
{% extends 'base.html' %}
{% load static %}
{% block title %}Assignments{% endblock %}
{% block styles %}
<link rel="stylesheet" href="{% static 'assignments/css/list_styles.css' %}">
{% endblock %}
{% block content %}
<header>
<h1>Assignments Per Course</h1>
</header>
<p>
<ul>
{% for course in course_list %}
<li>{{ course.course_code }} {{ course.course_title }} {{ course.section }}
<ul>
{% for assignment in assignments_list %}
{% if assignment.course_code == course %}
<li><a href="{% url 'assignments:assignment-detail' pk=assignment.pk %}">{{ assignment.name }}</a></li>
{% endif %}
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
</p>
{% endblock %}
<!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <link rel="stylesheet" href="styles.css">
<meta name="viewport" <title>{% block title %}{% endblock %}</title>
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 %} {% block styles %}{% endblock %}
</head> </head>
<body> <body>
......
{% extends 'base.html' %}
{% load static %}
{% block title %}{{ post.post_title }}{% endblock %}
{% block styles %}
<link rel="stylesheet" href="{% static 'forum/css/forum_details_styles.css' %}">
{% endblock %}
{% block content %}
<body>
{% if post.id == 1 %}
<img src="{% static 'forum/img/GitBranchCreate.png' %}" alt="create branch" class="center">
{% endif %}
{% if post.id == 2 %}
<img src="{% static 'forum/img/GitCheckout.png' %}" alt="switch branch" class="center">
{% endif %}
{% if post.id == 3 %}
<img src="{% static 'forum/img/GitBranch.png' %}" alt="view branch" class="center">
{% endif %}
<h1>{{ post.post_title }}</h1>
<h3>
by {{ post.author.first_name }} {{ post.author.last_name }}, {{ post.pub_date|date:'d/m/Y' }}
</h3>
<h4>
{{ post.post_body }}
</h4>
<div class="replies">
<h2>Replies:</h2>
{% for reply in reply_list %}
<li>
{{ reply.author.first_name }} {{ reply.author.last_name }}, {{ reply.pub_date|date:'d/m/Y' }} :
</li>
<p>{{ reply.reply_body }}</p>
{% endfor %}
</div>
</body>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Forum{% endblock %}
{% block styles %} <link rel="stylesheet" href="{% static 'forum/css/forum_list_styles.css' %}"> {% endblock %}
{% block content %}
<body>
<header> Welcome to Widget’s Forum! </header>
<h1>Forum posts:</h1>
{% for post in post_list %}
<li>
<a href="{% url 'forum:post-details' post_id=post.pk %}">
{{ post.post_title }} by {{ post.author.first_name }} {{ post.author.last_name }} dated {{ post.pub_date|date:"d/m/Y" }}
</a>
</li>
{% endfor %}
</body>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %} User Details {% endblock %}
{% block styles %} <link rel="stylesheet" href="{% static 'homepage/css/details.css' %}"> {% endblock %}
{% block content %}
<wid>{{user.last_name}}, {{user.first_name}} {{user.middle_name}}</wid>
<header></header>
<img src="{% static 'homepage/img/profile-picture.jpg' %}" alt="Profile Picture">
<infohead>User Details</br></infohead>
<info>
ID number: {{user.id_num}} </br>
Email address: {{user.email}} </br>
Department name: {{user.department}} </br>
Home unit: {{user.department.home_unit}} </br>
</info>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %} Homepage {% endblock %}
{% block styles %} <link rel="stylesheet" href="{% static 'homepage/css/homepage.css' %}"> {% endblock %}
{% block content %}
<header> Welcome to the Widget! </header>
<p>
<wu> Widget Users: </wu>
<ol type = '1'>
{% for user in user_list %}
<a href = "{% url 'homepage:details' user.id_num %}">
<li>{{user.last_name}}, {{user.first_name}} {{user.middle_name}} </br> </a> </li> </p>
{% endfor %}
</ol>
{% endblock %}
\ 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