mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 05:22:16 +00:00
Improve search logic and allow search of event archive (#248)
* Added search to person, venue, organisation and event archive
* Added search to invoice archive
* Added event search to homepage
* Tidy up event search logic and optimise
* Fixed merge issues
* Stopped 404 on failed search
* Set default ordering of people, organisations & venues to alphabetical (rather than order of addition to database)
* Added invoice search to home page (if you have permissions)
* Made invoice archive sort by reverse invoice date (rather than order added to database)
* Added search help page (very pretty)
* Made single search box for all search types
* FIX: Missing date field breaking archive view
* FEAT: Add omnisearch to header
Tis a bit broken on mobile at the moment...
* CHORE: Conform old code to pep8
* FIX: Select the event form, not the search one in tests!
* Revert "FEAT: Add omnisearch to header"
This reverts commit 6bcb242d6b because it caused MANY more problems than anticipated...
* FIX: Stop 404 on failed search, again
* FEAT: Basic testing of search
* Use a tooltip to help explain the UX
Obviously since it needs a tooltip it isn't brilliant UX but the best I can think of for now...
Co-authored-by: Tom Price <tom@codedinternet.com>
Co-authored-by: David Taylor <david@taylorhq.com>
Co-authored-by: Arona Jones <aj@aronajones.com>
This commit is contained in:
@@ -11,6 +11,7 @@ from django.template.loader import get_template
|
||||
from django.views import generic
|
||||
from django.db.models import Q
|
||||
from z3c.rml import rml2pdf
|
||||
from django.db.models import Q
|
||||
|
||||
from RIGS import models
|
||||
|
||||
@@ -122,6 +123,34 @@ class InvoiceArchive(generic.ListView):
|
||||
template_name = 'RIGS/invoice_list_archive.html'
|
||||
paginate_by = 25
|
||||
|
||||
def get_queryset(self):
|
||||
q = self.request.GET.get('q', "")
|
||||
|
||||
filter = Q(event__name__icontains=q)
|
||||
|
||||
# try and parse an int
|
||||
try:
|
||||
val = int(q)
|
||||
filter = filter | Q(pk=val)
|
||||
filter = filter | Q(event__pk=val)
|
||||
except: # noqa
|
||||
# not an integer
|
||||
pass
|
||||
|
||||
try:
|
||||
if q[0] == "N":
|
||||
val = int(q[1:])
|
||||
filter = Q(event__pk=val) # If string is Nxxxxx then filter by event number
|
||||
elif q[0] == "#":
|
||||
val = int(q[1:])
|
||||
filter = Q(pk=val) # If string is #xxxxx then filter by invoice number
|
||||
except: # noqa
|
||||
pass
|
||||
|
||||
object_list = self.model.objects.filter(filter).order_by('-invoice_date')
|
||||
|
||||
return object_list
|
||||
|
||||
|
||||
class InvoiceWaiting(generic.ListView):
|
||||
model = models.Event
|
||||
|
||||
Reference in New Issue
Block a user