Add better show url formation method
This commit is contained in:
parent
028b1ab279
commit
e59c03539d
@ -9,8 +9,8 @@
|
||||
<div class="container mb-5 mt-5">
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="{{showurl}}">{{show.name}}</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{showurl}}/discuss">Discussions</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{show.url}}">{{show.name}}</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{show.url}}/discuss">Discussions</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">{{board.title}}</li>
|
||||
</ol>
|
||||
</nav>
|
||||
@ -22,7 +22,7 @@
|
||||
<p>This board is locked</p>
|
||||
{% else %}
|
||||
{% if user.is_authenticated %}
|
||||
<a href="{{showurl}}/discuss/board/reply/{{board.pk}}" class="btn btn-primary"><i class="fa fa-fw fa-pencil"></i> Reply</a>
|
||||
<a href="{{show.url}}/discuss/board/reply/{{board.pk}}" class="btn btn-primary"><i class="fa fa-fw fa-pencil"></i> Reply</a>
|
||||
{% else %}
|
||||
<p><a href="/login">Log in</a> to reply</p>
|
||||
{% endif %}
|
||||
@ -38,8 +38,8 @@
|
||||
<span class="font-weight-light text-muted">ID: {{reply.pk}}</span>
|
||||
{% if "can_moderate_board" in show_perms or board.user == user %}
|
||||
<div class="alert alert-warning"><div class="font-weight-light">{{reply.body}}</div></div>
|
||||
<a href="{{showurl}}/discuss/board/delete/reply/{{reply.id}}" class="btn btn-warning ml-1">Restore</a>
|
||||
<a href="{{showurl}}/create_ban?user={{reply.user.username}}" class="btn btn-warning ml-1">Ban</a>
|
||||
<a href="{{show.url}}/discuss/board/delete/reply/{{reply.id}}" class="btn btn-warning ml-1">Restore</a>
|
||||
<a href="{{show.url}}/create_ban?user={{reply.user.username}}" class="btn btn-warning ml-1">Ban</a>
|
||||
{% endif %}
|
||||
<div class="w-100 mb-4"></div>
|
||||
{% else %}
|
||||
@ -54,20 +54,20 @@
|
||||
<div class="actions d-flex flex-row-reverse">
|
||||
{% if user.is_authenticated %}
|
||||
{% if "can_moderate_board" in show_perms or board.user == user %}
|
||||
<a href="{{showurl}}/discuss/board/delete/reply/{{reply.id}}" class="btn btn-warning ml-1">Delete Content</a>
|
||||
<a href="{{showurl}}/create_ban?user={{reply.user.username}}" class="btn btn-warning ml-1">Ban</a>
|
||||
<a href="{{show.url}}/discuss/board/delete/reply/{{reply.id}}" class="btn btn-warning ml-1">Delete Content</a>
|
||||
<a href="{{show.url}}/create_ban?user={{reply.user.username}}" class="btn btn-warning ml-1">Ban</a>
|
||||
{% else %}
|
||||
<a href="{{showurl}}/discuss/board/report/{{reply.id}}" class="btn btn-secondary ml-1" title="Report" aria-label="Report"><i class="fa fa-fw fa-flag"></i></a>
|
||||
<a href="{{show.url}}/discuss/board/report/{{reply.id}}" class="btn btn-secondary ml-1" title="Report" aria-label="Report"><i class="fa fa-fw fa-flag"></i></a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<div class="vote-btns">
|
||||
<form method="POST" class="d-inline" action="{{showurl}}/discuss/vote/{{reply.id}}/1">
|
||||
<form method="POST" class="d-inline" action="{{show.url}}/discuss/vote/{{reply.id}}/1">
|
||||
{% csrf_token %}
|
||||
<button href="#" class="btn btn-link text-success">
|
||||
<i class="fa fa-fw fa-thumbs-up"></i> {{reply.positives}}
|
||||
</button>
|
||||
</form>
|
||||
<form method="POST" class="d-inline" action="{{showurl}}/discuss/vote/{{reply.id}}/0">
|
||||
<form method="POST" class="d-inline" action="{{show.url}}/discuss/vote/{{reply.id}}/0">
|
||||
{% csrf_token %}
|
||||
<button href="#" class="btn btn-link text-danger">
|
||||
<i class="fa fa-fw fa-thumbs-down"></i> {{reply.negatives}}
|
||||
@ -121,7 +121,7 @@
|
||||
{% if user.is_authenticated and not board.locked %}
|
||||
<h2>Quick Reply</h2>
|
||||
<div class="reply-box">
|
||||
<form class="form-horizontal" role="form" action="{{showurl}}/discuss/board/reply/{{board.pk}}" method="post">
|
||||
<form class="form-horizontal" role="form" action="{{show.url}}/discuss/board/reply/{{board.pk}}" method="post">
|
||||
{% include "form.html" %}
|
||||
<div class="form-group">
|
||||
<button type="submit" class="btn btn-primary">Reply</button>
|
||||
@ -136,14 +136,14 @@
|
||||
<h4>Board Tools</h4>
|
||||
<ul>
|
||||
{% if not board.locked %}
|
||||
<li><a href="{{showurl}}/discuss/board/reply/{{board.pk}}">Reply to the board</a></li>
|
||||
<li><a href="{{show.url}}/discuss/board/reply/{{board.pk}}">Reply to the board</a></li>
|
||||
{% endif %}
|
||||
{% if "can_moderate_board" in show_perms or board.user == user and not board.locked %}
|
||||
<li><a href="{{showurl}}/discuss/board/lock/{{board.pk}}">Lock the board from further replies</a></li>
|
||||
<li><a href="{{show.url}}/discuss/board/lock/{{board.pk}}">Lock the board from further replies</a></li>
|
||||
{% endif %}
|
||||
{% if "can_moderate_board" in show_perms %}
|
||||
<li><a href="{{showurl}}/discuss/board/pin/{{board.pk}}">{% if board.pinned %}Unpin the board{% else %}Pin the board at the top{% endif %}</a></li>
|
||||
<li><a href="{{showurl}}/discuss/board/delete/{{board.pk}}">Delete the board</a></li>
|
||||
<li><a href="{{show.url}}/discuss/board/pin/{{board.pk}}">{% if board.pinned %}Unpin the board{% else %}Pin the board at the top{% endif %}</a></li>
|
||||
<li><a href="{{show.url}}/discuss/board/delete/{{board.pk}}">Delete the board</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
@ -6,9 +6,9 @@
|
||||
<section class="container mt-5 mb-5">
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="{{showurl}}">{{show.name}}</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{showurl}}/discuss">Discussions</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{showurl}}/discuss/board/{{board.pk}}-{{board.title|slugify}}">{{board.title}}</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{show.url}}">{{show.name}}</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{show.url}}/discuss">Discussions</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{show.url}}/discuss/board/{{board.pk}}-{{board.title|slugify}}">{{board.title}}</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">Reply</li>
|
||||
</ol>
|
||||
</nav>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<div class="container mb-5 mt-5">
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="{{showurl}}">{{show.name}}</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{show.url}}">{{show.name}}</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">Discussions</li>
|
||||
</ol>
|
||||
</nav>
|
||||
@ -14,7 +14,7 @@
|
||||
<p>Discuss {{show.name}} with your fellow community members!</p>
|
||||
<div class="d-flex flex-row-reverse mb-4">
|
||||
{% if user.is_authenticated %}
|
||||
<a href="{{showurl}}/discuss/board/new" class="btn btn-primary"><i class="fa fa-fw fa-pencil"></i> Create New Board</a>
|
||||
<a href="{{show.url}}/discuss/board/new" class="btn btn-primary"><i class="fa fa-fw fa-pencil"></i> Create New Board</a>
|
||||
{% else %}
|
||||
<p><a href="/login">Log in</a> to create boards</p>
|
||||
{% endif %}
|
||||
@ -27,7 +27,7 @@
|
||||
<div class="board border-bottom">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h2><a href="{{showurl}}/discuss/board/{{board.pk}}-{{board.title|slugify}}">{% if board.locked %}<i class="fa fa-fw fa-lock"></i>{% endif %}{% if board.pinned %}<i class="fa fa-fw fa-thumb-tack"></i>{% endif %}{{board.title}}</a></h2>
|
||||
<h2><a href="{{show.url}}/discuss/board/{{board.pk}}-{{board.title|slugify}}">{% if board.locked %}<i class="fa fa-fw fa-lock"></i>{% endif %}{% if board.pinned %}<i class="fa fa-fw fa-thumb-tack"></i>{% endif %}{{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>
|
||||
|
@ -6,8 +6,8 @@
|
||||
<section class="container mt-5 mb-5">
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="{{showurl}}">{{show.name}}</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{showurl}}/discuss">Discussions</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{show.url}}">{{show.name}}</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{show.url}}/discuss">Discussions</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">New Board</li>
|
||||
</ol>
|
||||
</nav>
|
||||
|
@ -6,9 +6,9 @@
|
||||
<section class="container mb-5 mt-5">
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="/show/{{show.abbr}}">{{show.name}}</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{discuss}}">Discussions</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{discuss}}/board/{{reply.board.pk}}-{{reply.board.title|slugify}}">{{reply.board.title}}</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{show.url}}">{{show.name}}</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{show.url}}/discuss">Discussions</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{show.url}}/discuss/board/{{reply.board.pk}}-{{reply.board.title|slugify}}">{{reply.board.title}}</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">Report</li>
|
||||
</ol>
|
||||
</nav>
|
||||
|
@ -29,7 +29,6 @@ from django.utils.text import slugify
|
||||
from guardian.decorators import permission_required_or_403
|
||||
|
||||
from LandingPage.models import Show, DiscussionBoard, DiscussionReply, DiscussionVote, Ban, Report
|
||||
from LandingPage.views import get_show_url
|
||||
from . import forms
|
||||
|
||||
import datetime
|
||||
@ -41,7 +40,6 @@ class Boards(TemplateView):
|
||||
|
||||
def get_context_data(self, abbr, **kwargs):
|
||||
ctx = super().get_context_data()
|
||||
ctx['showurl'] = get_show_url(abbr)
|
||||
|
||||
show = get_object_or_404(Show, abbr=abbr)
|
||||
|
||||
@ -80,8 +78,6 @@ class Board(TemplateView):
|
||||
|
||||
def get_context_data(self, abbr, bid, **kwargs):
|
||||
ctx = super().get_context_data()
|
||||
ctx['showurl'] = get_show_url(abbr)
|
||||
|
||||
show = get_object_or_404(Show, abbr=abbr)
|
||||
board = get_object_or_404(DiscussionBoard, pk=bid)
|
||||
|
||||
@ -109,7 +105,7 @@ class Board(TemplateView):
|
||||
found = DiscussionReply.objects.filter(timestamp__lt=item.timestamp,board=board).count()
|
||||
page = int(found / perpage) + 1
|
||||
index = int(found % perpage) + 1
|
||||
ctx['url'] = ctx['showurl'] + '/discuss/board/%d-%s?page=%d#reply-%d'%(board.pk, slugify(board.title), page, index)
|
||||
ctx['url'] = show.url() + '/discuss/board/%d-%s?page=%d#reply-%d'%(board.pk, slugify(board.title), page, index)
|
||||
|
||||
return ctx
|
||||
|
||||
@ -181,7 +177,7 @@ def BoardForm(req, abbr):
|
||||
new_post = DiscussionReply(user=user,board=new_board,body=form_data['body'])
|
||||
new_post.save()
|
||||
|
||||
return HttpResponseRedirect(ctx['showurl'] + '/discuss/board/%d-%s'%(new_board.pk, slugify(form_data['title'])))
|
||||
return HttpResponseRedirect(show.url() + '/discuss/board/%d-%s'%(new_board.pk, slugify(form_data['title'])))
|
||||
else:
|
||||
ctx['error'] = 'Invalid fields!'
|
||||
|
||||
@ -200,8 +196,7 @@ def BoardReplyForm(req, abbr, bid):
|
||||
ctx = {
|
||||
'form': form,
|
||||
'board': board,
|
||||
'show': show,
|
||||
'showurl': get_show_url(abbr)
|
||||
'show': show
|
||||
}
|
||||
|
||||
# Get bans for this user regarding this show
|
||||
@ -240,7 +235,7 @@ def BoardReplyForm(req, abbr, bid):
|
||||
new_reply.board = board
|
||||
new_reply.save()
|
||||
|
||||
return HttpResponseRedirect(ctx['showurl'] + '/discuss/board/%d-%s?findReply=%d'%(board.pk, slugify(board.title), new_reply.pk))
|
||||
return HttpResponseRedirect(show.url() + '/discuss/board/%d-%s?findReply=%d'%(board.pk, slugify(board.title), new_reply.pk))
|
||||
else:
|
||||
ctx['error'] = 'Invalid fields!'
|
||||
|
||||
@ -254,10 +249,10 @@ class BoardVoteSubmit(LoginRequiredMixin, View):
|
||||
pos_bool = int(positive) == 1
|
||||
|
||||
user = req.user
|
||||
showurl = get_show_url(abbr)
|
||||
|
||||
# Get the reply from the database
|
||||
reply = get_object_or_404(DiscussionReply, id=replyid)
|
||||
showurl = reply.board.show.url()
|
||||
|
||||
# Prevent voting for own reply
|
||||
if reply.user == user:
|
||||
@ -309,11 +304,10 @@ def ReportForm(req, abbr, rid):
|
||||
ctx = {
|
||||
'form': form,
|
||||
'show': show,
|
||||
'reply': reply,
|
||||
'showurl': get_show_url(abbr)
|
||||
'reply': reply
|
||||
}
|
||||
|
||||
url = '%s/discuss/board/%d-%s?findReply=%d'%(ctx['showurl'], reply.board.pk, slugify(reply.board.title), reply.pk)
|
||||
url = '%s/discuss/board/%d-%s?findReply=%d'%(show.url(), reply.board.pk, slugify(reply.board.title), reply.pk)
|
||||
|
||||
# Handle POST
|
||||
if req.method == 'POST':
|
||||
@ -339,7 +333,7 @@ def ReportForm(req, abbr, rid):
|
||||
new_report.url = url
|
||||
new_report.save()
|
||||
|
||||
return HttpResponseRedirect('%s/discuss/board/%d-%s'%(ctx['showurl'], reply.board.pk, slugify(reply.board.title)))
|
||||
return HttpResponseRedirect('%s/discuss/board/%d-%s'%(show.url(), reply.board.pk, slugify(reply.board.title)))
|
||||
else:
|
||||
ctx['error'] = 'Invalid fields!'
|
||||
|
||||
@ -349,27 +343,25 @@ def ReportForm(req, abbr, rid):
|
||||
def BoardLock(req, abbr, bid):
|
||||
user = req.user
|
||||
board = get_object_or_404(DiscussionBoard, pk=bid)
|
||||
showurl = get_show_url(abbr)
|
||||
|
||||
if not user.has_perm('LandingPage.can_moderate_board', board.show) and not board.user == user:
|
||||
return HttpResponse('<h1>Error</h1><p>You do not have permission to lock this show.</p><p>'
|
||||
'<a href="%s/discuss/board/%d-%s">Return to board</a></p>'
|
||||
% (showurl, board.pk, slugify(board.title)), status=400)
|
||||
% (board.show.url(), board.pk, slugify(board.title)), status=400)
|
||||
|
||||
lock = not board.locked
|
||||
DiscussionBoard.objects.filter(pk=board.pk).update(locked=lock)
|
||||
return HttpResponseRedirect('%s/discuss/board/%d-%s'%(showurl, board.pk, slugify(board.title)))
|
||||
return HttpResponseRedirect('%s/discuss/board/%d-%s'%(board.show.url(), board.pk, slugify(board.title)))
|
||||
|
||||
|
||||
@permission_required_or_403('LandingPage.can_moderate_board', (Show, 'abbr', 'abbr'), accept_global_perms=True)
|
||||
def BoardPin(req, abbr, bid):
|
||||
board = get_object_or_404(DiscussionBoard, pk=bid)
|
||||
showurl = get_show_url(abbr)
|
||||
|
||||
pin = not board.pinned
|
||||
|
||||
DiscussionBoard.objects.filter(pk=board.pk).update(pinned=pin)
|
||||
return HttpResponseRedirect('%s/discuss/board/%d-%s'%(showurl, board.pk, slugify(board.title)))
|
||||
return HttpResponseRedirect('%s/discuss/board/%d-%s'%(board.show.url(), board.pk, slugify(board.title)))
|
||||
|
||||
@permission_required_or_403('LandingPage.can_moderate_board', (Show, 'abbr', 'abbr'), accept_global_perms=True)
|
||||
def BoardDelete(req, abbr, bid):
|
||||
@ -378,15 +370,14 @@ def BoardDelete(req, abbr, bid):
|
||||
|
||||
DiscussionBoard.objects.filter(pk=board.pk).delete()
|
||||
|
||||
return HttpResponseRedirect('%s/discuss' % (showurl))
|
||||
return HttpResponseRedirect('%s/discuss' % (board.show.url()))
|
||||
|
||||
@permission_required_or_403('LandingPage.can_moderate_board', (Show, 'abbr', 'abbr'), accept_global_perms=True)
|
||||
def BoardDeleteReply(req, abbr, rid):
|
||||
reply = get_object_or_404(DiscussionReply, pk=rid)
|
||||
showurl = get_show_url(abbr)
|
||||
|
||||
delete = not reply.deleted
|
||||
|
||||
DiscussionReply.objects.filter(pk=reply.pk).update(deleted=delete)
|
||||
|
||||
return HttpResponseRedirect('%s/discuss/board/%d-%s'%(showurl, reply.board.pk, slugify(reply.board.title)))
|
||||
return HttpResponseRedirect('%s/discuss/board/%d-%s'%(reply.show.url(), reply.board.pk, slugify(reply.board.title)))
|
||||
|
@ -176,7 +176,7 @@ DISCUSSIONS_PER_PAGE = 26
|
||||
DISCUSSIONS_REPLIES_PER_PAGE = 10
|
||||
|
||||
# Domain of this app
|
||||
DOMAIN='localhost'
|
||||
DOMAIN=options.get('domain')
|
||||
|
||||
# Use subdomains for each show
|
||||
DOMAIN_SUBDOMAIN_SHOWS=False
|
||||
DOMAIN_SUBDOMAIN_SHOWS=options.get('use_subdomain_paths') == 'true'
|
||||
|
@ -15,6 +15,7 @@
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
from django.db import models
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import AbstractUser
|
||||
from django.core.files.storage import FileSystemStorage
|
||||
from django.conf import settings
|
||||
@ -95,6 +96,15 @@ class Show(TimestampedModel):
|
||||
('can_moderate_board', 'Can delete and edit boards and replies of this show'),
|
||||
)
|
||||
|
||||
def url(self):
|
||||
use_sdms = getattr(settings, "DOMAIN_SUBDOMAIN_SHOWS", False)
|
||||
domain = getattr(settings, "DOMAIN", 'localhost')
|
||||
|
||||
if use_sdms:
|
||||
return domain.format(sub=self.abbr + '.',path='')
|
||||
|
||||
return '/show/%s' % (self.abbr)
|
||||
|
||||
def __str__(self):
|
||||
return '%s [%s]'%(self.name,self.abbr)
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
{% if not recent %} Nothing to show {% endif %}
|
||||
<div class="text-center">
|
||||
{% for show in recent %}
|
||||
<a class="show-promo" href="/show/{{show.abbr}}">
|
||||
<a class="show-promo" href="{{show.url}}">
|
||||
<img class="artwork" src="/media/uploaded_resources/{{show.artwork}}">
|
||||
<span>{{show.name}}</span>
|
||||
</a>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<div class="row">
|
||||
{% for show in shows %}
|
||||
<div class="col">
|
||||
<a href="/show/{{show.abbr}}">{{show.name}}</a>
|
||||
<a href="{{show.url}}">{{show.name}}</a>
|
||||
</div>
|
||||
{% if forloop.counter|divisibleby:3 %}
|
||||
<div class="w-100"></div>
|
||||
|
@ -21,7 +21,7 @@ from django.contrib.auth import login as auth_login, authenticate
|
||||
from django.conf import settings
|
||||
from django.http import HttpResponse
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.db.models import Max
|
||||
from django.db.models import Max, F
|
||||
from django.contrib.auth.views import logout
|
||||
import requests
|
||||
import hashlib
|
||||
@ -31,16 +31,6 @@ from .models import Show
|
||||
from .models import Submission
|
||||
from .models import DiscussionBoard
|
||||
|
||||
# Get a show's URL by its abbreviation
|
||||
def get_show_url(abbr):
|
||||
use_sdms = getattr(settings, "DOMAIN_SUBDOMAIN_SHOWS", False)
|
||||
domain = getattr(settings, "DOMAIN", 'localhost')
|
||||
|
||||
if use_sdms:
|
||||
return '%s.%s' % (abbr, domain)
|
||||
|
||||
return '/show/%s' % (abbr)
|
||||
|
||||
# Redirect url should point to this view
|
||||
class LoginRedirect(View):
|
||||
def get(self, req):
|
||||
|
@ -7,7 +7,7 @@
|
||||
<section class="container mt-2 mb-5">
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="{{showurl}}">{{show.name}}</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{show.url}}">{{show.name}}</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">New Season</li>
|
||||
</ol>
|
||||
</nav>
|
||||
|
@ -46,7 +46,7 @@
|
||||
<section class="container mb-5 mt-2">
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="{{showurl}}">{{show.name}}</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{show.url}}">{{show.name}}</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">{{episode.name}}</li>
|
||||
</ol>
|
||||
</nav>
|
||||
@ -73,13 +73,13 @@
|
||||
</div>
|
||||
<div class="col-md-2 text-md-right">
|
||||
<div class="vote-btns" data-vote-id="{{sbm.id}}">
|
||||
<form method="POST" class="d-inline" action="{{showurl}}/vote/{{sbm.id}}/1">
|
||||
<form method="POST" class="d-inline" action="{{show.url}}/vote/{{sbm.id}}/1">
|
||||
{% csrf_token %}
|
||||
<button class="btn btn-success">
|
||||
<i class="fa fa-fw fa-thumbs-up"></i> {{sbm.positives}}
|
||||
</button>
|
||||
</form>
|
||||
<form method="POST" class="d-inline" action="{{showurl}}/vote/{{sbm.id}}/0">
|
||||
<form method="POST" class="d-inline" action="{{show.url}}/vote/{{sbm.id}}/0">
|
||||
{% csrf_token %}
|
||||
<button class="btn btn-danger">
|
||||
<i class="fa fa-fw fa-thumbs-down"></i> {{sbm.negatives}}
|
||||
@ -98,9 +98,9 @@
|
||||
</span>
|
||||
<span class="divider">·</span>
|
||||
{% if "can_moderate_show" in show_perms %}
|
||||
<a href="{{showurl}}/submission/{{sbm.id}}/moderate" class="button modbutton"><i class="fa fa-fw fa-shield"></i> Change</a>
|
||||
<a href="{{show.url}}/submission/{{sbm.id}}/moderate" class="button modbutton"><i class="fa fa-fw fa-shield"></i> Change</a>
|
||||
{% else %}
|
||||
<a href="{{showurl}}/submission/{{sbm.id}}/report" class="report">Report Invalid or Spam</a>
|
||||
<a href="{{show.url}}/submission/{{sbm.id}}/report" class="report">Report Invalid or Spam</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
@ -111,19 +111,19 @@
|
||||
<div class="d-flex flex-row-reverse mt-4">
|
||||
{% if user.is_authenticated %}
|
||||
{% if "can_moderate_show" in show_perms %}
|
||||
<a href="{{showurl}}/episode/{{episode.season.number}}/{{episode.episode}}/submit" class="btn btn-warning"><i class="fa fa-fw fa-plus"></i> Add New Link</a>
|
||||
<a href="{{show.url}}/episode/{{episode.season.number}}/{{episode.episode}}/submit" class="btn btn-warning"><i class="fa fa-fw fa-plus"></i> Add New Link</a>
|
||||
{% else %}
|
||||
<a href="{{showurl}}/episode/{{episode.season.number}}/{{episode.episode}}/submit" class="btn btn-primary"><i class="fa fa-fw fa-plus"></i> Submit New Link</a>
|
||||
<a href="{{show.url}}/episode/{{episode.season.number}}/{{episode.episode}}/submit" class="btn btn-primary"><i class="fa fa-fw fa-plus"></i> Submit New Link</a>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<span class="fillertext"><a href="/login">Log in</a> to submit a link</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
<p>Discuss <q>{{episode.name}}</q> on the <a href="{{showurl}}/discuss">discussion boards</a>!</p>
|
||||
<p>Discuss <q>{{episode.name}}</q> on the <a href="{{show.url}}/discuss">discussion boards</a>!</p>
|
||||
<ul class="nav fixed-bottom d-flex justify-content-center border-top bg-light">
|
||||
{% if has_previous %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{showurl}}/episode/{{episode.season.number}}/{{episode.episode|add:'-1'}}">Previous Episode</a>
|
||||
<a class="nav-link" href="{{show.url}}/episode/{{episode.season.number}}/{{episode.episode|add:'-1'}}">Previous Episode</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="nav-item">
|
||||
@ -132,7 +132,7 @@
|
||||
{% endif %}
|
||||
{% if has_next %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{showurl}}/episode/{{episode.season.number}}/{{episode.episode|add:'1'}}">Next Episode</a>
|
||||
<a class="nav-link" href="{{show.url}}/episode/{{episode.season.number}}/{{episode.episode|add:'1'}}">Next Episode</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="nav-item">
|
||||
|
@ -33,7 +33,7 @@
|
||||
<section class="container mt-2 mb-5">
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="{{showurl}}">{{show.name}}</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{show.url}}">{{show.name}}</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">New Episode</li>
|
||||
</ol>
|
||||
</nav>
|
||||
|
@ -33,8 +33,8 @@
|
||||
<section class="container mb-4 mt-2">
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="{{showurl}}">{{show.name}}</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{showurl}}/episode/{{episode.season.number}}/{{episode.episode}}-{{episode.name|slugify}}">{{episode.name}}</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{show.url}}">{{show.name}}</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{show.url}}/episode/{{episode.season.number}}/{{episode.episode}}-{{episode.name|slugify}}">{{episode.name}}</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">Report</li>
|
||||
</ol>
|
||||
</nav>
|
||||
|
@ -7,7 +7,7 @@
|
||||
<section class="container mt-5 mb-5">
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="{{showurl}}">{{show.name}}</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{show.url}}">{{show.name}}</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">New Season</li>
|
||||
</ol>
|
||||
</nav>
|
||||
|
@ -42,14 +42,14 @@
|
||||
</div>
|
||||
{% if "can_moderate_show" in show_perms %}
|
||||
<div class="col-md-1 text-md-right">
|
||||
<a href="{{showurl}}/season/{{season.number}}/append" class="action"><i class="fa fa-fw fa-plus"></i></a>
|
||||
<a href="{{show.url}}/season/{{season.number}}/append" class="action"><i class="fa fa-fw fa-plus"></i></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% if "can_moderate_show" in show_perms %}
|
||||
<div class="d-flex flex-row-reverse">
|
||||
<a href="{{showurl}}/season/new" class="btn btn-warning"><i class="fa fa-fw fa-plus"></i> Add a Season</a>
|
||||
<a href="{{show.url}}/season/new" class="btn btn-warning"><i class="fa fa-fw fa-plus"></i> Add a Season</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</section>
|
||||
|
@ -33,8 +33,8 @@
|
||||
<section class="container mt-5 mb-5">
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="{{showurl}}">{{show.name}}</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{showurl}}/episode/{{episode.season.number}}/{{episode.episode}}-{{episode.name|slugify}}">{{episode.name}}</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{show.url}}">{{show.name}}</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{show.url}}/episode/{{episode.season.number}}/{{episode.episode}}-{{episode.name|slugify}}">{{episode.name}}</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">Submit</li>
|
||||
</ol>
|
||||
</nav>
|
||||
|
@ -35,8 +35,8 @@
|
||||
{% get_obj_perms request.user for show as "show_perms" %}
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="{{showurl}}">{{show.name}}</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{showurl}}/episode/{{episode.season.number}}/{{episode.episode}}-{{episode.name|slugify}}">{{episode.name}}</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{show.url}}">{{show.name}}</a></li>
|
||||
<li class="breadcrumb-item"><a href="{{show.url}}/episode/{{episode.season.number}}/{{episode.episode}}-{{episode.name|slugify}}">{{episode.name}}</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">Edit Submission</li>
|
||||
</ol>
|
||||
</nav>
|
||||
|
@ -27,7 +27,6 @@ from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from guardian.decorators import permission_required_or_403
|
||||
|
||||
from LandingPage.models import User, Show, Season, Episode, Submission, SubmissionVote, Ban, Report
|
||||
from LandingPage.views import get_show_url
|
||||
|
||||
from . import forms
|
||||
|
||||
@ -51,7 +50,6 @@ class IndexView(TemplateView):
|
||||
# Add fields to context
|
||||
ctx['show'] = show
|
||||
ctx['seasons'] = seasons
|
||||
ctx['showurl'] = get_show_url(abbr)
|
||||
|
||||
return ctx
|
||||
|
||||
@ -61,7 +59,6 @@ class EpisodeView(TemplateView):
|
||||
|
||||
def get_context_data(self, abbr, season, episode, **kwargs):
|
||||
ctx = super().get_context_data()
|
||||
ctx['showurl'] = get_show_url(abbr)
|
||||
|
||||
highlight = self.request.GET.get('submission', None)
|
||||
if not highlight == None:
|
||||
@ -88,11 +85,11 @@ class EpisodeView(TemplateView):
|
||||
raise Http404('No Episode matches the given query.')
|
||||
|
||||
episode_number = int(epobj.episode)
|
||||
ctx['url'] = '%s/episode/%d/%d'%(ctx['showurl'], season_number, episode_number)
|
||||
ctx['url'] = '%s/episode/%d/%d'%(show.url(), season_number, episode_number)
|
||||
elif episode_number > int(lastep.episode):
|
||||
season_number += 1
|
||||
episode_number = 1
|
||||
ctx['url'] = '%s/episode/%d/%d'%(ctx['showurl'], season_number, episode_number)
|
||||
ctx['url'] = '%s/episode/%d/%d'%(show.url(), season_number, episode_number)
|
||||
|
||||
if 'url' in ctx:
|
||||
return ctx
|
||||
@ -132,11 +129,10 @@ class EpisodeView(TemplateView):
|
||||
def EpisodeFindSubmission(req, abbr, submission):
|
||||
show = get_object_or_404(Show, abbr=abbr)
|
||||
submission = int(submission)
|
||||
showurl = get_show_url(abbr)
|
||||
|
||||
episode = get_object_or_404(Episode, submissions__id=submission)
|
||||
|
||||
return HttpResponseRedirect('%s/episode/%d/%d?submission=%d'%(showurl, episode.season.number, episode.episode, submission))
|
||||
return HttpResponseRedirect('%s/episode/%d/%d?submission=%d'%(show.url(), episode.season.number, episode.episode, submission))
|
||||
|
||||
# Submission form GET and POST
|
||||
@login_required
|
||||
@ -151,8 +147,7 @@ def SubmissionForm(req, abbr, season, episode):
|
||||
ctx = {
|
||||
'form': form,
|
||||
'show': show,
|
||||
'episode': episode,
|
||||
'showurl': get_show_url(abbr)
|
||||
'episode': episode
|
||||
}
|
||||
|
||||
# Get bans for this user regarding this show
|
||||
@ -185,7 +180,7 @@ def SubmissionForm(req, abbr, season, episode):
|
||||
new_submission.episode = episode
|
||||
new_submission.save()
|
||||
|
||||
return HttpResponseRedirect('%s/episode/%d/%d'%(ctx['showurl'], episode.season.number, episode.episode))
|
||||
return HttpResponseRedirect('%s/episode/%d/%d'%(show.url(), episode.season.number, episode.episode))
|
||||
else:
|
||||
ctx['error'] = 'Invalid fields!'
|
||||
|
||||
@ -205,19 +200,18 @@ def SubmissionModForm(req, abbr, submission):
|
||||
ctx = {
|
||||
'form': form,
|
||||
'show': show,
|
||||
'episode': episode,
|
||||
'showurl': get_show_url(abbr)
|
||||
'episode': episode
|
||||
}
|
||||
|
||||
# Handle POST
|
||||
if req.method == 'POST':
|
||||
if 'delete' in req.POST:
|
||||
submission.delete()
|
||||
return HttpResponseRedirect('%s/episode/%d/%d'%(ctx['showurl'], episode.season.number, episode.episode))
|
||||
return HttpResponseRedirect('%s/episode/%d/%d'%(show.url(), episode.season.number, episode.episode))
|
||||
|
||||
if 'delete_ban' in req.POST:
|
||||
submission.delete()
|
||||
return HttpResponseRedirect('%s/create_ban?user=%s'%(ctx['showurl'],submission.user.username))
|
||||
return HttpResponseRedirect('%s/create_ban?user=%s'%(show.url(),submission.user.username))
|
||||
|
||||
form = forms.SubmissionFormAdmin(req.POST, instance=submission)
|
||||
ctx['form'] = form
|
||||
@ -226,7 +220,7 @@ def SubmissionModForm(req, abbr, submission):
|
||||
form_data = form.cleaned_data
|
||||
form.save()
|
||||
|
||||
return HttpResponseRedirect('%s/episode/%d/%d'%(ctx['showurl'], episode.season.number, episode.episode))
|
||||
return HttpResponseRedirect('%s/episode/%d/%d'%(show.url(), episode.season.number, episode.episode))
|
||||
else:
|
||||
ctx['error'] = 'Invalid fields!'
|
||||
|
||||
@ -243,8 +237,7 @@ def SeasonSubmitForm(req, abbr):
|
||||
# Request context
|
||||
ctx = {
|
||||
'form': form,
|
||||
'show': show,
|
||||
'showurl': get_show_url(abbr)
|
||||
'show': show
|
||||
}
|
||||
|
||||
# Handle POST
|
||||
@ -264,7 +257,7 @@ def SeasonSubmitForm(req, abbr):
|
||||
new_season.show = show
|
||||
new_season.save()
|
||||
|
||||
return HttpResponseRedirect(ctx['showurl'])
|
||||
return HttpResponseRedirect(show.url())
|
||||
else:
|
||||
ctx['error'] = 'Invalid fields!'
|
||||
|
||||
@ -283,8 +276,7 @@ def EpisodeSubmitForm(req, abbr, season):
|
||||
ctx = {
|
||||
'form': form,
|
||||
'season': season,
|
||||
'show': show,
|
||||
'showurl': get_show_url(abbr)
|
||||
'show': show
|
||||
}
|
||||
|
||||
# Handle POST
|
||||
@ -305,7 +297,7 @@ def EpisodeSubmitForm(req, abbr, season):
|
||||
new_episode.season = season
|
||||
new_episode.save()
|
||||
|
||||
return HttpResponseRedirect(ctx['showurl'])
|
||||
return HttpResponseRedirect(show.url())
|
||||
else:
|
||||
ctx['error'] = 'Invalid fields!'
|
||||
|
||||
@ -319,7 +311,6 @@ class SubmissionVoteSubmit(LoginRequiredMixin, View):
|
||||
pos_bool = int(positive) == 1
|
||||
|
||||
user = req.user
|
||||
showurl = get_show_url(abbr)
|
||||
|
||||
# Get the submission from the database
|
||||
submission = get_object_or_404(Submission, id=subid)
|
||||
@ -352,7 +343,7 @@ class SubmissionVoteSubmit(LoginRequiredMixin, View):
|
||||
)
|
||||
new_vote.save()
|
||||
|
||||
return HttpResponseRedirect('%s/episode/%d/%d'%(showurl, submission.episode.season.number, submission.episode.episode))
|
||||
return HttpResponseRedirect('%s/episode/%d/%d'%(show.url(), submission.episode.season.number, submission.episode.episode))
|
||||
|
||||
# Episode form GET and POST
|
||||
@permission_required_or_403('LandingPage.can_create_show_ban', (Show, 'abbr', 'abbr'), accept_global_perms=True)
|
||||
@ -407,7 +398,7 @@ def BanFromShowForm(req, abbr):
|
||||
if 'delete' in req.POST:
|
||||
Submission.objects.filter(episode__show=show,user=banTarget).delete()
|
||||
|
||||
return HttpResponseRedirect(ctx['showurl'])
|
||||
return HttpResponseRedirect(show.url())
|
||||
else:
|
||||
ctx['error'] = 'Invalid fields!'
|
||||
|
||||
@ -437,7 +428,7 @@ def ReportSubmission(req, abbr, submission):
|
||||
'showurl': get_show_url(abbr)
|
||||
}
|
||||
|
||||
url = '%s/episode/%d/%d?submission=%s'%(ctx['showurl'], episode.season.number, episode.episode,submission.pk)
|
||||
url = '%s/episode/%d/%d?submission=%s'%(show.url(), episode.season.number, episode.episode, submission.pk)
|
||||
|
||||
# Handle POST
|
||||
if req.method == 'POST':
|
||||
@ -463,7 +454,7 @@ def ReportSubmission(req, abbr, submission):
|
||||
new_report.url = url
|
||||
new_report.save()
|
||||
|
||||
return HttpResponseRedirect('%s/episode/%d/%d'%(ctx['showurl'], episode.season.number, episode.episode))
|
||||
return HttpResponseRedirect('%s/episode/%d/%d'%(show.url(), episode.season.number, episode.episode))
|
||||
else:
|
||||
ctx['error'] = 'Invalid fields!'
|
||||
|
||||
|
@ -9,6 +9,10 @@ secret_key=5up3r s3cr3t k3y
|
||||
#For configuration details
|
||||
database=sqlite:///database.sqlite3
|
||||
|
||||
#Domain of this website to use in show path manufacturing
|
||||
domain=http://{sub}localhost:8000{path}
|
||||
use_subdomain_paths=false
|
||||
|
||||
[OAuth]
|
||||
#The root of the oauth endpoint you are using for oauth settings
|
||||
token_endpoint=https://icynet.eu/oauth/
|
||||
|
Reference in New Issue
Block a user