Start with discussion boards
This commit is contained in:
parent
393f2689a0
commit
22ca7de96b
76
Discussions/templates/boards.html
Normal file
76
Discussions/templates/boards.html
Normal file
@ -0,0 +1,76 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}
|
||||
{{show.name}} Discussions - Episodes.Community
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<div class="container mb-5 mt-5">
|
||||
<h1>{{show.name}} Discussion Boards</h1>
|
||||
<div class="d-flex flex-row-reverse mb-4">
|
||||
{% if user.is_authenticated %}
|
||||
<a href="/show/{{show.abbr}}/discuss/board/new" class="btn btn-primary"><i class="fa fa-fw fa-pencil"></i> Create New Board</a>
|
||||
{% else %}
|
||||
<a href="/login">Log in</a> to create boards
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="bg-light rounded p-2 row">
|
||||
<div class="col">Board Name</div>
|
||||
<div class="col-2">Latest Reply</div>
|
||||
</div>
|
||||
{% for board in boards %}
|
||||
<div class="board border-bottom">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h2><a href="/show/{{show.abbr}}/discuss/board/{{board.pk}}-{{board.title|slugify}}">{{board.title}}</a></h2>
|
||||
<span class="text-muted font-weight-light">Submitted {{board.timestamp}} by
|
||||
{% if board.user.is_staff %}
|
||||
<span class="mod"><i class="fa fa-fw fa-shield"></i></span>
|
||||
{% endif %}
|
||||
<span class="display_name">{{board.user.display_name}}</span>
|
||||
</span>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<span class="text-muted font-weight-light">No replies</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% empty %}
|
||||
<h3>Nobody has started any discussions for this show!</h3>
|
||||
{% endfor %}
|
||||
|
||||
{% if boards.has_other_pages %}
|
||||
<nav aria-label="Boards navigation">
|
||||
<ul class="pagination">
|
||||
{% if boards.has_previous %}
|
||||
<li class="page-item">
|
||||
<a href="?page={{ boards.previous_page_number }}" class="page-link">Previous</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
<a class="page-link" href="#" tabindex="-1">Previous</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% for i in boards.paginator.page_range %}
|
||||
{% if boards.number == i %}
|
||||
<li class="page-item active">
|
||||
<span class="page-link">{{ i }} <span class="sr-only">(current)</span></span>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item">
|
||||
<span class="page-link" href="?page={{ i }}">{{ i }}</span>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if users.has_next %}
|
||||
<li class="page-item">
|
||||
<a href="?page={{ boards.next_page_number }}" class="page-link">Next</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
<a class="page-link" href="#" tabindex="-1">Next</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</nav>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
24
Discussions/urls.py
Normal file
24
Discussions/urls.py
Normal file
@ -0,0 +1,24 @@
|
||||
# Episodes.Community - Community-Driven TV Show Episode Link Sharing Site
|
||||
# Copyright (C) 2018 Evert "Diamond" Prants <evert@lunasqu.ee>, Taizo "Tsa6" Simpson <taizo@tsa6.net>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
from django.conf.urls import url
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', views.Boards.as_view()),
|
||||
]
|
||||
|
@ -13,7 +13,42 @@
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
from django.template import RequestContext
|
||||
from django.shortcuts import render, get_list_or_404, get_object_or_404
|
||||
from django.views import View
|
||||
from django.views.generic.base import TemplateView
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.conf import settings
|
||||
from django.http import Http404, HttpResponseForbidden, HttpResponse, HttpResponseRedirect
|
||||
from django.db.models import Case, When, Value, IntegerField, Count, F, Q
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.shortcuts import render
|
||||
from django.core.paginator import Paginator
|
||||
|
||||
# Create your views here.
|
||||
from guardian.decorators import permission_required_or_403
|
||||
|
||||
from LandingPage.models import Show, DiscussionBoard, DiscussionReply, DiscussionVote
|
||||
|
||||
class Boards(TemplateView):
|
||||
|
||||
template_name = "boards.html"
|
||||
|
||||
def get_context_data(self, abbr, **kwargs):
|
||||
ctx = super().get_context_data()
|
||||
show = get_object_or_404(Show, abbr=abbr)
|
||||
|
||||
page = self.request.GET.get('page', 1)
|
||||
|
||||
boards_list = DiscussionBoard.objects.filter(show=show)
|
||||
paginator = Paginator(boards_list, getattr(settings, "DISCUSSIONS_PER_PAGE", 26))
|
||||
try:
|
||||
boards = paginator.page(page)
|
||||
except PageNotAnInteger:
|
||||
boards = paginator.page(1)
|
||||
except EmptyPage:
|
||||
boards = paginator.page(paginator.num_pages)
|
||||
|
||||
ctx['boards'] = boards
|
||||
ctx['show'] = show
|
||||
|
||||
return ctx
|
||||
|
@ -171,3 +171,5 @@ AUTH_TOKEN_ENDPOINT = oauth_options.get('token_endpoint','https://icynet.eu/oaut
|
||||
AUTH_CLIENT_ID = oauth_options.get('client_id')
|
||||
AUTH_B64 = base64.b64encode(bytearray('%s:%s'%(AUTH_CLIENT_ID,oauth_options.get('client_secret')),'utf-8')).decode("utf-8")
|
||||
AUTH_REDIRECT_URL = oauth_options.get('redirect_url')
|
||||
|
||||
DISCUSSIONS_PER_PAGE = 26
|
||||
|
@ -36,6 +36,7 @@ from django.conf.urls.static import static
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^admin/', admin.site.urls),
|
||||
url(r'^show/(?P<abbr>\w{1,16})/discuss', include('Discussions.urls')),
|
||||
url(r'^show/(?P<abbr>\w{1,16})/', include('Show.urls')),
|
||||
url(r'^', include('LandingPage.urls'))
|
||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
Reference in New Issue
Block a user