Commit ccee7e03 authored by Alia Lawraine Olay's avatar Alia Lawraine Olay

Merge branch 'olay/announcementboard'

parents 1c633889 4bde8a3b
from django import forms
from .models import Announcement
class AnnouncementForm(forms.ModelForm):
class Meta:
model = Announcement
fields = [
'announcement_title',
'announcement_body',
'author',
]
\ No newline at end of file
from django.urls import path from django.urls import path
from .views import announcement_list_view, announcement_detail_view from .views import AnnouncementListView, AnnouncementCreateView, announcement_detail_view
urlpatterns = [ urlpatterns = [
# path('', index, name='index') path('', AnnouncementListView.as_view(), name='announcement-list'),
path('', announcement_list_view, name='announcement-list'), path('<int:pk>/details/', announcement_detail_view, name='announcement-detail'),
path('<int:pk>/details', announcement_detail_view, name='announcement-detail'), path('add/', AnnouncementCreateView.as_view(), name='announcement-create'),
] ]
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.urls import reverse
from django.views.generic.list import ListView
from django.views.generic.edit import CreateView
from .models import Announcement from .models import Announcement
def announcement_list_view(request): class AnnouncementListView(ListView):
context = {} queryset = Announcement.objects.order_by('-pub_date')
context['object_list'] = Announcement.objects.order_by('-pub_date').all()
return render(request, 'announcementboard/announcement_list.html', context)
class AnnouncementCreateView(CreateView):
model = Announcement
fields = '__all__'
def get_success_url(self):
return reverse('announcementboard:announcement-list')
def announcement_detail_view(request, pk): def announcement_detail_view(request, pk):
announcement = Announcement.objects.get(pk=pk) announcement = Announcement.objects.get(pk=pk)
......
h1 {
color: #33415c;
border-bottom: solid;
font-family: 'Tahoma';
font-size: 40pt;
}
h4 a{
background-color: #dae8ea;
padding: 15px;
text-decoration: none;
border-style: solid;
}
body {
background-color: #fefefe;
font-family: 'Trebuchet MS';
font-size: 12pt;
padding: 20pt;
}
p{
padding-left: 15pt;
color: #8e574c;
}
a:link {
color: #33415c;
text-decoration: none;
}
a:visited {
color: #5c677d;
}
#submit_button{
background-color: white;
font-family: 'Trebuchet MS';
color: #33415c;
border-color: #33415c;
}
\ No newline at end of file
h1 { h1 {
color: #393d3f; color: #fefefe;
background-color: #6c7a84;
font-family: 'Tahoma'; font-family: 'Tahoma';
font-size: 35pt; font-size: 35pt;
line-height: 10px; line-height: 70pt;
padding-left: 10pt;
} }
h2 { h2{
color: #546a7b; color: #4f5b63;
font-family: 'Tahoma'; font-size: 25pt;
font-size: 20pt; line-height: 0pt;
padding-left: 10pt;
} }
h3 { h3 {
color: #546a7b; color: #8e574c;
font-family: 'Trebuchet MS';
font-size: 16pt;
font-style: italic; font-style: italic;
font-family: 'Trebuchet MS';
font-size: 18pt;
line-height: 0pt;
padding-left: 15pt;
}
h4 a{
background-color: #d4d9da;
padding: 15px;
text-decoration: none;
border-style: solid;
} }
body { body {
color: #393d3f; background-color: #fefefe;
font-family: 'Trebuchet MS'; font-family: 'Trebuchet MS';
font-size: 12pt; font-size: 12pt;
line-height: 15px;
} }
img { p{
height: 2cm; padding-left: 20pt;
color: rgb(51, 53, 53);
}
a:link {
color: #33415c;
text-decoration: none;
}
a:visited {
color: #5c677d
}
img{
height: 80px;
float: left;
padding-left: 10pt;
padding-right: 10pt;
padding-top: 5pt;
} }
\ No newline at end of file
h1 { h1 {
color: #22223b; color: #454545;
background-color: #93b7be;
font-family: 'Tahoma'; font-family: 'Tahoma';
font-size: 38pt; font-size: 45pt;
line-height: 80pt;
text-align: center;
} }
h3 { h3 {
color: #4a4e69; color: #4a4e69;
font-family: 'Trebuchet MS'; font-family: 'Trebuchet MS';
font-size: 18pt; font-size: 25pt;
line-height: 10pt;
}
h4 a{
background-color: #dae8ea;
padding: 15px;
text-decoration: none;
border-style: solid;
} }
body { body {
color: #4a4e69; background-color: #fefefe;
font-family: 'Trebuchet MS'; font-family: 'Trebuchet MS';
font-size: 12pt; font-size: 12pt;
} }
a:visited { ul{
margin-left: 15px;
line-height: 30px;
}
a:link {
color: #33415c;
text-decoration: none;
}
a:hover {
color: #723d46; color: #723d46;
} }
a:visited {
color: #5c677d
}
\ No newline at end of file
...@@ -21,10 +21,14 @@ ...@@ -21,10 +21,14 @@
<h2> <h2>
by {{ announcement.author.first_name }} {{ announcement.author.last_name }}, {{ announcement.pub_date|date:'d/m/Y' }} by {{ announcement.author.first_name }} {{ announcement.author.last_name }}, {{ announcement.pub_date|date:'d/m/Y' }}
</h2> </h2>
{{ announcement.announcement_body }} <p>{{ announcement.announcement_body }}</p>
<h3>Reactions:</h3> <br><h3>Reactions</h3>
<p>
Like: {{ count_like }}<br> Like: {{ count_like }}<br>
Love: {{ count_love }}<br> Love: {{ count_love }}<br>
Angry: {{ count_angry }} Angry: {{ count_angry }}
</p>
<br><br><br>
<h4><a href="{% url 'announcementboard:announcement-list' %}">Back to Announcement Board</a></h4>
{% endblock %} {% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %}Create Announcement{% endblock %}
{% block styles %}
<link rel="stylesheet" href="{% static 'announcementboard/css/create_styles.css' %}">
{% endblock %}
{% block content %}
<h1>New Announcement</h1>
<p>
<form method="POST">
{% csrf_token %}
<label for="{{ form.announcement_title.id_for_label }}">Announcement Title</label><br>
{{ form.announcement_title }}<br><br>
<label for="{{ form.announcement_body.id_for_label }}">Announcement Body</label><br>
{{ form.announcement_body }}<br><br>
<label for="{{ form.authot.id_for_label }}">Author</label><br>
{{ form.author }}<br><br>
<input type="submit" value="Save Announcement" id="submit_button">
</form>
</p>
<br><h4><a href="{% url 'announcementboard:announcement-list' %}">Back to Announcement Board</a></h4>
{% endblock %}
...@@ -10,12 +10,16 @@ ...@@ -10,12 +10,16 @@
{% block content %} {% block content %}
<h1>Announcement Board</h1> <h1>Announcement Board</h1>
<h3>Important announcements:</h3> <h3>Important Announcements</h3>
{% for object in object_list %} <ul>
{% for object in object_list %}
<li> <li>
<a href="{% url 'announcementboard:announcement-detail' pk=object.pk %}"> <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" }} {{ object.announcement_title }} by {{ object.author.first_name }} {{ object.author.last_name }} dated {{ object.pub_date|date:"d/m/Y" }}
</a> </a>
</li> </li>
{% endfor %} {% endfor %}
</ul>
<br>
<h4><a href="{% url 'announcementboard:announcement-create' %}">Add New Announcement</a></h4>
{% endblock %} {% endblock %}
<html lang="en"> <html lang="en">
<head> <head>
<link rel="stylesheet" href="styles.css">
<title>{% block title %}{% endblock %}</title> <title>{% block title %}{% endblock %}</title>
{% block styles %}{% endblock %} {% block styles %}{% endblock %}
</head> </head>
......
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