Commit 1bb55877 authored by Neal Berones's avatar Neal Berones

converted announcements index view into CBV, tested populating announcements model using forms

parent 3c4a7fcf
p{
color: white;
color: black;
font-weight: bold;
font-family: Helvetica;
font-size:25px;
......@@ -7,12 +7,12 @@ p{
h1 {
position: sticky;
text-align: left;
color: white;
color: black;
font-size: 55px;
font-family: Helvetica;
}
body {
background-image: url("/static/bg.png");
background-image: url("/static/announcements/bg.png");
background-repeat: no-repeat;
background-size: cover;
background-position: center;
......@@ -20,14 +20,14 @@ body {
font-family: Helvetica;
}
a{
color: white;
color: black;
font-family: Helvetica;
font-weight: bold;
}
ol {
font-size:35px;
font-family: Helvetica;
color:white;
color:black;
font-weight: bold;
}
a:link {
......
......@@ -3,7 +3,7 @@ from . import views
app_name = "announcements"
urlpatterns = [
path('', views.index, name='index'),
path('', views.IndexView.as_view(), name='index'),
path('add/', views.add, name='add'),
path('<int:announcement_id>/details', views.detail, name="detail")
#path('welcome', views.welcome, name='welcome')
......
......@@ -4,8 +4,15 @@ from django.shortcuts import render, redirect
from .models import WidgetUser, Announcement, Reaction
from .forms import AnnouncementForm
from django.template import loader
from django.views import View
# Create your views here.
class IndexView(View):
def get(self,request):
announcements_list = Announcement.objects.all().order_by("pub_date")
return render(request, "announcements/index.html", {"announcements_list":announcements_list})
'''
def index(request):
announcements_list = Announcement.objects.all().order_by("pub_date")
#template = loader.get_template("announcements/index.html")
......@@ -13,7 +20,7 @@ def index(request):
"announcements_list":announcements_list
}
return render(request, "announcements/index.html", context)
'''
#HttpResponse(template.render(context, request))
def detail(request, announcement_id):
......
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