Commit 92b62429 authored by Julia Anishka's avatar Julia Anishka

fixed url format of details, add and edit announcement

parent 8aa8eb3c
from django.db import models
from django.urls import reverse
from dashboard.models import WidgetUser
......@@ -6,11 +7,14 @@ class Announcement(models.Model):
title = models.CharField(max_length = 50)
body = models.TextField(max_length = 700, null = True, blank = True)
author = models.ForeignKey(WidgetUser, on_delete = models.CASCADE)
pub_datetime = models.DateTimeField('publication date and time')
pub_datetime = models.DateTimeField('publication date and time', auto_now_add=True)
def __str__(self):
return self.title
def get_absolute_url(self):
return reverse('announcementboard:announcement-details', kwargs={'pk': self.pk})
class Reaction(models.Model):
class Choices(models.TextChoices):
like = 'Like'
......
......@@ -2,7 +2,7 @@
{% block title %} {{ announcement.title }} {% endblock %}
{% block header %}
<h1> {{ announcement.title }} </h1>
<h1> {{ announcement.title }} </h1>
{% endblock %}
{% block body %}
......@@ -14,6 +14,5 @@
<li>Love: {{ tallies.love|default:0 }}</li>
<li>Angry: {{ tallies.angry|default:0 }}</li>
</ul>
<a href="{{ announcement.get_absolute_url }}edit"> Edit Announcement </a>
<a href="{% url 'announcementboard:announcement-edit' announcement.id %}"> Edit Announcement </a>
{% endblock %}
\ No newline at end of file
......@@ -19,7 +19,7 @@
</ul>
</div>
<div>
<a href="/announcements/announcements/add/"> New Announcement </a>
<a href="/announcements/add/"> New Announcement </a>
</div>
<a href="/dashboard/"> Dashboard </a>
<a href="/forum/"> Forum </a>
......
......@@ -5,9 +5,9 @@ from .views import (AnnouncementsDetailView, AnnouncementsUpdateView, Announceme
urlpatterns = [
path('', views.announcement_view, name='announcements'),
path('announcements/<int:pk>/details/', AnnouncementsDetailView.as_view(), name='announcement-details'),
path('announcements/add/', AnnouncementsCreateView.as_view(), name='announcement-add'),
path('announcements/<int:pk>/details/edit/', AnnouncementsUpdateView.as_view(), name='announcement-edit')
path('<int:pk>/details/', AnnouncementsDetailView.as_view(), name='announcement-details'),
path('add/', AnnouncementsCreateView.as_view(), name='announcement-add'),
path('<int:pk>/edit/', AnnouncementsUpdateView.as_view(), name='announcement-edit'),
]
app_name = 'announcementboard'
\ 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