diff --git a/LandingPage/models.py b/LandingPage/models.py
index 8a434a4..90cc515 100644
--- a/LandingPage/models.py
+++ b/LandingPage/models.py
@@ -185,6 +185,24 @@ class Report(TimestampedModel):
help_text='The URL of the content being reported',
verbose_name = 'Content URL'
)
+ read_by = models.ForeignKey(
+ User,
+ on_delete=models.SET_NULL,
+ null=True,
+ blank=True,
+ related_name='reader',
+ help_text='The administrator that read this report',
+ verbose_name='Read by'
+ )
+ read_at = models.DateTimeField(
+ null=True,
+ blank=True,
+ help_text='The date and time this report was read'
+ )
+ resolved = models.BooleanField(
+ help_text='Whether or not this report has been marked as resolved',
+ default=False
+ )
def __str__(self):
return "%s's report of %s"%(self.reporter, self.url)
diff --git a/LandingPage/static/css/style.css b/LandingPage/static/css/style.css
index 076f37b..b99f928 100644
--- a/LandingPage/static/css/style.css
+++ b/LandingPage/static/css/style.css
@@ -174,6 +174,10 @@ a.episode .submission_cnt {
.submission {
padding: 10px;
}
+.submission.highlighted {
+ background-color: #feffb3 !important;
+ border: 5px solid #ffbf61;
+}
.submission .data {
font-size: 90%;
color: #b1b1b1;
@@ -229,6 +233,22 @@ a.episode .submission_cnt {
opacity: 0.5;
user-select: none;
}
+.report-box {
+ padding: 10px;
+ margin: 10px 0px;
+ border: 2px dashed #ddd;
+ background-color: #fffbdb;
+ width: 400px;
+}
+.report-box .submitter {
+ font-size: 120%;
+ font-weight: bold;
+}
+.report-box .url-to {
+ display: block;
+ font-size: 90%;
+ color: #6d6d6d;
+}
@media all and (max-width: 800px) {
.logo {
font-size: 5vw !important;
diff --git a/Show/forms.py b/Show/forms.py
index d809f21..fdc758b 100644
--- a/Show/forms.py
+++ b/Show/forms.py
@@ -15,7 +15,7 @@
# along with this program. If not, see .
from django import forms
-from LandingPage.models import Submission, Season, Episode, Ban, User
+from LandingPage.models import Submission, Season, Episode, Ban, User, Report
class SubmissionForm(forms.ModelForm):
class Meta():
@@ -45,3 +45,8 @@ class BanForm(forms.ModelForm):
class Meta():
model = Ban
fields = ('reason','expiration','permanent',)
+
+class ReportForm(forms.ModelForm):
+ class Meta():
+ model = Report
+ fields = ('title','details',)
diff --git a/Show/templates/episode.html b/Show/templates/episode.html
index a4bca4e..ab87936 100644
--- a/Show/templates/episode.html
+++ b/Show/templates/episode.html
@@ -57,7 +57,7 @@
Watch {{episode.name}}
From
{% for sbm in submissions %}
-
diff --git a/Show/templates/report.html b/Show/templates/report.html
new file mode 100644
index 0000000..5799e63
--- /dev/null
+++ b/Show/templates/report.html
@@ -0,0 +1,54 @@
+{% extends "base.html" %}
+{% block title %}
+ Report a Submission - {{show.name}} - Episodes.Community
+{% endblock %}
+{% block content %}
+
+
+
+
+ {% if episode.season.artwork %}
+
+ {% else %}
+
+ {% endif %}
+
+
+
{{show.name}}
+ {% if episode.season.name %}
+
{{ episode.season.name }}
+ {% else %}
+
Season {{ episode.season.number }}
+ {% endif %}
+
+ {% if episode.season.description %}
+ {{ episode.season.description }}
+ {% else %}
+ {{ show.description }}
+ {% endif %}
+
+
+
+
+
+
+{% endblock %}
diff --git a/Show/urls.py b/Show/urls.py
index 86e7d8a..62b6e69 100644
--- a/Show/urls.py
+++ b/Show/urls.py
@@ -40,6 +40,8 @@ urlpatterns = [
url(r'^season/new$', views.SeasonSubmitForm),
url(r'^season/(?P\d{1,4})/append$', views.EpisodeSubmitForm),
url(r'^submission/(?P\d{1,4})/moderate$', views.SubmissionModForm),
+ url(r'^submission/(?P\d{1,4})/report$', views.ReportSubmission),
+ url(r'^episode/by-submission/(?P\d{1,4})$', views.EpisodeFindSubmission),
url(r'^episode/(?P\d{1,4})/(?P\d{1,4})(-[\w-]+)?/?$', views.EpisodeView.as_view()),
url(r'^episode/(?P\d{1,4})/(?P\d{1,4})(-[\w-]+)?/submit$', views.SubmissionForm),
url(r'^vote/(?P\d+)/(?P[0-1])/?$', views.SubmissionVoteSubmit.as_view())
diff --git a/Show/views.py b/Show/views.py
index 04f4c78..cbff335 100644
--- a/Show/views.py
+++ b/Show/views.py
@@ -60,6 +60,10 @@ class EpisodeView(TemplateView):
def get_context_data(self, abbr, season, episode, **kwargs):
ctx = super().get_context_data()
+ highlight = self.request.GET.get('submission', None)
+ if not highlight == None:
+ highlight = int(highlight)
+
# Get show by abbr
show = get_object_or_404(Show, abbr=abbr)
episode = get_object_or_404(Episode, show=show,season__number=season,episode=episode)
@@ -82,9 +86,18 @@ class EpisodeView(TemplateView):
ctx['show'] = show
ctx['episode'] = episode
ctx['submissions'] = submissions
+ ctx['highlight'] = highlight
return ctx
+def EpisodeFindSubmission(req, abbr, submission):
+ show = get_object_or_404(Show, abbr=abbr)
+ submission = int(submission)
+
+ episode = get_object_or_404(Episode, submissions__id=submission)
+
+ return HttpResponseRedirect('/show/%s/episode/%d/%d?submission=%d'%(abbr, episode.season.number, episode.episode, submission))
+
# Submission form GET and POST
@login_required
def SubmissionForm(req, abbr, season, episode):
@@ -353,3 +366,46 @@ def BanFromShowForm(req, abbr):
ctx['error'] = 'Invalid fields!'
return render(req, "create_ban.html", ctx)
+
+@login_required
+def ReportSubmission(req, abbr, submission):
+ show = get_object_or_404(Show, abbr=abbr)
+ submission = get_object_or_404(Submission, pk=submission,episode__show=show)
+ episode = submission.episode
+ user = req.user
+
+ form = forms.ReportForm()
+
+ # Get bans for this user regarding this show
+ bans = Ban.objects.filter(Q(expiration__gte=datetime.datetime.now()) | Q(permanent=True), user=user, site_wide=True)
+
+ if bans.count() > 0:
+ return HttpResponseForbidden('You are banned from the site and therefor not allowed to create reports.
Reason: %s'%(bans.first().reason))
+
+ # Request context
+ ctx = {
+ 'form': form,
+ 'show': show,
+ 'episode': episode,
+ 'submission': submission
+ }
+
+ # Handle POST
+ if req.method == 'POST':
+ form = forms.ReportForm(req.POST)
+ ctx['form'] = form
+
+ if form.is_valid():
+ form_data = form.cleaned_data
+
+ # Save
+ new_report = form.save(commit=False)
+ new_report.reporter = user
+ new_report.url = '/show/%s/episode/%d/%d?submission=%s'%(abbr, episode.season.number, episode.episode,submission.pk)
+ new_report.save()
+
+ return HttpResponseRedirect('/show/%s/episode/%d/%d'%(abbr, episode.season.number, episode.episode))
+ else:
+ ctx['error'] = 'Invalid fields!'
+
+ return render(req, "report.html", ctx)