Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

setup to support filteredmultipleselect and added a git ignore

  • Loading branch information...
commit 3f27606e18c7d4659a63d8cb9400b1139d382c48 1 parent d18784a
@sontek sontek authored
Showing with 17 additions and 16 deletions.
  1. +6 −0 .gitignore
  2. +11 −16 tekextensions/widgets.py
View
6 .gitignore
@@ -0,0 +1,6 @@
+*.pyc
+*.pyo
+*.db
+*.swp
+local_settings.py
+haystack/
View
27 tekextensions/widgets.py
@@ -1,14 +1,15 @@
from django import forms
from django.template.loader import render_to_string
+from django.contrib.admin.widgets import FilteredSelectMultiple
-class MultipleSelectWithPopUp(forms.SelectMultiple):
- def __init__(self, model=None, template='addnew.html'):
+class PopUpBaseWidget(object):
+ def __init__(self, model=None, template='addnew.html', *args, **kwargs):
self.model = model
self.template = template
- super(MultipleSelectWithPopUp, self).__init__()
+ super(PopUpBaseWidget, self).__init__(*args, **kwargs)
def render(self, name, *args, **kwargs):
- html = super(MultipleSelectWithPopUp, self).render(name, *args, **kwargs)
+ html = super(PopUpBaseWidget, self).render(name, *args, **kwargs)
if not self.model:
self.model = name
@@ -16,17 +17,11 @@ def render(self, name, *args, **kwargs):
popupplus = render_to_string(self.template, {'field': name, 'model': self.model})
return html+popupplus
-class SelectWithPopUp(forms.Select):
- def __init__(self, model=None, template='addnew.html'):
- self.model = model
- self.template = template
- super(SelectWithPopUp, self).__init__()
-
- def render(self, name, *args, **kwargs):
- html = super(SelectWithPopUp, self).render(name, *args, **kwargs)
+class FilteredMultipleSelectWithPopUp(PopUpBaseWidget, FilteredSelectMultiple):
+ pass
- if not self.model:
- self.model = name
+class MultipleSelectWithPopUp(PopUpBaseWidget, forms.SelectMultiple):
+ pass
- popupplus = render_to_string(self.template, {'field': name, 'model': self.model})
- return html+popupplus
+class SelectWithPopUp(PopUpBaseWidget, forms.Select):
+ pass
Please sign in to comment.
Something went wrong with that request. Please try again.