Commit 539eed5e authored by Joshua Son's avatar Joshua Son

Test: Announcement test code

parent 41001228
h1 {
color: purple;
font-weight:bold;
}
p {
color: orange;
font-weight:bold;
}
body {
background-color: beige;
}
a {
color: orangered;
}
\ No newline at end of file
{% extends "announcement/base.html" %}
{% block content %}
<h1> {{ announcement.announcement_title }} </h1>
<p> <em> by {{ announcement.author.first_name}} {{announcement.author.last_name}}, {{announcement.pub_date}} </em> </p>
<p> {{announcement.announcement_body</p>
<p> {% include "announcement/reactions_list.html" with reactions=announcement.reaction_list %}</p>
{% endblock %}
\ No newline at end of file
{% extends "announcement/base.html" %}
{% block content %}
<h1> Important Announcements </h1>
{% if announce_list %}
<ul>
{% for announce in announce_list %}
<l1> <a href = "{% url 'detail' announce.id %}"></a></l1>
{% endfor %}
</ul>
{% else %}
<p> No announcements here! </p>
{% endif %}
{% endblock %}
\ 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 'announcement/style.css' %}">
<title>Announcements</title>
</head>
<body>
{% block content %}
{% endblock %}
</body>
</html>
\ No newline at end of file
<p> <p>
<p>{{ reactions.reaction_name }} : {{reactions.tally}}</p> <p>{{ reactions.reaction_name }} : {{reactions.tally}}</p>
{% if reactions.reaction_self != NULL %} {% if reactions.reaction_self != NULL %}
<p>{% include "reactions_list.html" with reactions=reactions.reaction_self %}</p> <p>{% include "announcement/reactions_list.html" with reactions=reactions.reaction_self %}</p>
{% endif %} {% endif %}
......
<p>
<h2>ANNOUNCEMENTS: </h2>
{% for announcement in announcements%}
<p><b>{{announcement.announcement_title}}</b> by {{announcement.author.first_name}} {{announcement.author.last_name}} dated {{announcement.pub_date}}</p>
<p>{{announcement.announcement_body}}</p>
<p>{% include "reactions_list.html" with reactions=announcement.reaction_list %}</p>
{{ value|linebreaks }}
{% endfor %}
</p>
\ No newline at end of file
...@@ -3,5 +3,6 @@ from django.urls import path ...@@ -3,5 +3,6 @@ from django.urls import path
from . import views from . import views
urlpatterns = [ urlpatterns = [
path('', views.show_announcements, name='show_announcements') path('', views.index, name='index'),
path("<int:announcement_id>", views.detail, name="detail"),
] ]
\ No newline at end of file
from django.http import HttpResponse from django.http import HttpResponse, Http404
from django.shortcuts import render from django.shortcuts import render
from .models import Announcement, Reaction from .models import Announcement, Reaction
# Create your views here. # Create your views here.
def show_announcements(request): #def show_announcements(request):
announcement = Announcement.objects.all() #announcement = Announcement.objects.all()
return render(request, 'announcement_board.html', {'announcements': announcement}) #return render(request, 'announcement/announcement_board.html', {'announcements': announcement})
\ No newline at end of file
def index(request):
announce_list = Announcement.objects.order_by("pub_date")
context = {
"announce_list": announce_list,
}
return render(request, "announcement/announcement_page.html", context)
def detail(request, announcement_id):
try:
announce = Announcement.objects.get(pk=announcement_id)
except Announcement.DoesNotExist:
raise Http404("Announcement does not exist!")
return render(request, "announcement/announcement_board.html", {"announce": announce})
\ 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