testing popups

This commit is contained in:
Sanj 2012-07-11 18:55:54 +05:30
parent f44cd331a3
commit 93bab11ff7
5 changed files with 8 additions and 3 deletions

View File

@ -28,7 +28,7 @@ class ConnectionsWidget(forms.SelectMultiple):
def get_context(self, name, value, attrs, *args, **kwargs):
ctx = super(ConnectionsWidget, self).get_context(name, value, attrs)
ctx['popup_url'] = '/m/person/popup' #FIXME: url scheme, also, a better way to pass this context to the widget template.
#selected_values = [{'id': obj[0], 'text': obj[1]} for obj in self.choices if obj[0] in value]
#ctx['data_json'] = json.dumps(selected_values) # json.dumps(choices)
return ctx

View File

@ -13,6 +13,9 @@ def person_form(request):
#pdb.set_trace()
return render_to_response("test/person_form.html", {'form': form, 'inlines': inlines})
def personpopup(request):
form = PersonForm()
return render_to_response("test/popup.html", {'form': form})
def autocomplete(request):
q = request.GET.get('q', 'a')

View File

@ -1,2 +1,2 @@
<input type="hidden" id="id_{{name}}" name="{{name}}" class="select2class" value="{% for v in value %}{{ v }},{% endfor %}" style="width:600px;" />
<input type="hidden" id="id_{{name}}" name="{{name}}" class="select2class" value="{% for v in value %}{{ v }},{% endfor %}" style="width:600px;" /> <a href="/popups/{{name}}" id="add_{{name}}" onclick="return showAddPopup(this);">Add</a>

View File

@ -8,6 +8,7 @@
<link rel="stylesheet" href="/static/uni_form/uni-form.css" type="text/css" />
<link rel="stylesheet" href="/static/uni_form/default.uni-form.css" type="text/css" />
<link rel="stylesheet" href="/static/css/select2/select2.css" />
<script type="text/javascript" src="/admin/media/RelatedObjectLookups.js"></script>
<style type="text/css">
.select2-search-choice {
float: none !important;

View File

@ -38,9 +38,10 @@ urlpatterns = patterns('',
# ('^getLanguages', 'itfcore.views.getLanguages'),
# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
#Core views:
#Test views:
(r'test_profile', 'itfprofiles.views.person_form'),
(r'^autocompletes/itfprofiles/$', 'itfprofiles.views.autocomplete'),
(r'^m/person/popup', 'itfprofiles.views.personpopup'),
# (r'i/', include('itfcore.urls')),
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
(r'^search/', include('haystack.urls')),