@login_required
@no_cache
def toggle_requester_status(request, id):
    rp, created = RequesterProfile.objects.get_or_create(requester_id=id)
    rp.is_public = not rp.is_public

    solr = pysolr.Solr(settings.SOLR_MAIN)
    if rp.is_public:
        # add hitgroups to solr index
        IndexQueue.objects.add_requester(rp.requester_id)

        # indexing large amount of data during single request might not be the
        # best idea...
        #hitgroups = HitGroupContent.objects.filter(requester_id=rp.requester_id)
        #log.debug('adding HitGroupContent objects to solr index: %s',
        #        [hg.group_id for hg in hitgroups])
        #solr.add([_hitgroup_content_to_sorl_dt(hg) for hg in hitgroups])
    else:
        # remove hitgroups from solr index
        solr.delete(q='requester_id:"%s"' % rp.requester_id)
        IndexQueue.objects.del_requester(rp.requester_id)
        log.debug('deleting HitGroupContent objects from solr index: %s',
                rp.requester_id)
    rp.save()
    return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))
Toggle given requester private/public status
dataset/ETHPy150Open ipeirotis/Mturk-Tracker/app/mturk/main/admin.py/toggle_requester_status