woo hoo! autocomplete input on rightsholder creation form. uses app django-selectable

pull/1/head
eric 2011-11-18 09:22:21 -05:00
parent 296cbf1488
commit 6cc05817a8
7 changed files with 44 additions and 7 deletions

10
core/lookups.py Normal file
View File

@ -0,0 +1,10 @@
from selectable.base import ModelLookup
from selectable.registry import registry
from django.contrib.auth.models import User
class OwnerLookup(ModelLookup):
model = User
search_field = 'username__icontains'
registry.register(OwnerLookup)

View File

@ -2,8 +2,12 @@ from django import forms
from django.db import models
from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _
from decimal import Decimal as D
from selectable.forms import AutoCompleteSelectWidget,AutoCompleteSelectField
from regluit.core.models import UserProfile, RightsHolder, Claim
from regluit.core.lookups import OwnerLookup
class ClaimForm(forms.ModelForm):
i_agree=forms.BooleanField()
@ -13,6 +17,13 @@ class ClaimForm(forms.ModelForm):
widgets = { 'user': forms.HiddenInput, 'work': forms.HiddenInput }
class RightsHolderForm(forms.ModelForm):
owner = AutoCompleteSelectField(
OwnerLookup,
label='Owner',
widget=AutoCompleteSelectWidget(OwnerLookup),
required=True,
)
class Meta:
model = RightsHolder
@ -20,10 +31,10 @@ class RightsHolderForm(forms.ModelForm):
rights_holder_name = self.data["rights_holder_name"]
try:
RightsHolder.objects.get(rights_holder_name__iexact=rights_holder_name)
except User.DoesNotExist:
except RightsHolder.DoesNotExist:
return rights_holder_name
raise forms.ValidationError(_("Another rights holder with that name already exists."))
class ProfileForm(forms.ModelForm):
clear_facebook=forms.BooleanField(required=False)
clear_twitter=forms.BooleanField(required=False)

View File

@ -12,9 +12,12 @@
<link type="text/css" rel="stylesheet" href="/static/css/sitewide.css" />
<link href="/static/css/book-panel.css" rel="stylesheet" type="text/css" />
<link REL="SHORTCUT ICON" HREF="/static/images/favicon.ico">
{% block base_js %}
<script type="text/javascript" src="/static/js/jquery-1.6.3.min.js"></script>
<script type="text/javascript" src="/static/js/book-panel.js"></script>
{% block extra_head %}{% endblock %}
{% endblock %}
{% block extra_head %}
{% endblock %}
</head>
<body>

View File

@ -1,4 +1,12 @@
{% extends "basedocumentation.html" %}
{% block base_js %}{% endblock %}
{% block extra_head %}
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/themes/ui-lightness/jquery-ui.css" type="text/css" media="screen">
{{ form.media.css }}
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js"></script>
{{ form.media.js }}
{% endblock %}
{% block doccontent %}
@ -13,10 +21,12 @@
<h2> Accepted Rights Holders </h2>
{% for rights_holder in rights_holders %}
<h3>{{ rights_holder.rights_holder_name }}</h3>
<h3>{{ rights_holder.rights_holder_name }}</h3><p>
PSA #: {{ rights_holder.id }}<br/>
email: {{ rights_holder.email }}<br/>
owner: <a href="{% url supporter supporter_username=rights_holder.owner %}">{{ rights_holder.owner }}</a><br/>
owner: <a href="{% url supporter supporter_username=rights_holder.owner %}">{{ rights_holder.owner }}</a></p>
{% empty %}
<p>No rights holders have been accepted yet</p>
{% endfor %}
{% if pending %}
@ -37,7 +47,7 @@
{% endfor %}
</form>
{% endif %}
active:{{ active_data.count }}
{% if active_data.count %}
<h2> Active Claims </h2>
{% for claim in active_data %}

View File

@ -17,3 +17,4 @@ mechanize
pyzotero
freebase
django-endless-pagination
django-selectable

View File

@ -109,6 +109,7 @@ INSTALLED_APPS = (
'tastypie',
'djcelery',
'endless_pagination',
'selectable',
)
# A sample logging configuration. The only tangible logging

View File

@ -11,5 +11,6 @@ urlpatterns = patterns('',
('^profiles/edit/$', 'profiles.views.edit_profile', {'form_class': ProfileForm,}),
(r'^profiles/', include('profiles.urls')),
(r'', include('regluit.frontend.urls')),
(r'', include('regluit.payment.urls'))
(r'', include('regluit.payment.urls')),
(r'^selectable/', include('selectable.urls')),
)