diff --git a/dr_botzo/urls.py b/dr_botzo/urls.py index ce22036..145ecd8 100644 --- a/dr_botzo/urls.py +++ b/dr_botzo/urls.py @@ -14,6 +14,7 @@ urlpatterns = [ url(r'^choices/', include('choices.urls')), url(r'^dispatch/', include('dispatch.urls')), + url(r'^itemsets/', include('facts.urls')), url(r'^karma/', include('karma.urls')), url(r'^markov/', include('markov.urls')), url(r'^races/', include('races.urls')), diff --git a/facts/templates/facts/base.html b/facts/templates/facts/base.html new file mode 100644 index 0000000..9abceb2 --- /dev/null +++ b/facts/templates/facts/base.html @@ -0,0 +1,4 @@ +{% extends 'base.html' %} +{% block extra_media %}{% load static %} + +{% endblock %} diff --git a/facts/templates/facts/factcategory_detail.html b/facts/templates/facts/factcategory_detail.html new file mode 100644 index 0000000..a149ca9 --- /dev/null +++ b/facts/templates/facts/factcategory_detail.html @@ -0,0 +1,11 @@ +{% extends 'facts/base.html' %} + +{% block title %}item set: {{ factcategory.name }}{% endblock %} + +{% block content %} +

{{ factcategory.name }}

+

{{ factcategory.random_fact.fact }}

+ {% if factcategory.show_all_entries %} +
Items: {{ facts|join:", " }}
+ {% endif %} +{% endblock %} diff --git a/facts/templates/facts/index.html b/facts/templates/facts/index.html new file mode 100644 index 0000000..72efb77 --- /dev/null +++ b/facts/templates/facts/index.html @@ -0,0 +1,11 @@ +{% extends 'facts/base.html' %} + +{% block title %}item sets{% endblock %} + +{% block content %} + +{% endblock %} diff --git a/facts/urls.py b/facts/urls.py new file mode 100644 index 0000000..826a334 --- /dev/null +++ b/facts/urls.py @@ -0,0 +1,9 @@ +"""URL patterns for the facts web views.""" +from django.conf.urls import url + +from facts.views import index, factcategory_detail + +urlpatterns = [ + url(r'^$', index, name='facts_index'), + url(r'^(?P.+)/$', factcategory_detail, name='facts_factcategory_detail'), +] diff --git a/facts/views.py b/facts/views.py new file mode 100644 index 0000000..3dfb112 --- /dev/null +++ b/facts/views.py @@ -0,0 +1,26 @@ +"""Display fact categories.""" +import logging + +from django.shortcuts import get_object_or_404, render + +from facts.models import FactCategory + +log = logging.getLogger(__name__) + + +def index(request): + """Display a simple list of the fact categories, for the moment.""" + factcategories = FactCategory.objects.all() + + return render(request, 'facts/index.html', {'factcategories': factcategories}) + + +def factcategory_detail(request, factcategory_name): + """Display info, and a random choice, for the fact category.""" + factcategory = get_object_or_404(FactCategory, name=factcategory_name) + + facts = [] + if factcategory.show_all_entries: + facts = [x.fact for x in factcategory.fact_set.all()] + + return render(request, 'facts/factcategory_detail.html', {'factcategory': factcategory, 'facts': facts}) diff --git a/static/css/facts.css b/static/css/facts.css new file mode 100644 index 0000000..0626d6a --- /dev/null +++ b/static/css/facts.css @@ -0,0 +1,4 @@ +.fact-category-items { + margin-top: 20px; + color: #999999; +} \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index 366370f..1f2dd6f 100644 --- a/templates/base.html +++ b/templates/base.html @@ -73,6 +73,7 @@ {% block navbar_menu %}