Commit d489fdef authored by Junho Park's avatar Junho Park

Merge remote-tracking branch 'origin/master' into park/announcement

parents 699a22bb 40f4dcff
......@@ -2,6 +2,8 @@ from pyexpat import model
from django.db import models
from django.core.validators import RegexValidator
# Create your models here.
class Course(models.Model):
course_code = models.CharField(max_length=10)
......
h1{
color: purple;
font-weight: bold;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
p, ul{
color: darkolivegreen;
font-size: 24px;
margin-bottom: 15px;
display: block;
text-align: justify;
font-family: Georgia, 'Times New Roman', Times, serif;
}
body{
background-color: rgb(255, 225, 182);
}
a{
color: blueviolet;
}
a:visited{
color: brown;
}
a:hover{
color: orangered;
}
img{
display: block;
margin-left: auto;
margin-right: auto;
width: 50%;
}
{% load static %}
<!DOCTYPE html>
<html lang ="en">
<head>
<link rel ="stylesheet" type="text/css" href="{% static 'assignments/style.css' %}">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE-edge">
<meta name ="viewport" content="width-device width, initial scale=1.0">
<title>Assignments</title>
</head>
<body>
{% block content %}
{% endblock %}
</body>
</html>
\ No newline at end of file
{% extends "assignments/base.html" %}
{% load static %}
{% block content %}
<h1> {{assignment.course.course_code}} {{assignment.course.course_title}} {{assignment.course.section}} </h1>
<p>
{{assignment.name}} <br>
{{assignment.description}} <br>
{{assignment.max_points}} <br>
{{assignment.passing_score}} <br>
{% if assignment.id == 1 %}
<img src = "{% static 'assignments/images/history.jpg' %}" alt = "history">
{% elif assignment.id == 2 %}
<img src = "{% static 'assignments/images/koreanlang.png' %}" alt = "korean speaking">
{% else %}
<img src = "{% static 'assignments/images/yoga.jpg' %}" alt = "yoga">
{% endif %}
</p>
{% endblock %}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head></head>
<body>
<h1> ASSIGNMENTS: </h1>
{% for assignment in assignment_entries %}
<p>
Assignment Name: {{assignment.name}}<br>
Description: {{assignment.description}}<br>
Perfect Score: {{assignment.max_points}}<br>
Passing Score: {{assignment.passing_score}}<br>
Course/Section: {{assignment.course.course_code}} {{assignment.course.course_title}} | {{assignment.course.section}}
</p>
{% endfor %}
</body>
</html>
{% extends "assignments/base.html" %}
{% block content %}
<h1> Assignments Per Course </h1>
<p>
List of All Courses: <br>
{% for course in course_list %}
<ul>
<li>{{course.course_code}} {{course.course_title}} {{course.section}} </li>
{% for assignment in course.assignment_set.all %}
<ul>
<li> <a href = "{% url 'assignments:detail' assignment.id %}"> {{assignment.name}} </a> </li>
</ul>
{% endfor %}
</ul>
{% endfor %}
</p>
{% endblock %}
from django.urls import path
from django.urls import path, include
from . import views
urlpatterns = [
path('', views.index, name = 'index'),
#assignments/1/details
path("<int:assignment_id>/details/", views.detail, name='detail'),
]
app_name = "assignments"
\ No newline at end of file
from django.http import HttpResponse
from django.template import loader
from unicodedata import name
from django.http import Http404, HttpResponse
from django.shortcuts import render, redirect
from .models import Course, Assignment
# Create your views here.
def index(request):
assignments = Assignment.objects.all()
template = loader.get_template('assignments/index.html')
course_list = Course.objects.order_by("course_code")
context = {
'assignment_entries': assignments
'course_list': course_list
}
return HttpResponse(template.render(context, request))
return render(request, "assignments/index.html", context)
def detail(request, assignment_id):
try:
assignment = Assignment.objects.get(pk=assignment_id)
except Assignment.DoesNotExist:
raise Http404("Assignment does not exist!")
return render(request, "assignments/detail.html", {"assignment": assignment})
\ No newline at end of file
from django.contrib import admin
from .models import Post
from .models import Post, Reply
# Register your models here.
admin.site.register(Post)
\ No newline at end of file
admin.site.register(Post)
admin.site.register(Reply)
\ No newline at end of file
# Generated by Django 4.0.3 on 2022-04-07 17:14
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('homepage', '0002_auto_20220407_0505'),
('forum', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='post',
name='author',
field=models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.CASCADE, to='homepage.widgetuser'),
),
migrations.CreateModel(
name='Reply',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('reply_body', models.CharField(max_length=10000)),
('pub_date', models.DateTimeField(verbose_name='date published')),
('author', models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.CASCADE, to='homepage.widgetuser')),
('reply_post', models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.CASCADE, to='forum.post')),
],
),
]
# Generated by Django 4.0.3 on 2022-05-25 20:23
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('forum', '0002_post_author_reply'),
]
operations = [
migrations.AlterField(
model_name='reply',
name='reply_post',
field=models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='replies', to='forum.post'),
),
]
from django.db import models
from homepage.models import WidgetUser
# Create your models here.
......@@ -6,6 +7,16 @@ class Post(models.Model):
post_title = models.CharField(max_length=100)
post_body = models.CharField(max_length=10000)
pub_date = models.DateTimeField('date published')
author = models.ForeignKey('homepage.WidgetUser', on_delete=models.CASCADE, default=None, null=True)
def __str__(self):
return self.post_title
\ No newline at end of file
return self.post_title
class Reply(models.Model):
reply_body = models.CharField(max_length=10000)
pub_date = models.DateTimeField('date published')
reply_post = models.ForeignKey(Post, related_name="replies", on_delete=models.CASCADE, default=None, null=True)
author = models.ForeignKey('homepage.WidgetUser', on_delete=models.CASCADE, default=None, null=True)
def __str__(self):
return 'Reply to: {}' .format(self.reply_post)
\ No newline at end of file
h1 {
color: #3E2723;
font-weight: bold;
font-size: 70px;
font-family: Garamond, serif;
margin-bottom: 0px;
}
h2, li {
font-family: Garamond, serif;
color: #3E2723;
}
h3 {
color: #4E342E;
font-family: 'Times New Roman', serif;
}
p {
color:#A1887F;
font-weight: bold;
}
body {
background-color: #BCAAA4;
padding-left: 60px;
padding-right: 60px;
}
a {
color: #212121;
font-size: 20px;
list-style: none;
}
img {
border-radius: 50px;
max-width: 200px;
}
\ No newline at end of file
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="{% static "forum/style.css" %}">
<title>Widget's Forum</title>
</head>
<body>
{% block content %}
{% endblock %}
</body>
</html>
\ No newline at end of file
{% extends "forum/base.html"%}
{% load static %} <!-- need to load pictures ig -->
{% block content %}
<h1>{{ post.post_title }}</h1>
<p>by {{ post.author.first_name }} {{ post.author.last_name }}, {{ post.pub_date }}</p>
<br/>
<h3>{{ post.post_body }}</h3>
<div>
{% if post.id == 1 %}
<img src = "{% static 'forum/images/pepeWOW.jpeg' %}" alt = ":o">
{% elif post.id == 2 %}
<img src = "{% static 'forum/images/pepeBLUSH.jpeg' %}" alt = "hehe>">
{% else %}
<img src = "{% static 'forum/images/pepeTIRED.jpeg' %}" alt = "profile image">
{% endif %}
</div>
<br/>
<br/>
<h2>Comments</h2>
{% if not post.replies.all %}
No Comments Yet. :|
{% else %}
{% for reply in post.replies.all reversed %}
<li>
{{ reply.author.first_name }} {{ reply.author.last_name }},
dated {{ reply.pub_date }} -
{{ reply.reply_body }}
</li>
{% endfor %}
{% endif %}
{% endblock %}
\ No newline at end of file
{% extends "forum/base.html" %}
{% block content %}
<h1>Welcome to Widget's Forum! :)</h1>
<br/>
<h2>Forum Posts:</h2>
{% if post_list %}
<u1>
{% for post in post_list %}
<ol><a href="/forum/{{ post.id }}/details/">{{ post.post_title }} by {{ post.author.first_name }} {{ post.author.last_name }} dated {{ post.pub_date }}</a></ol>
{% endfor %}
</u1>
{% else %}
<p>No posts are available.</p>
{% endif %}
{% endblock %}
\ No newline at end of file
......@@ -2,7 +2,8 @@ from django.urls import path
from . import views
urlpatterns = [
path("", views.index, name="Forum")
path("", views.index, name="Forum"),
path("<int:post_id>/details/", views.details, name="details")
]
app_name = "forum"
\ No newline at end of file
from django.http import HttpResponse
from django.http import Http404, HttpResponse
from django.shortcuts import render
from .models import Post
# Create your views here.
def index(request):
return HttpResponse("Welcome to Widget's Forum!")
\ No newline at end of file
# forum/
def index(request):
post_list = Post.objects.order_by("pub_date")
context = {
"post_list": post_list,
}
return render(request, "forum/index.html", context)
# posts/<post_id>/details
def details(request, post_id):
try:
post = Post.objects.get(pk=post_id)
except Post.DoesNotExist:
raise Http404("Post does not exist.")
return render(request, "forum/detail.html", {"post": post})
\ No newline at end of file
body {
background-color: rgb(40, 105, 239);
font-family: 'Montserrat', serif;
color: rgb(255, 255, 255);
margin: 0;
}
header {
background-color:rgb(27, 27, 27);
color:rgb(241, 65, 65);
}
h1 {
text-transform: uppercase;
text-align: center;
padding: 10px;
margin: 0;
}
h2 {
padding: 10px;
font-weight: 700;
}
ul, ol {
font-weight: 500;
margin: 1em;
}
ul { list-style-type: none; }
li { margin: 10px 0; }
a { color: rgb(255, 255, 255); }
img { width: 400px; }
#userInfo {
display: flex;
flex-flow: row wrap-reverse;
justify-content: space-evenly;
}
#userInfo > div {
flex: 0 1 auto;
}
\ No newline at end of file
<!-- project/template/base.html -->
<!DOCTYPE html>
{% load static %}
<html lang="en">
<head>
<link rel="stylesheet" href="{% static 'homepage\style.css' %}">
<meta charset="UTF-8">
<meta name ="viewport" content="width-device width, initial scale=1">
<title> {% block title%} Homepage {% endblock %} </title>
</head>
<body>
<div id="content">
{% block content %}
{% endblock %}
</body>
</html>
\ No newline at end of file
{% extends "homepage/base.html" %}
{% load static %}
{% block title%} {{user.last_name}}, {{user.first_name}} {{user.middle_name}} {% endblock %}
{% block content %}
<header><h1> {{user.last_name}}, {{user.first_name}} {{user.middle_name}} </h1></header>
<div id="userInfo">
<div>
<ul>
<li> ID number: {{user.id_num}} </li>
<li> Email address: {{user.email}} </li>
<li> Department name: {{user.department.dept_name}} </li>
<li> Home unit: {{user.department.home_unit}} </li>
</ul>
</div>
<div>
{% if user.id_num == 201234 %}
<img src = "{% static 'homepage/images/201234.png' %}" alt = "profile image">
{% elif user.id_num == 201524 %}
<img src = "{% static 'homepage/images/201524.png' %}" alt = "profile image">
{% elif user.id_num == 204483 %}
<img src = "{% static 'homepage/images/204483.png' %}" alt = "profile image">
{% else %}
<img src = "{% static 'homepage/images/205678.png' %}" alt = "profile image">
{% endif %}
</div>
</div>
{% endblock %}
\ No newline at end of file
<!DOCTYPE html>
{% extends "homepage/base.html" %}
<html>
<head></head>
<body>
<h1> WIDGET USERS: </h1>
{% for widget_user in widget_user_entries %}
{% block content %}
<header><h1> Welcome to Widget! </h1></header>
<p>
{{widget_user.last_name}},
{{widget_user.first_name}}
{{widget_user.middle_name}}:
{{widget_user.id_num}},
{{widget_user.email}},
{{widget_user.department.dept_name}}
{{widget_user.department.home_unit}}
</p>
{% endfor %}
</body>
</html>
\ No newline at end of file
<h2>Widget Users: </h2>
{% if user_list %}
<ol>
{% for user in user_list %}
<li> <a href = "{% url 'homepage:detail' user.id_num %}">
{{user.last_name}}, {{user.first_name}} {{user.middle_name}}
</a></li>
{% endfor %}
</ol>
{% else %}
<p> No users available. </p>
{% endif %}
{% endblock %}
\ No newline at end of file
from django.urls import path
from . import views
urlpatterns = [
path("", views.index, name="homepage")
]
app_name = "homepage"
urlpatterns = [
path("", views.index, name="homepage"),
path("<int:user_id>/details", views.detail, name="detail")
]
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
from django.template import loader
from django.http import Http404, HttpResponse
from .models import WidgetUser
# Create your views here.
def index(request):
widget_users = WidgetUser.objects.all()
user_list = WidgetUser.objects.order_by("last_name")
context = {
"user_list": user_list
}
return render(request, "homepage/index.html", context)
template = loader.get_template('homepage\index.html')
context = {
'widget_user_entries': widget_users
}
return HttpResponse(template.render(context, request))
def detail(request, user_id):
try:
user = WidgetUser.objects.get(id_num = user_id)
except WidgetUser.DoesNotExist:
raise Http404("User does not exist!")
context = {
"user": user
}
return render(request, "homepage/detail.html", context)
\ 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