Created a members page
This commit is contained in:
31
charter_members/templates/all.html
Normal file
31
charter_members/templates/all.html
Normal file
@ -0,0 +1,31 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block body %}
|
||||
<div class="container-fluid bg-dark-primary py-3">
|
||||
<div class="container">
|
||||
{% for chapter in chapters %}
|
||||
<div class="row bg-white mb-5">
|
||||
<div class="col-12 pt-3">
|
||||
<h2 class="text-dark-primary">{{ chapter }}</h2>
|
||||
<hr style="border-top: 1px solid rgba(0,0,0,0.2) !important">
|
||||
<div class="row">
|
||||
{% for attorney in attorneys %}
|
||||
{% if attorney.chapter == chapter %}
|
||||
<a class="col-3 text-center pt-5" href="{% url 'attorney' attorney.id %}">
|
||||
<div>
|
||||
<img class="pb-3" src="/media/{{ attorney.image }}"
|
||||
style="width: auto; max-width: 100%; height: 200px"/>
|
||||
<h5 class="text-dark-primary">{{ attorney.name }}</h5>
|
||||
<span class="text-light-primary">{{ attorney.position }}</span>
|
||||
<hr>
|
||||
</div>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
@ -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})
|
||||
|
Reference in New Issue
Block a user