mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-16 21:12:13 +00:00
Readded start>end checking. Template improvements
Added descritpions of all error for the user as well as the image. Added contextual alert boxes for messages in base. If start>end start<=>end. Very simple fix, thanks Charlie.
This commit is contained in:
@@ -6,11 +6,12 @@ import urllib2
|
||||
from django.views import generic
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.template import Context, RequestContext
|
||||
from django.template import RequestContext
|
||||
from django.template.loader import get_template
|
||||
from django.conf import settings
|
||||
from django.http import HttpResponse, HttpResponseBadRequest
|
||||
from django.http import HttpResponse
|
||||
from django.db.models import Q
|
||||
from django.contrib import messages
|
||||
from z3c.rml import rml2pdf
|
||||
from PyPDF2 import PdfFileMerger, PdfFileReader
|
||||
|
||||
@@ -125,6 +126,13 @@ class EventArchive(generic.ArchiveIndexView):
|
||||
def get_queryset(self):
|
||||
start = self.request.GET.get('start', None)
|
||||
end = self.request.GET.get('end', datetime.date.today())
|
||||
|
||||
# Assume idiots, always check
|
||||
if start and start > end:
|
||||
messages.add_message(self.request, messages.INFO,
|
||||
"Muppet! Check the dates, it has been fixed for you.")
|
||||
start, end = end, start # Stop the impending fail
|
||||
|
||||
filter = False
|
||||
if end != "":
|
||||
filter = Q(start_date__lte=end)
|
||||
@@ -139,4 +147,10 @@ class EventArchive(generic.ArchiveIndexView):
|
||||
else:
|
||||
qs = self.model.objects.all()
|
||||
|
||||
return qs.select_related('person', 'organisation', 'venue', 'mic')
|
||||
# Preselect related for efficiency
|
||||
qs.select_related('person', 'organisation', 'venue', 'mic')
|
||||
|
||||
if len(qs) == 0:
|
||||
messages.add_message(self.request, messages.WARNING, "No events have been found matching those criteria.")
|
||||
|
||||
return qs
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
{% block content %}
|
||||
<div class="text-center">
|
||||
<h1>400: Bad Request</h1>
|
||||
<img src="{% static 'imgs/400.jpg' %}"/>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
{% block content %}
|
||||
<div class="text-center">
|
||||
<h1>401: Unauthorized</h1>
|
||||
<img src="{% static 'imgs/401.jpg' %}"/>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
{% block content %}
|
||||
<div class="text-center">
|
||||
<h1>403: Forbidden</h1>
|
||||
<img src="{% static 'imgs/403.jpg' %}"/>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -3,7 +3,11 @@
|
||||
{% block title %}Page Not Found{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="text-center">
|
||||
<img src="{% static 'imgs/404.jpg' %}"/>
|
||||
<div class="col-sm-12">
|
||||
<h1>404: Not Found</h1>
|
||||
|
||||
<div class="text-center">
|
||||
<img src="{% static 'imgs/404.jpg' %}"/>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
{% block content %}
|
||||
<div class="text-center">
|
||||
<h1>500: Server error</h1>
|
||||
<img src="{% static 'imgs/500.jpg' %}"/>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -110,7 +110,11 @@
|
||||
<div class="info">{{ info }}</div>{% endif %}
|
||||
{% if messages %}
|
||||
{% for message in messages %}
|
||||
<div class="info">{{ message }}</div>
|
||||
<div class="alert alert-{{ message.level_tag }} alert-dismissible" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span
|
||||
aria-hidden="true">×</span></button>
|
||||
{{ message }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user