# HG changeset patch # User cavaliet # Date 1377689791 -7200 # Node ID 047675624f4588af60bee89dce826f73eb102cee # Parent 63c5437a9b7d8ef68f06a8b666347315355845a9 first step of title search in list of records diff -r 63c5437a9b7d -r 047675624f45 src/p4l/forms.py --- a/src/p4l/forms.py Wed Aug 28 11:16:03 2013 +0200 +++ b/src/p4l/forms.py Wed Aug 28 13:36:31 2013 +0200 @@ -9,8 +9,10 @@ from django.contrib.auth.forms import (UserChangeForm as AuthUserChangeForm, UserCreationForm as AuthUserCreationForm) from django.core.exceptions import ValidationError -from django.forms.fields import ChoiceField +from django.forms import Form +from django.forms.fields import ChoiceField, CharField from django.utils.translation import ugettext as _ +from .models import Record User = get_user_model() @@ -34,3 +36,15 @@ language = ChoiceField(label=_("language"), choices=[(k,_(v)) for k,v in settings.LANGUAGES], initial=settings.LANGUAGE_CODE[:2]) class Meta: model = User + + +class RecordFilterForm(Form): + title = CharField(required=True, min_length=1) + def get_filter_qs(self, qs=None): + if qs is None: + qs = Record.objects.select_related("language").prefetch_related('titles') # @UndefinedVariable + t = self.cleaned_data.get('title',None) + if t: + qs = qs.filter(titles__title__icontains=t) + return qs + diff -r 63c5437a9b7d -r 047675624f45 src/p4l/models/data.py --- a/src/p4l/models/data.py Wed Aug 28 11:16:03 2013 +0200 +++ b/src/p4l/models/data.py Wed Aug 28 13:36:31 2013 +0200 @@ -162,16 +162,16 @@ class Record(P4lModel): uri = models.URLField(max_length=2048, unique=True, db_index=True) #subject - subjects = models.ManyToManyField('p4l.Subject') #dct:subject - themes = models.ManyToManyField('p4l.Theme') #iiep:theme - countries = models.ManyToManyField('p4l.Country') #iiep:country + subjects = models.ManyToManyField('p4l.Subject') #dct:subject # Thesaurus with no country + themes = models.ManyToManyField('p4l.Theme') #iiep:theme # Theme + countries = models.ManyToManyField('p4l.Country') #iiep:country # Thesaurus filtered with country only identifier = models.CharField(max_length=128, unique=True, db_index=True) #dct:identifier notes = models.TextField(blank=True, null=True) #iiep:notes #issns foreign key from Isbn #iiep:issn #isbns foreign key from Isbn #iiep:isbn #documentCodes foreign key from Isbn #iiep:documentCode - language = models.ForeignKey('p4l.Language', blank=True, null=True) #dct:language - otherLanguages = models.ManyToManyField('p4l.Language', related_name='otherLanguage_record') #iiep:otherLanguage + language = models.ForeignKey('p4l.Language', blank=True, null=True) #dct:language # Language + otherLanguages = models.ManyToManyField('p4l.Language', related_name='otherLanguage_record') #iiep:otherLanguage # Language #titles foreign Key from Title #dct:title #addedTitles foreign Key from AddedTitle #iiep:addedTitle #titlesMainDocument foreign Key from TitleMainDocument #iiep:titleMainDocument @@ -185,9 +185,9 @@ series = models.ManyToManyField('p4l.Serie', through='p4l.RecordSerie') #iiep:serie authors = models.ManyToManyField('p4l.Author') #iiep:author subjectPersons = models.ManyToManyField('p4l.SubjectPerson') #iiep:subjectPerson - subjectCorporateBodies = models.ManyToManyField('p4l.CorporateBody') #iiep:subjectCorporateBody + subjectCorporateBodies = models.ManyToManyField('p4l.CorporateBody') #iiep:subjectCorporateBody # Organisation ? subjectMeetings = models.ManyToManyField('p4l.SubjectMeeting') #iiep:subjectMeeting - corporateAuthors = models.ManyToManyField('p4l.CorporateAuthor') #iiep:corporateAuthor + corporateAuthors = models.ManyToManyField('p4l.CorporateAuthor') #iiep:corporateAuthor # Organisation ? #urls foreign Key from Url #iiep:url recordType = models.URLField(max_length=2048) #dct:type isDocumentPart = models.BooleanField() #iiep:isDocumentPart diff -r 63c5437a9b7d -r 047675624f45 src/p4l/static/p4l/css/p4l.css --- a/src/p4l/static/p4l/css/p4l.css Wed Aug 28 11:16:03 2013 +0200 +++ b/src/p4l/static/p4l/css/p4l.css Wed Aug 28 13:36:31 2013 +0200 @@ -6,3 +6,6 @@ margin: 0 auto; width: 950px; } +.table thead td:first-letter { + text-transform: uppercase; +} diff -r 63c5437a9b7d -r 047675624f45 src/p4l/templates/p4l/p4l_base.html --- a/src/p4l/templates/p4l/p4l_base.html Wed Aug 28 11:16:03 2013 +0200 +++ b/src/p4l/templates/p4l/p4l_base.html Wed Aug 28 13:36:31 2013 +0200 @@ -34,7 +34,7 @@ {% endblock %} {% block js_common %} - + {% endblock %} {% block js_page %} {% endblock %} diff -r 63c5437a9b7d -r 047675624f45 src/p4l/templates/p4l/p4l_home.html --- a/src/p4l/templates/p4l/p4l_home.html Wed Aug 28 11:16:03 2013 +0200 +++ b/src/p4l/templates/p4l/p4l_home.html Wed Aug 28 13:36:31 2013 +0200 @@ -1,6 +1,7 @@ {% extends "p4l/p4l_base.html" %} {% load static %} {% load i18n %} +{% load p4lstringfilters %} {% block content %}