Commit 08d64f1d authored by N1o9r4b7e9r6to's avatar N1o9r4b7e9r6to

added the requirements required from the lab 3 specs

parent 49575147
# Generated by Django 4.0.3 on 2022-05-07 19:07
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('homepage', '0006_widgetuser_department'),
('forum', '0006_alter_post_author_alter_reply_author'),
]
operations = [
migrations.RemoveField(
model_name='reply',
name='active',
),
migrations.AlterField(
model_name='post',
name='author',
field=models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, to='homepage.widgetuser'),
),
migrations.AlterField(
model_name='reply',
name='author',
field=models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, to='homepage.widgetuser'),
),
migrations.AlterField(
model_name='reply',
name='post',
field=models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, to='forum.post'),
),
]
from django.db import models from django.db import models
from homepage.models import WidgetUser from homepage.models import WidgetUser
import datetime
#class date(models.Model):
#datenow = datetime.now().date()
class Post(models.Model): class Post(models.Model):
post_title = models.CharField(max_length=50) post_title = models.CharField(max_length=50)
......
h1 {
color: magenta;
border: 2px solid black;
background-color: white;
border-width: 5px 7px;
font-weight: bold;
font-family: "Gill Sans", sans-serif;
}
h2 {
color: black;
border: 2px solid dodgerblue;
background-color: lightcyan;
font-size: 25px;
margin-left: 40px;
font-weight: bold;
font-family: "Gill Sans", sans-serif;
}
h3 {
color: crimson;
background-color:greenyellow;
font-size: 25px;
border: 2px solid dodgerblue;
font-family: "Gill Sans", sans-serif;
}
p {
color: black;
font-weight: lighter;
background-color: white;
font-size: 20px;
margin-left: 40px;
border: 2px solid green;
font-family: "Gill Sans", sans-serif;
}
body {
color: black;
background-color: aqua;
margin-left: 40px;
font-family: "Gill Sans", sans-serif;
}
a:link {
color: green;
font-size: 20px;
font-weight: bold;
font-family: "Gill Sans", sans-serif;
}
a:visited {
color: blueviolet;
font-size: 20px;
font-weight: bold;
font-family: "Gill Sans", sans-serif;
}
a:hover {
color: red;
text-decoration: underline;
font-size: 20px;
font-weight: bold;
font-family: "Gill Sans", sans-serif;
}
a:active {
color: black;
text-decoration: underline;
font-size: 20px;
font-weight: bold;
font-family: "Gill Sans", sans-serif;
}
\ No newline at end of file
{% load static %}
<link rel="stylesheet" type="text/css" href="{% static 'forum/style.css' %}"
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<style>
</style>
<body>
{% block content %}
{% endblock %}
</body>
</html>
{% extends "forum/base.html" %}
{% block content %}
<h1><b> '{{post.post_title}}'</b></h1>
<p style="font-size:15px;margin-left: 20px;border:none;background-color:aqua;"> by <i>{{post.author.first_name}} {{post.author.last_name}}</i> on {{post.pub_date|date:'d/m/Y'}}</p>
<p style="font-size:30px;margin-left: 40px;border:none;background-color:aqua;">{{post.post_body}}{% load static %} </p>
<center>{% load static %} <img src="{% static img %}" style="width:450px;"/></center>
<h2>Replies:
{% for replies in reply %}
{% if replies.post.post_title == post.post_title %}
<ul><li><p><b>{{replies.author.first_name}} {{replies.author.last_name}}</b>, {{replies.pub_date|date:'d/m/Y'}}:
<br>{{replies.reply_body}}</p></li></ul>
{% endif %}
{% endfor %}
</h2>
{% endblock %}
\ No newline at end of file
{% extends "forum/base.html" %}
{% block content %}
<center><h1>This is Widget's Forum!</h1></center>
<h3>Forum Posts:</h3>
{% for posts in all_posts %}
<ul><li><a href="posts/{{ posts.id }}/details">[{{posts.post_title}}]</a> by <i>{{posts.author.first_name}} {{posts.author.last_name}}</i> dated {{posts.pub_date|date:'d/m/Y'}}: {{ post.id }}</li></ul>
{% endfor %}
<left><img src="../../static/images/twopeopletalking.jpg" alt="people talking" style="width:450px;float:left;"></left>
<center><img src="../../static/images/forum.PNG" align="left" alt="people bubbes" style="width:450px;margin-left:130px;"></center>
<right><img src="../../static/images/teachingstudents.jpg" alt="teacher teaching" style="width:450px;float:right;">
{% endblock %}
\ No newline at end of file
from django.urls import path from django.urls import path
from .views import forumposts, DisplayPostdetails, forumreplies
from .views import displayForumPosts """from .views import displayForumPosts
urlpatterns = [ urlpatterns = [
path('', displayForumPosts, name='displayForumPosts') path('', displayForumPosts, name='displayForumPosts')
]"""
urlpatterns = [
path('', forumposts, name="post"),
path('', forumreplies, name="replies"),
path('posts/<int:post_id>/details/', DisplayPostdetails, name='DisplayPostdetails'),
#path('<int:post_id>/details/', DisplayReplies, name='DisplayReply')
] ]
......
...@@ -2,6 +2,11 @@ from django.shortcuts import render ...@@ -2,6 +2,11 @@ from django.shortcuts import render
from . import models from . import models
#from asyncio.windows_events import NULL #from asyncio.windows_events import NULL
from django.http import HttpResponse from django.http import HttpResponse
from django.template import Template, Context
from django.template.loader import get_template
from forum.models import Post, Reply
"""
def displayForumPosts(request): def displayForumPosts(request):
ForumPosts = models.Post.objects.all() ForumPosts = models.Post.objects.all()
...@@ -32,3 +37,38 @@ def displayForumPosts(request): ...@@ -32,3 +37,38 @@ def displayForumPosts(request):
output += ReplyThread + "" output += ReplyThread + ""
output += "<br>" output += "<br>"
return HttpResponse('<h1>FORUM POSTS: </h1>' + output ) return HttpResponse('<h1>FORUM POSTS: </h1>' + output )
def index(request):
return HttpResponse("This is Widget's Forum!")
"""
def forumposts(request):
all_posts = models.Post.objects.order_by("-pub_date")
#all_replies = models.Reply.objects.all()
context = {
"all_posts":all_posts,
#"all_replies":all_replies
}
return render(request, "forum/forum.html", context)
def forumreplies(request):
all_replies = models.Reply.objects.all()
context = {
#"all_posts":all_posts,
"all_replies":all_replies
}
return render(request, "forum/details.html", context)
def DisplayPostdetails(request, post_id):
post = Post.objects.get(pk=post_id)
reply = Reply.objects.order_by("-pub_date")
context = {
"post":post,
"reply":reply,
"img": "images/" + str(post_id) + ".png"
}
return render(request, "forum/details.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