Skip to content

Commit

Permalink
add simple quiz list
Browse files Browse the repository at this point in the history
  • Loading branch information
simennj committed Jan 3, 2018
1 parent fb224fe commit 95390dd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs_quiz/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
from django.contrib import admin
from django.urls import path

from quiz.views import SearchView, QuizCreateView, QuizView, QuizResultView, QuestionCreateView
from quiz.views import SearchView, QuizCreateView, QuizListView, QuizView, QuizResultView, QuestionCreateView

urlpatterns = [
path('', SearchView.as_view()),
path('create_quiz', QuizCreateView.as_view(), name='create_quiz'),
path('create_question', QuestionCreateView.as_view(), name='create_question'),
path('quiz', QuizListView.as_view(), name='quiz_list'),
path('quiz/<slug:pk>', QuizView.as_view(), name='quiz'),
path('quiz_result/<slug:pk>', QuizResultView.as_view(), name='quiz_result'),
path('admin/', admin.site.urls),
Expand Down
16 changes: 16 additions & 0 deletions quiz/templates/quiz_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% extends 'base.html' %}
{% block content %}
<div class="ui center aligned container">
<div class="ui massive list">
{% for quiz in quiz_list %}
<div class="item">
<div class="content">
<a href="{% url 'quiz' quiz.name %}">
{{ quiz.name }}
</a>
</div>
</div>
{% endfor %}
</div>
</div>
{% endblock content %}
5 changes: 5 additions & 0 deletions quiz/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ def get(self, request, *args, **kwargs):
return self.render_to_response(context)


class QuizListView(generic.ListView):
template_name = 'quiz_list.html'
model = Quiz


class QuizView(generic.DetailView):
template_name = 'quiz.html'
model = Quiz
Expand Down

0 comments on commit 95390dd

Please sign in to comment.