added identifier option to search
This commit is contained in:
		
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							@@ -6,7 +6,7 @@ from django.contrib.auth.models import User
 | 
			
		||||
class SearchForm(forms.Form):
 | 
			
		||||
    title = forms.CharField(label="Title", max_length=200)
 | 
			
		||||
    author = forms.CharField(label='Author', max_length=100)
 | 
			
		||||
    # identifier = forms.CharField(label='Identifier(ISBN, Google-id, amazon id)', max_length=20)
 | 
			
		||||
    identifier = forms.CharField(label='Identifier(ISBN, Google-id, amazon id)', max_length=20)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -57,7 +57,7 @@ class Data(models.Model):
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Identifier(models.Model):
 | 
			
		||||
    book = models.IntegerField()
 | 
			
		||||
    book = models.ForeignKey("Book", db_column="book", on_delete=models.CASCADE)
 | 
			
		||||
    type = models.TextField()
 | 
			
		||||
    val = models.TextField()
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,8 @@
 | 
			
		||||
    <input id="title" type="text" name="title" value="">
 | 
			
		||||
    <label for="author">Author: </label>
 | 
			
		||||
    <input id="author" type="text" name="author" value="">
 | 
			
		||||
    <label for="author">Identifier: </label>
 | 
			
		||||
    <input id="identifier" type="text" name="identifier" value="">
 | 
			
		||||
    <button class="waves-effect waves-light btn green accent-4" type="submit">search</button>
 | 
			
		||||
</form>
 | 
			
		||||
</div>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
from django.shortcuts import render
 | 
			
		||||
from django.views import generic
 | 
			
		||||
from .models import Author, Book, Comment, Rating, BookAuthorLink, Publisher, Tag, BookTagLink, BookRatingLink, Data
 | 
			
		||||
from .models import Author, Book, Comment, Rating, BookAuthorLink, Publisher, Tag, BookTagLink, BookRatingLink, Data, Identifier
 | 
			
		||||
from django.http import HttpResponseRedirect
 | 
			
		||||
from .forms import SearchForm, UserCreationForm
 | 
			
		||||
from django.db import models
 | 
			
		||||
@@ -40,11 +40,14 @@ class ResultsView(generic.ListView):  # no clue if this is secure.
 | 
			
		||||
    def get_queryset(self):  # new
 | 
			
		||||
        title = self.request.GET.get('title')
 | 
			
		||||
        author = self.request.GET.get('author')
 | 
			
		||||
        identifier = self.request.GET.get("identifier")
 | 
			
		||||
        books = Book.objects.prefetch_related("tags", "ratings")
 | 
			
		||||
        if title:
 | 
			
		||||
            books =books.filter(sort__icontains=title)
 | 
			
		||||
        if author:
 | 
			
		||||
            books = books.filter(author_sort__icontains=author)
 | 
			
		||||
        if identifier:
 | 
			
		||||
            books = books.filter(identifier__val=identifier)
 | 
			
		||||
        return books
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user