Commit 7f7423b8 authored by Dmitry Shelepnev's avatar Dmitry Shelepnev
Browse files

Add Doubles search

parent c15d50c9
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
			<td style="font-size:80%; padding:1rem 1rem;">
				<b>Название книги:</b> {{ b.title }} <br>
				{% if b.authors.count > 0 %}
				   <b>Авторы:</b>{% for a in b.authors %} {{a.last_name}} {{a.first_name}}{% if not forloop.last %},{%endif%} {%endfor%}<br>
				   <b>Авторы:</b>{% for a in b.authors %} <a href="{% url "web:searchbooks" %}?searchtype=a&searchterms={{a.id}}">{{a.last_name}} {{a.first_name}}</a>{% if not forloop.last %},{%endif%} {%endfor%}<br>
				{% endif %}
				{% if b.genres.count > 0 %}
				   <b>Жанры:</b>{% for g in b.genres %} {{g.subsection}}{% if not forloop.last %},{%endif%} {%endfor%} <br>
@@ -29,7 +29,7 @@
				<b>Размер файла:</b> {{ b.filesize }}Кб.<br>
				<b>Дата правки:</b> {{ b.docdate }} <br>	
				{% if b.doubles > 0 %}
				<b>Дубликаты книги: </b> {{ b.title }} ({{b.doubles}}шт.)
				<b>Дубликаты книги: </b> <a href="{% url "web:searchbooks" %}?searchtype=d&searchterms={{b.id}}">{{ b.title }} ({{b.doubles}}шт.)</a>
				{% endif %}
			</td>
			</tr>
+9 −1
Original line number Diff line number Diff line
@@ -34,6 +34,14 @@ def SearchBooksView(request):
            except:
                author_id = 0
            books = Book.objects.filter(authors=author_id)      
        # Поиск дубликатов для книги            
        elif searchtype == 'd':
            #try:
            book_id = int(searchterms)
            mbook = Book.objects.get(id=book_id)
            books = Book.objects.filter(title__iexact=mbook.title, authors__in=mbook.authors.all()).exclude(id=book_id)
            #except:
            #    books={}                    
        
        if len(books)>0:
            books = books.prefetch_related('authors','genres','series').order_by('title','authors','-docdate')