예제 #1
0
def api_current(request):
    snapshot = public_snapshot()
    data = dict()
    filename_base = snapshot.dump_filename_base()
    data['json_url'] = settings.MEDIA_URL + "dumps/" + filename_base + ".json"
    data['zip_url'] = settings.MEDIA_URL + "dumps/" + filename_base + ".zip"
    json = dumps(data)
    return HttpResponse(json, content_type="application/json")
예제 #2
0
def search(request):
    q = request.GET.get('q', '')
    if q == '':
        return HttpResponseRedirect("/")

    snapshot = public_snapshot()
    charges = Charge.objects.filter(
        snapshot=snapshot,
        label__icontains=q) | Charge.objects.filter(snapshot=snapshot,
                                                    penal_code__icontains=q)
    charges = [c for c in charges if c.is_leaf()]
    return render(request, 'law/search.html', dict(charges=charges))
예제 #3
0
 def snapshot(self):
     return public_snapshot()
예제 #4
0
 def get_context_data(self, **kwargs):
     snapshot = public_snapshot()
     return dict(charges=snapshot.top_level_charges())
예제 #5
0
 def get_context_data(self, *args, **kwargs):
     return dict(snapshots=Snapshot.objects.all(),
                 working_snapshot=working_snapshot(),
                 public_snapshot=public_snapshot())