Esempio n. 1
0
def resource_find(request, template='depot/resource_find.html'):
    """docstring for resource_find"""

    results = locations = []
    centre = None
    pins = []
    # places = []
    result = request.REQUEST.get('result', '')
    if request.method == 'POST' or result:
        # result = request.REQUEST.get('result', '')
        if result == 'Cancel':
            return HttpResponseRedirect(reverse('resource-list'))
        form = FindResourceForm(request.REQUEST)
    
        if form.is_valid():
            results = form.results
            locations = form.locations
            centre = form.centre
            # pins = [loc['obj'] for loc in locations]
            
    else:
        form = FindResourceForm(initial={'post_code': 'aberdeen', 'boost_location': settings.SOLR_LOC_BOOST_DEFAULT})

    # print places
    return render_to_response(template,
        RequestContext( request, { 'form': form, 'results': results, 'locations': locations, 'centre': centre, 'pins': pins, 'yahoo_appid': settings.YAHOO_KEY, 'google_key': settings.GOOGLE_KEY }))
Esempio n. 2
0
def resource_find(request, template='depot/resource_find.html'):
    """docstring for resource_find"""

    results = locations = []
    centre = None
    pins = []
    # places = []
    result = request.REQUEST.get('result', '')
    if request.method == 'POST' or result:
        # result = request.REQUEST.get('result', '')
        if result == 'Cancel':
            return HttpResponseRedirect(reverse('resource-list'))
        form = FindResourceForm(request.REQUEST)

        if form.is_valid():
            user = get_account(request.user.id)
            for result in form.results:
                resource = get_one_or_404(id=ObjectId(result['res_id']))

                try:
                    curation_index, curation = get_curation_for_user_resource(
                        user, resource)
                except TypeError:
                    curation_index = curation = None

                curation_form = CurationForm(initial={'outcome': STATUS_OK},
                                             instance=curation)
                results.append({
                    'resource_result': result,
                    'curation': curation,
                    'curation_form': curation_form,
                    'curation_index': curation_index
                })
            locations = form.locations
            centre = form.centre
            # pins = [loc['obj'] for loc in locations]

    else:
        form = FindResourceForm(
            initial={
                'post_code': 'aberdeen',
                'boost_location': settings.SOLR_LOC_BOOST_DEFAULT
            })

    # print places
    context = {
        'form': form,
        'results': results,
        'locations': locations,
        'centre': centre,
        'pins': pins,
        'yahoo_appid': settings.YAHOO_KEY,
        'google_key': settings.GOOGLE_KEY,
    }
    return render_to_response(template, RequestContext(request, context))
Esempio n. 3
0
def resource_find(request, template='depot/resource_find.html'):
    """docstring for resource_find"""

    results = locations = []
    centre = None
    pins = []
    # places = []
    result = request.REQUEST.get('result', '')
    if request.method == 'POST' or result:
        # result = request.REQUEST.get('result', '')
        if result == 'Cancel':
            return HttpResponseRedirect(reverse('resource-list'))
        form = FindResourceForm(request.REQUEST)

        if form.is_valid():
            user = get_account(request.user.id)
            for result in form.results:
                resource = get_one_or_404(id=ObjectId(result['res_id']))

                try:
                    curation_index, curation = get_curation_for_user_resource(user, resource)
                except TypeError:
                    curation_index = curation = None

                curation_form = CurationForm(
                        initial={'outcome': STATUS_OK},
                        instance=curation)
                results.append({
                    'resource_result': result,
                    'curation': curation,
                    'curation_form': curation_form,
                    'curation_index': curation_index
                })
            locations = form.locations
            centre = form.centre
            # pins = [loc['obj'] for loc in locations]

    else:
        form = FindResourceForm(initial={'post_code': 'aberdeen', 'boost_location': settings.SOLR_LOC_BOOST_DEFAULT})

    # print places
    context = {
        'form': form,
        'results': results,
        'locations': locations,
        'centre': centre,
        'pins': pins,
        'yahoo_appid': settings.YAHOO_KEY,
        'google_key': settings.GOOGLE_KEY,
    }
    return render_to_response(template, RequestContext(request, context))
Esempio n. 4
0
def resource_find(request, template="depot/resource_find.html"):
    """docstring for resource_find"""

    results = locations = []
    centre = None
    pins = []
    # places = []
    result = request.REQUEST.get("result", "")
    if request.method == "POST" or result:
        # result = request.REQUEST.get('result', '')
        if result == "Cancel":
            return HttpResponseRedirect(reverse("resource-list"))
        form = FindResourceForm(request.REQUEST)

        if form.is_valid():
            user = get_account(request.user.id)
            for result in form.results:
                resource = get_one_or_404(id=ObjectId(result["res_id"]))

                try:
                    curation_index, curation = get_curation_for_user_resource(user, resource)
                except TypeError:
                    curation_index = curation = None

                curation_form = CurationForm(initial={"outcome": STATUS_OK}, instance=curation)
                results.append(
                    {
                        "resource_result": result,
                        "curation": curation,
                        "curation_form": curation_form,
                        "curation_index": curation_index,
                    }
                )

            locations = form.locations
            centre = form.centre
            # pins = [loc['obj'] for loc in locations]

    else:
        form = FindResourceForm(initial={"post_code": "aberdeen", "boost_location": settings.SOLR_LOC_BOOST_DEFAULT})

    context = {
        "form": form,
        "results": results,
        "locations": locations,
        "centre": centre,
        "pins": pins,
        "yahoo_appid": settings.YAHOO_KEY,
        "google_key": settings.GOOGLE_KEY,
    }
    return render_to_response(template, RequestContext(request, context))
Esempio n. 5
0
def resource_find(request, template="depot/resource_find.html"):
    """docstring for resource_find"""

    results = locations = []
    centre = None
    pins = []
    # places = []
    result = request.REQUEST.get("result", "")
    if request.method == "POST" or result:
        # result = request.REQUEST.get('result', '')
        if result == "Cancel":
            return HttpResponseRedirect(reverse("resource-list"))
        form = FindResourceForm(request.REQUEST)

        if form.is_valid():
            results = form.results
            locations = form.locations
            centre = form.centre
            # pins = [loc['obj'] for loc in locations]

    else:
        form = FindResourceForm(initial={"post_code": "aberdeen", "boost_location": settings.SOLR_LOC_BOOST_DEFAULT})

    # print places
    return render_to_response(
        template,
        RequestContext(
            request,
            {
                "form": form,
                "results": results,
                "locations": locations,
                "centre": centre,
                "pins": pins,
                "yahoo_appid": settings.YAHOO_KEY,
                "google_key": settings.GOOGLE_KEY,
            },
        ),
    )