woo hoo! autocomplete input on rightsholder creation form. uses app django-selectable
parent
296cbf1488
commit
6cc05817a8
|
@ -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)
|
|
@ -2,8 +2,12 @@ from django import forms
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from decimal import Decimal as D
|
from decimal import Decimal as D
|
||||||
|
from selectable.forms import AutoCompleteSelectWidget,AutoCompleteSelectField
|
||||||
|
|
||||||
from regluit.core.models import UserProfile, RightsHolder, Claim
|
from regluit.core.models import UserProfile, RightsHolder, Claim
|
||||||
|
from regluit.core.lookups import OwnerLookup
|
||||||
|
|
||||||
class ClaimForm(forms.ModelForm):
|
class ClaimForm(forms.ModelForm):
|
||||||
i_agree=forms.BooleanField()
|
i_agree=forms.BooleanField()
|
||||||
|
@ -13,6 +17,13 @@ class ClaimForm(forms.ModelForm):
|
||||||
widgets = { 'user': forms.HiddenInput, 'work': forms.HiddenInput }
|
widgets = { 'user': forms.HiddenInput, 'work': forms.HiddenInput }
|
||||||
|
|
||||||
class RightsHolderForm(forms.ModelForm):
|
class RightsHolderForm(forms.ModelForm):
|
||||||
|
owner = AutoCompleteSelectField(
|
||||||
|
OwnerLookup,
|
||||||
|
label='Owner',
|
||||||
|
widget=AutoCompleteSelectWidget(OwnerLookup),
|
||||||
|
required=True,
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = RightsHolder
|
model = RightsHolder
|
||||||
|
|
||||||
|
@ -20,10 +31,10 @@ class RightsHolderForm(forms.ModelForm):
|
||||||
rights_holder_name = self.data["rights_holder_name"]
|
rights_holder_name = self.data["rights_holder_name"]
|
||||||
try:
|
try:
|
||||||
RightsHolder.objects.get(rights_holder_name__iexact=rights_holder_name)
|
RightsHolder.objects.get(rights_holder_name__iexact=rights_holder_name)
|
||||||
except User.DoesNotExist:
|
except RightsHolder.DoesNotExist:
|
||||||
return rights_holder_name
|
return rights_holder_name
|
||||||
raise forms.ValidationError(_("Another rights holder with that name already exists."))
|
raise forms.ValidationError(_("Another rights holder with that name already exists."))
|
||||||
|
|
||||||
class ProfileForm(forms.ModelForm):
|
class ProfileForm(forms.ModelForm):
|
||||||
clear_facebook=forms.BooleanField(required=False)
|
clear_facebook=forms.BooleanField(required=False)
|
||||||
clear_twitter=forms.BooleanField(required=False)
|
clear_twitter=forms.BooleanField(required=False)
|
||||||
|
|
|
@ -12,9 +12,12 @@
|
||||||
<link type="text/css" rel="stylesheet" href="/static/css/sitewide.css" />
|
<link type="text/css" rel="stylesheet" href="/static/css/sitewide.css" />
|
||||||
<link href="/static/css/book-panel.css" rel="stylesheet" type="text/css" />
|
<link href="/static/css/book-panel.css" rel="stylesheet" type="text/css" />
|
||||||
<link REL="SHORTCUT ICON" HREF="/static/images/favicon.ico">
|
<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/jquery-1.6.3.min.js"></script>
|
||||||
<script type="text/javascript" src="/static/js/book-panel.js"></script>
|
<script type="text/javascript" src="/static/js/book-panel.js"></script>
|
||||||
{% block extra_head %}{% endblock %}
|
{% endblock %}
|
||||||
|
{% block extra_head %}
|
||||||
|
{% endblock %}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -1,4 +1,12 @@
|
||||||
{% extends "basedocumentation.html" %}
|
{% 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 %}
|
{% block doccontent %}
|
||||||
|
|
||||||
|
@ -13,10 +21,12 @@
|
||||||
|
|
||||||
<h2> Accepted Rights Holders </h2>
|
<h2> Accepted Rights Holders </h2>
|
||||||
{% for rights_holder in rights_holders %}
|
{% 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/>
|
PSA #: {{ rights_holder.id }}<br/>
|
||||||
email: {{ rights_holder.email }}<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 %}
|
{% endfor %}
|
||||||
|
|
||||||
{% if pending %}
|
{% if pending %}
|
||||||
|
@ -37,7 +47,7 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</form>
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
active:{{ active_data.count }}
|
|
||||||
{% if active_data.count %}
|
{% if active_data.count %}
|
||||||
<h2> Active Claims </h2>
|
<h2> Active Claims </h2>
|
||||||
{% for claim in active_data %}
|
{% for claim in active_data %}
|
||||||
|
|
|
@ -17,3 +17,4 @@ mechanize
|
||||||
pyzotero
|
pyzotero
|
||||||
freebase
|
freebase
|
||||||
django-endless-pagination
|
django-endless-pagination
|
||||||
|
django-selectable
|
||||||
|
|
|
@ -109,6 +109,7 @@ INSTALLED_APPS = (
|
||||||
'tastypie',
|
'tastypie',
|
||||||
'djcelery',
|
'djcelery',
|
||||||
'endless_pagination',
|
'endless_pagination',
|
||||||
|
'selectable',
|
||||||
)
|
)
|
||||||
|
|
||||||
# A sample logging configuration. The only tangible logging
|
# A sample logging configuration. The only tangible logging
|
||||||
|
|
3
urls.py
3
urls.py
|
@ -11,5 +11,6 @@ urlpatterns = patterns('',
|
||||||
('^profiles/edit/$', 'profiles.views.edit_profile', {'form_class': ProfileForm,}),
|
('^profiles/edit/$', 'profiles.views.edit_profile', {'form_class': ProfileForm,}),
|
||||||
(r'^profiles/', include('profiles.urls')),
|
(r'^profiles/', include('profiles.urls')),
|
||||||
(r'', include('regluit.frontend.urls')),
|
(r'', include('regluit.frontend.urls')),
|
||||||
(r'', include('regluit.payment.urls'))
|
(r'', include('regluit.payment.urls')),
|
||||||
|
(r'^selectable/', include('selectable.urls')),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue