allow fts search on foreign key / fix DocumentSubject search
This commit is contained in:
parent
4ee0e66859
commit
53d93b318c
|
@ -205,7 +205,7 @@ class ItfModel(models.Model):
|
|||
qstring = f + '__icontains'
|
||||
qobject = Q(**{qstring:t})
|
||||
qobjects.append(qobject)
|
||||
return qset.filter(reduce(operator.or_, qobjects))
|
||||
return qset.filter(reduce(operator.or_, qobjects)).distinct()
|
||||
|
||||
|
||||
'''
|
||||
|
|
|
@ -266,6 +266,7 @@ class DocumentSubject(ItfModel):
|
|||
title = models.CharField(max_length=255)
|
||||
main_image = models.ImageField(upload_to='upload/images/festival/main/', blank=True, null=True)
|
||||
|
||||
fts_fields = ['title', 'document__title', 'document__intro']
|
||||
def __unicode__(self):
|
||||
return self.title
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ import floppyforms as forms
|
|||
from registration.forms import RegistrationForm
|
||||
from models import *
|
||||
from registration.models import RegistrationProfile
|
||||
import json
|
||||
|
||||
class ItfRegistrationForm(RegistrationForm):
|
||||
subscribe = forms.BooleanField(help_text='Subscribe to newsletter?')
|
||||
|
@ -14,11 +15,32 @@ class ItfRegistrationForm(RegistrationForm):
|
|||
|
||||
|
||||
|
||||
class ConnectionsWidget(forms.SelectMultiple):
|
||||
template_name = 'formwidgets/select2_multiple.html'
|
||||
|
||||
'''
|
||||
def get_context_data(self):
|
||||
ctx = super(ConnectionsWidget, self).get_context_data()
|
||||
|
||||
#ctx['data_json'] = [{'id': obj[0], 'text': obj[1]} for obj in self.choices]
|
||||
return ctx
|
||||
'''
|
||||
|
||||
def get_context(self, name, value, attrs, *args, **kwargs):
|
||||
import pdb
|
||||
pdb.set_trace()
|
||||
ctx = super(ConnectionsWidget, self).get_context(name, value, attrs)
|
||||
ctx['data_json'] = "hi" # json.dumps(choices)
|
||||
return ctx
|
||||
|
||||
|
||||
#Actual person form definition
|
||||
class PersonForm(forms.ModelForm):
|
||||
# occupations = forms.ModelMultipleChoiceField(Occupation.objects.all(), widget=forms.CheckboxSelectMultiple())
|
||||
connections = forms.ModelMultipleChoiceField(Person.objects.all(), widget=ConnectionsWidget())
|
||||
# occupations = forms.ModelMultipleChoiceField(Occupation.objects.all(), widget=forms.CheckboxSelectMultiple())
|
||||
email = forms.EmailField(widget=forms.EmailInput(attrs={'placeholder': 'john@example.com'}))
|
||||
|
||||
|
||||
# inlines = [ConnectionFormset, ProductionFormset]
|
||||
class Meta:
|
||||
model = Person
|
||||
|
@ -27,6 +49,6 @@ class PersonForm(forms.ModelForm):
|
|||
'last_name': forms.TextInput,
|
||||
'occupations': forms.CheckboxSelectMultiple
|
||||
}
|
||||
exclude = ('connections', 'productions')
|
||||
#exclude = ('connections', 'productions')
|
||||
|
||||
|
||||
|
|
|
@ -6,7 +6,9 @@ from ox.django.shortcuts import render_to_json_response
|
|||
from django.core.paginator import Paginator, InvalidPage, EmptyPage
|
||||
|
||||
def person_form(request):
|
||||
return render_to_response("test/person_form.html", {'form': PersonForm})
|
||||
person = Person.objects.all()[0]
|
||||
form = PersonForm(instance=person)
|
||||
return render_to_response("test/person_form.html", {'form': form})
|
||||
|
||||
|
||||
def autocomplete(request):
|
||||
|
|
|
@ -108,9 +108,7 @@ $(function(){
|
|||
})();
|
||||
|
||||
if (deletedItem) {
|
||||
if (!confirm("are you sure you wish to delete?")) {
|
||||
$this.select2("val",
|
||||
}
|
||||
|
||||
console.log("deleted", deletedItem);
|
||||
}
|
||||
|
||||
|
@ -149,7 +147,7 @@ $(function(){
|
|||
<div id="searchContainer">
|
||||
<form id="formItf" action="" class="uniForm" method="POST">
|
||||
<div>
|
||||
<input type="hidden" data-placeholder="Choose Connections" id="id_connections" name="connections" style="width:600px" />
|
||||
<!-- <input type="hidden" data-placeholder="Choose Connections" id="id_connections" name="connections" style="width:600px" /> -->
|
||||
</div>
|
||||
{{ form|crispy }}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user