Commit eb72774a authored by Joshua Son's avatar Joshua Son

Update: index view is now CBV, hopefully

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