Added some documentation.

This commit is contained in:
Stephan Porada
2019-03-01 20:55:41 +01:00
parent 96e84d083d
commit 27aa61d91a
37 changed files with 277 additions and 115 deletions

View File

@ -6,7 +6,8 @@ from django_tables2.utils import A # alias for Accessor
class SpeakerTable(tables.Table):
"""
Configures the table showing all speakers. Inserts a column with links to
the profile of one speaker. Also defines all shown columns.
the profile of one speaker. Also defines all shown columns. The template
speakers/table.html is imported in line 19.
"""
link = tables.LinkColumn("MdB", text="Profil", args=[A("id")],
orderable=False,

View File

@ -1,6 +1,8 @@
{% extends "blog/base.html" %}
{% load render_table from django_tables2 %}
<!-- This template creates the profile page for one speaker. -->
{% block content %}
<div class="container">
<div class="row">

View File

@ -1,6 +1,9 @@
{% extends "blog/base.html" %}
{% load render_table from django_tables2 %}
<!-- This template creates the searchable list of all speakers MdBs of the
Bundestag since 1949. -->
{% block content %}
<div class="container">
<div class="row">

View File

@ -1,5 +1,9 @@
{% load django_tables2 %}
{% load i18n %}
<!-- This template creates a table template which is used by the different table
classes defined in tables.py. Mostly used to display search results. -->
{% block table-wrapper %}
{% block table %}
<table {% render_attrs table.attrs %} class="highlight">

View File

@ -1,6 +1,10 @@
from django.urls import path
from . import views
"""
Url paths for all speakers views.
"""
urlpatterns = [
path("", views.speakers, name="MdBs"),
path("mdb/<int:id>", views.speaker, name="MdB"),

View File

@ -11,6 +11,9 @@ from speeches.forms import SearchFormSpeech
def speakers(request):
"""
This view creates the page for the searchable speakers list.
"""
if(request.method == "GET"):
form = SearchForm(request.GET)
if(form.is_valid()):
@ -30,6 +33,9 @@ def speakers(request):
def speaker(request, id):
"""
This view creates the profile page of one speaker.
"""
try:
current_speaker = Speaker.objects.get(pk=id)
speech_count = len(Speech.objects.filter(foreign_speaker=id))