Commit eb72774a authored by Joshua Son's avatar Joshua Son

Update: index view is now CBV, hopefully

parent 411e7579
......@@ -22,6 +22,6 @@
</form>
<br>
<br>
<a href="{% url 'index' %}"> Go back </a>
<a href="{% url 'showAnnouncements' %}"> Go back </a>
{% endblock %}
\ No newline at end of file
from django.urls import path
from . import views
from django.conf import settings
from .views import showAnnouncements
urlpatterns = [
path('', views.index, name='index'),
path('', showAnnouncements.as_view(), name='showAnnouncements'),
path("<int:announcement_id>/", views.detail, name="detail"),
path("add/", views.add, name="add"),
#path("add/newAnnounce", views.newAnnounce, name="newAnnounce")
......
......@@ -5,6 +5,7 @@ from .models import Announcement, Reaction
from homepage.models import WidgetUser
import datetime
from .forms import AnnouncementForm
from django.views import View
# Create your views here.
......@@ -15,6 +16,14 @@ def index(request):
}
return render(request, "announcement/announcement_page.html", context)
class showAnnouncements(View):
def get(self, request):
announce_list = Announcement.objects.order_by("pub_date")
context = {
"announce_list": announce_list,
}
return render(request, "announcement/announcement_page.html", context)
def add(request):
author = WidgetUser.objects.all()
context = {
......
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