Skip to content

Commit

Permalink
faq front end implementation, closes #69
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemaddem committed May 7, 2020
1 parent 39637c2 commit e537fe6
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 2 deletions.
16 changes: 16 additions & 0 deletions project-templates/support/faq_detail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% extends "base.html" %}
{% load static %}

{% block head %}
<title>FAQ #{{ faq.pk }} - {{ SITE_NAME }}</title>
{% endblock %}

{% block body %}
<h1>{{ faq.category.name }}</h1>
<h2>{{ faq.question }}</h2>
<p>{{ faq.anaswer }}</p>
<p>Creator: {{ faq.creator }}</p>
<p>Created: {{ faq.created }}, Updated: {{ faq.updated }}</p>

{% endblock %}

36 changes: 36 additions & 0 deletions project-templates/support/faq_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{% extends "base.html" %}
{% load static %}

{% block head %}
<title>FAQ - {{ SITE_NAME }}</title>
{% endblock %}

{% block body %}
{% if questions.count == 0 %}
<h2>There's nothing here yet! Check back soon!</h2>
{% endif %}

<table class="table table-hover">
<tr id="header">
<thead>
<th>Category</th>
<th>Question</th>
<th>Answer</th>
<th>Last Updated</th>
</thead>
</tr>
{% for q in questions %}
<tbody>
<tr>
<td>{{ q.category.name }}</td>
<td><a href="{% url 'support:faq_detail' pk=q.pk %}">{{ q.question }}</a></td>
<td><a href="{% url 'support:faq_detail' pk=q.pk %}">{{ q.answer|truncatewords:20 }}</a></td>
<td>{{ q.updated }}</td>
</tr>
</tbody>
{% endfor %}
</table>


{% endblock %}

4 changes: 3 additions & 1 deletion support/urls.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from django.contrib.auth.decorators import login_required
from django.urls import path

from support.views import MyTicketListView, MyTicketDetailView, TicketCreateView
from support.views import MyTicketListView, MyTicketDetailView, TicketCreateView, FAQDetail, FAQListView

app_name = 'support'

urlpatterns = [
path('', login_required(MyTicketListView.as_view()), name='list'),
path('my/<int:pk>/', login_required(MyTicketDetailView.as_view()), name='detail'),
path('create/', login_required(TicketCreateView.as_view()), name='create'),
path('faq/', FAQListView, name='faq_list'),
path('faq/<int:pk>/', FAQDetail, name='faq_detail')
]
14 changes: 13 additions & 1 deletion support/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,19 @@

from profiles.models import UserProfile
from support.forms import TicketCreateForm, TicketCommentCreateForm, TicketStatusChangeForm, ListFilterForm
from support.models import Ticket, TicketComment
from support.models import Ticket, TicketComment, QuestionAnswer, QuestionAnswerCategory


def FAQListView(request):
questions = QuestionAnswer.objects.all()
return render(request, 'support/faq_list.html',
{'questions': questions})


def FAQDetail(request, pk):
faq = get_object_or_404(QuestionAnswer, pk=pk)
template = 'support/faq_detail.html'
return render(request, template, {'faq': faq})


class MyTicketListView(View):
Expand Down

0 comments on commit e537fe6

Please sign in to comment.