Search engine scraper-aggregator For some reason, I completely lost my reasoning with this code. I can't hold this simple logic for too long in my head. Actually, I want to improve this code, making it a little concise. The if (so.scan_complete and force) or not so.scan_complete: is just not a KISS thing. Please any suggesion to optimize and concise it?

source = request.POST.get('source')
queries = request.POST.get('term')

force = request.POST.get('rescan', False) # if checkbox is checked this becomes True

queries = [query.strip().lower() for query in queries.split(',')]
engines = ['alibaba', 'madeinchina', 'google', 'bing']
for src in engines:
    for query in queries:
        so = Source.objects.get(term__term=query, engine=src)
        if src == 'alibaba':
            if (so.scan_complete and force) or not so.scan_complete:
                ali_results.delay(src, query)
        elif src == 'madeinchina':
            if (so.scan_complete and force) or not so.scan_complete:
                made_results.delay(src, query)
        elif src == "google" or src == "bing":
            if (so.scan_complete and force) or not so.scan_complete:
                search_engine_scraper.delay(query=query, source=src)
The test if (so.scan_complete and force) or not so.scan_complete: only fails when so.scan_complete is True and force is False. So it can be simplified to if force or not so.scan_complete:.

Also, since the test is identical for every src, it only needs to be done once:

for src in engines:
    for query in queries:
        so = Source.objects.get(term__term=query, engine=src)
        if force or not so.scan_complete:
            if src == 'alibaba':
                ali_results.delay(src, query)
            elif src == 'madeinchina':
                made_results.delay(src, query)
            elif src == "google" or src == "bing":
                search_engine_scraper.delay(query=query, source=src)