Commit ba68f516 authored by Jiuvi Anne Hu's avatar Jiuvi Anne Hu

Added correct imports and fixed miscellaneous issues.

parent e92d174c
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<a href = "/Dashboard/">Dashboard</a><br> <a href = "/Dashboard/">Dashboard</a><br>
<a href = "/forum/">Forum</a><br> <a href = "/forum/">Forum</a><br>
<a href = "/Assignments/">Assignments</a><br> <a href = "/assignments/">Assignments</a><br>
<a href = "/widget_Calendar/">Calendar</a> <a href = "/widget_Calendar/">Calendar</a>
{% endblock content %} {% endblock content %}
\ No newline at end of file
from django.urls import path from django.urls import path
from .views import index from .views import index, AnnouncementDetailView, AnnouncementAddView, AnnouncementEditView
urlpatterns = [ urlpatterns = [
path('announcements/', index, name='index'), path('announcements/', index, name='index'),
path('announcements/<int:pk>/details/', AnnouncementDetailView.as_view(), name='announcement-detail'), path('announcements/<int:pk>/details/', AnnouncementDetailView.as_view(), name='announcement-detail'),
path('announcements/add/', AnnouncementDetailView.as_view(), name='announcement-add'), path('announcements/add/', AnnouncementAddView.as_view(), name='announcement-add'),
path('announcements/<int:pk>/edit/', AnnouncementDetailView.as_view(), name='announcement-edit'), path('announcements/<int:pk>/edit/', AnnouncementEditView.as_view(), name='announcement-edit'),
] ]
app_name = "announcements" app_name = "announcements"
\ No newline at end of file
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from .models import Announcement, Reaction from .models import Announcement, Reaction
import pytz import pytz
from django.utils import timezone from django.utils import timezone
...@@ -20,13 +21,13 @@ def index(request): ...@@ -20,13 +21,13 @@ def index(request):
return render(request, 'announcements/announcements.html', context) return render(request, 'announcements/announcements.html', context)
class AnnouncementDetailView(DetailView) class AnnouncementDetailView(DetailView):
model = Announcement model = Announcement
template_name = 'announcements/announcement-detail.html' template_name = 'announcements/announcement-detail.html'
queryset = Annoucement.objects.all() queryset = Announcement.objects.all()
context_object_name = 'annoucement-details' context_object_name = 'annoucement-details'
class AnnouncementAddView(CreateView) class AnnouncementAddView(CreateView):
model = Announcement model = Announcement
fields = '__all__' fields = '__all__'
template_name = 'announcement-add.html' template_name = 'announcement-add.html'
...@@ -35,7 +36,7 @@ class AnnouncementAddView(CreateView) ...@@ -35,7 +36,7 @@ class AnnouncementAddView(CreateView)
return reverse('announcement:announcementdetailview', kwargs={'pk': self.object.id}, return reverse('announcement:announcementdetailview', kwargs={'pk': self.object.id},
current_app=self.request.resolver_match.namespace) current_app=self.request.resolver_match.namespace)
class AnnouncementEditView(UpdateView) class AnnouncementEditView(UpdateView):
model = Announcement model = Announcement
template_name = 'announcements/announcement-edit' template_name = 'announcements/announcement-edit'
......
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