Hi,
i´m programming an exlusion search for django but my code is not
working. I think the functions are okay but django is not accepting
them / running them. Only my ajaxwindow comes.
When i start this tag search an ajax window will pop up and i can
choose tags from 2 boxes. In the first box are tags that i want to
have and in the second box are tags that the companys / persons do not
have in thair tags. I only want companys shown after my search that
have tags from box 1 and not from box 2.
Sorry for my english but do you guys get it? I hope :-)
So here is my code, hope you can help me why it is not working.
Thx for your help!
Chris
admin.py
Code:
tag_search.short_description = "Tag Search"
def export_selected_objects(modeladmin, request, queryset):
selected = request.POST.getlist(admin.ACTION_CHECKBOX_NAME)
ct = ContentType.objects.get_for_model(queryset.model)
return HttpResponseRedirect("/admin/comcsv/?ct=%s&ids=%s" % (ct.pk,
",".join(selected)))
views.py
Code:
def tag_search(request):
message = request.GET.get('key')
if(message == 'Company'):
c = '<form action="/admin/Company/company/" method="post">
<p style="margin-left:50px;text-align:left;"></p>'
a = ComSearchFormEin()
b = ComSearchFormAus()
b = c+'<div style="margin-left:50px;margin-right:<40px;text-
align:left;">'+a.as_table()+'
</div><div style="margin-left:50px;margin-
right:<40px;text-align:left;">'+b.as_table()+'
</div><br/><input type="submit" value="Ok"/></form>'
return HttpResponse(b, mimetype="text/html")
change_list.html
Code:
function newTag(){
boxes = document.forms[1]._selected_action.length;
companyids = "";
for (i = 0; i < boxes; i++){
if (document.forms[1]._selected_action[i].checked){
companyids = companyids + ","+ document.forms
[1]._selected_action[i].value;
}
}
tagids = "";
selects = document.getElementById("id_tags").options.length;
for(i = 0;i < selects;i++){
if(document.getElementById("id_tags").options[i].selected ==
true){
tagids = tagids +","+ document.getElementById
("id_tags").options[i].value;
}
}
companyids = companyids+":"+tagids;
site = "{{ cl.opts.verbose_name_plural|capfirst }}";
if(site == "Person"){
ajaxpack.getAjaxRequest('/admin/newpertag/',
'key='+companyids, reLoad, 'txt');
}
else if(site == "Company"){
ajaxpack.getAjaxRequest('/admin/newtag/', 'key='+companyids,
reLoad, 'txt');
}
}
unction sendSearch(){
tagidsein = "";
selectsein = document.getElementById("id_ein").options.length;
for(i = 0;i < selectsein;i++){
if(document.getElementById("id_ein").options.selected == true)
{
tagidsein = tagidsein +","+ document.getElementById
("id_ein").options.value;
}
}
tagidsaus = "";
selectsaus = document.getElementById("id_aus").options.length;
for(i = 0;i < selectsaus;i++){
if(document.getElementById("id_aus").options.selected == true)
{
tagidsaus = tagidsaus +","+ document.getElementById
("id_aus").options.value;
}
}
ids = tagidsein+":"+tagidsaus;
alert("/admin/Company/company/?ids="+ids);
window.location.href="/admin/gelb/?ids="+ids;
}
function comSearch(){
var myajax=ajaxpack.ajaxobj
var myfiletype=ajaxpack.filetype
if (myajax.readyState == 4){
if (myajax.status==200 || window.location.href.indexOf("http")
==-1){
// if we got something show it
if (myajax.responseText.length > 3){
showDialog('Tag Ausschluss Suche',"<div style='padding-top:
30px;text-align:center;'>"+myajax.responseText,'prompt');
}
}
}
}
$(document).ready(function() {
$("[name=action]").change( function() {
site = "{{ cl.opts.verbose_name_plural|capfirst }}";
if($("[name=action]").val() == "new_tag"){
if(site == "Company"){
ajaxpack.getAjaxRequest('/admin/newtag/', 'key=
{{ cl.opts.verbose_name_plural|capfirst }}', processGetPost, 'txt');
}
}
if($("[name=action]").val() == "tag_search"){
if(site == "Company"){
ajaxpack.getAjaxRequest('/admin/comsearch/', 'key=
{{ cl.opts.verbose_name_plural|capfirst }}', comSearch, 'txt');
}
}
});
});
function reLoad(){
var myajax=ajaxpack.ajaxobj
var myfiletype=ajaxpack.filetype
if (myajax.readyState == 4){
if (myajax.status==200 || window.location.href.indexOf("http")
==-1){
// if we got something show it
if (myajax.responseText.length > 3){
location.reload();
}
}
}
}
function processGetPost(){
var myajax=ajaxpack.ajaxobj
var myfiletype=ajaxpack.filetype
if (myajax.readyState == 4){
if (myajax.status==200 || window.location.href.indexOf("http")
==-1){
// if we got something show it
if (myajax.responseText.length > 3){
showDialog('Tag/Tags hinzufügen',"<div style='padding-
top:30px;text-align:center;>
"+myajax.responseText+"<br/><br/><input type='button'
value='Ok' onclick='newTag();'/></div>",'prompt');
}
}
}
}
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=.