Commit 21470c00 authored by Joshua Son's avatar Joshua Son

Meta: committing the same files; not really any change

parent 8c64f2fe
......@@ -41,6 +41,8 @@ not part of the project itself but provides information to programmers on how
to write the program.
8. Others: if it doesn't fit in with the any of the above. <b>Avoid this subject
header as much as possible.</b>
9. Manual Merge: if you merged two branches manually. List down what branches you
merged.
### Other Guidelines
1. One commit message can have multiple subjects. For example,
......
# Generated by Django 3.2.12 on 2022-05-24 07:22
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('forum', '0004_auto_20220331_2149'),
]
operations = [
migrations.RemoveField(
model_name='post',
name='reply_chain',
),
migrations.RemoveField(
model_name='reply',
name='reply_chain',
),
migrations.AddField(
model_name='post',
name='post_image',
field=models.ImageField(null=True, upload_to=''),
),
migrations.AddField(
model_name='reply',
name='post',
field=models.ForeignKey(blank=True, default=0, on_delete=django.db.models.deletion.CASCADE, to='forum.post'),
),
migrations.AlterField(
model_name='post',
name='pub_date',
field=models.DateTimeField(auto_now_add=True, null=True),
),
]
from asyncio.windows_events import NULL
from django.db import models
# Create your models here.
class Post(models.Model):
author = models.ForeignKey('homepage.WidgetUser', on_delete=models.CASCADE)
post_image = models.ImageField(null=True)
post_title = models.CharField(max_length=100)
post_body = models.TextField()
pub_date = models.DateTimeField(auto_now_add=True)
reply_chain = models.ForeignKey('Reply', on_delete=models.CASCADE,
blank=True,null= True)
pub_date = models.DateTimeField(auto_now_add=True, null=True)
def __str__(self):
return self.post_title
......@@ -16,5 +16,4 @@ class Reply(models.Model):
author = models.ForeignKey('homepage.WidgetUser', on_delete=models.CASCADE)
reply_body = models.TextField()
pub_date = models.DateTimeField(auto_now_add=True)
reply_chain = models.ForeignKey('Reply', on_delete=models.CASCADE,
blank=True,null= True)
post = models.ForeignKey(Post, on_delete=models.CASCADE, blank=True, default=NULL)
body {
background-color: grey;
font-family: Helvetica, sans-serif;
}
{% 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> Forum </title>
</head>
<body>
{% block content %}
{% endblock %}
</body>
</html>
\ No newline at end of file
{% extends 'forum/base.html' %}
{% block content %}
<h3>Welcome to Widget's Forum!</h3>
<p> Forum Posts: </p>
{% for post in posts %}
<ul>
<li>
<p>
<a href="{% url 'Show Post Details' post.id %}">
{{ post.post_title }} by {{ post.author.first_name }} {{ post.author.last_name }} dated {{ post.pub_date|date:"d/m/Y h:i:s A" }}
</a>
</p>
</li>
</ul>
{% endfor %}
{% endblock %}
\ No newline at end of file
{% extends "forum/base.html" %}
{% block content %}
<img src="{{post.post_image.url}}">
<p><h2>{{post.post_title}}</h2></p>
<p><i>by {{post.author.first_name}} {{post.author.last_name}}, {{ post.pub_date|date:"d/m/Y h:i:s A"}}:</i></p>
<p> {{ post.post_body }} </p>
<p><b> Reply Section: </b></p>
<ul>
{% for reply in replies %}
<li>{{reply.author.first_name}} {{reply.author.last_name}}, {{ reply.pub_date|date:"d/m/Y h:i:s A"}}: {{reply.reply_body}}</li>
{% endfor %}
</ul>
{% endblock %}
\ No newline at end of file
{% extends 'forum/base.html' %}
{% block content %}
<form action="confirmation" method="POST">
{% csrf_token %}
<h3> Post Name: </h3> <input type="text" name="post_title"> <br>
<h3> Post Body: </h3> <input type="text" name="post_body"> <br>
<h3> Author ID </h3> <input type="text" name="author_id"> <br>
<input type="submit">
</form>
{% endblock %}
<h2>FORUM POSTS:</h2>
<p>
{% for post in posts %}
<p><b>{{post.post_title}}</b> by {{post.author.first_name}} {{post.author.last_name}} dated {{post.pub_date}}:</p>
<p> {{ post.post_body }} </p>
{% if post.reply_chain != NULL %}
<p> {% include "replychain_listing.html" with reply=post.reply_chain %} </p>
{% endif %}
<br>
{% endfor %}
</p>
\ No newline at end of file
<p>
<i> Reply by {{post.author.first_name}} {{post.author.last_name}} dated {{reply.pub_date|date:"d/m/Y h:i:s A"}}: </i>
</p>
<p>{{reply.reply_body}}</p>
{% if reply.reply_chain != NULL %}
<p>{% include "replychain_listing.html" with reply=reply.reply_chain %}</p>
{% endif %}
\ No newline at end of file
......@@ -2,5 +2,11 @@ from django.urls import path
from . import views
urlpatterns = [
path('', views.show_forum_page, name="Show Forum Page")
path('', views.show_index, name="Show Forum Page"),
path('post/<int:post_id>/details', views.show_post, name="Show Post Details"),
# Disabled for the time being. May be used again in the near future.
#path('post/add', views.show_form, name="Add Post Form"),
#path('post/confirmation', views.show_confirmation, name="Show confirmation"),
]
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
from django.http import Http404, HttpResponse
from .models import Post, Reply
# Create your views here.
def show_forum_page(request):
posts = Post.objects.all()
return render(request, 'post_listing.html', {'posts': posts})
\ No newline at end of file
def show_index(request):
posts = Post.objects.all().order_by("-pub_date")
return render(request, 'forum/index.html', {'posts':posts})
def show_post(request, post_id):
try:
post = Post.objects.get(pk=post_id)
except Post.DoesNotExist:
raise Http404("No such article exists.")
replies = Reply.objects.filter(post=post_id).order_by("-pub_date")
return render(request, 'forum/post_details.html', {'post':post, 'replies': replies})
# The following functions are not used for the time being. May be used again
# in the near future.
def show_form(request):
return render(request, 'forum/post_form.html', {})
def show_confirmation(request):
if (request.method == "POST"):
title = request.POST.get("post_title")
body = request.POST.get("post_body")
author = request.POST.get("author_id")
post = Post.objects.create(post_title=title,post_body=body,author_id=author)
return HttpResponse("Article saved!")
\ 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