From 1c1b56722ca3e74e4dcaffc54f9cd6ec34e191fc Mon Sep 17 00:00:00 2001 From: Zak Timson Date: Sun, 14 Jan 2018 17:55:35 -0500 Subject: [PATCH] Created a members page --- OACPL/urls.py | 1 + charter_members/templates/all.html | 31 ++++++++++++++++++++++++++++++ charter_members/views.py | 9 ++++++++- main/templates/index.html | 3 +++ static/main/css/index.css | 2 +- templates/base.html | 12 +++++++----- 6 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 charter_members/templates/all.html diff --git a/OACPL/urls.py b/OACPL/urls.py index 7447e14..0ea8221 100644 --- a/OACPL/urls.py +++ b/OACPL/urls.py @@ -37,6 +37,7 @@ urlpatterns = [ url(r'^logout/', main.views.logout, name='logout'), url(r'^media/secure/(?P.*)$', protected_serve, {'document_root': os.path.join(settings.MEDIA_ROOT, 'secure')}, name='secure media'), url(r'^media/(?P.*)$', serve, {'document_root': settings.MEDIA_ROOT}, name='media'), + url(r'^members', charter_members.views.all, name='members'), url(r'^newsletter/unsubscribe', newsletters.views.unsubscribe, name='unsubscribe'), url(r'^newsletter/', newsletters.views.newsletters, name='newsletters'), url(r'^tinymce/', include('tinymce.urls')) diff --git a/charter_members/templates/all.html b/charter_members/templates/all.html new file mode 100644 index 0000000..ed0316e --- /dev/null +++ b/charter_members/templates/all.html @@ -0,0 +1,31 @@ +{% extends 'base.html' %} + +{% block body %} +
+
+ {% for chapter in chapters %} +
+
+

{{ chapter }}

+
+
+ {% for attorney in attorneys %} + {% if attorney.chapter == chapter %} + +
+ +
{{ attorney.name }}
+ {{ attorney.position }} +
+
+
+ {% endif %} + {% endfor %} +
+
+
+ {% endfor %} +
+
+{% endblock %} diff --git a/charter_members/views.py b/charter_members/views.py index 33c73fd..56983af 100644 --- a/charter_members/views.py +++ b/charter_members/views.py @@ -1,8 +1,15 @@ +from django.db.models import Count from django.shortcuts import render -from .models import Attorney +from .models import Chapter, Attorney def index(request, id): attorney = Attorney.objects.get(id=id) return render(request, 'attorney.html', {'attorney': attorney}) + + +def all(request): + chapters = Chapter.objects.all().order_by('name') + attorneys = Attorney.objects.all().annotate(Count('chapter')) + return render(request, 'all.html', {'chapters': chapters, 'attorneys': attorneys}) diff --git a/main/templates/index.html b/main/templates/index.html index a8f63f7..3398170 100644 --- a/main/templates/index.html +++ b/main/templates/index.html @@ -143,6 +143,9 @@ {% endfor %} +
+ View All +
{% endif %} diff --git a/static/main/css/index.css b/static/main/css/index.css index 2031286..49334e7 100644 --- a/static/main/css/index.css +++ b/static/main/css/index.css @@ -22,7 +22,7 @@ body { } hr { - border-top: 1px solid #377DBD !important; + border-top: 1px solid #377DBD; } ul { diff --git a/templates/base.html b/templates/base.html index 6797570..b87b9d9 100644 --- a/templates/base.html +++ b/templates/base.html @@ -42,11 +42,13 @@