@login_required
@unique_session_or_json_redirect
def scoreplan(request, planid):
    """
    Validate a plan to allow for it to be shown in the leaderboard

    Parameters:
        request -- The HttpRequest, which includes the user.
        planid -- The plan to score.

    Returns:
        A JSON HttpResponse which includes a status, and if applicable,
        a reason why the plan couldn't be validated
    """
    note_session_activity(request)
    status = { 'success': False }
    plan = Plan.objects.get(pk=planid)

    criterion = ValidationCriteria.objects.filter(legislative_body=plan.legislative_body)
    status['success'] = True
    for criteria in criterion:
        try:
            score = ComputedPlanScore.compute(criteria.function, plan)
        except:
            logger.debug(traceback.format_exc())

        if not score or not score['value']:
            status['success'] = False
            status['message'] = (criteria.get_short_label(), criteria.get_long_description() or criteria.function.get_long_description()) % '<p>%s</p><p>%s</p>'
            break

    if status['success']:
        status['success'] = True
        status['message'] = _("Validation successful")

        # Set is_valid status on the plan
        plan.is_valid = True
        plan.save()

    return HttpResponse(json.dumps(status),mimetype='application/json')
dataset/ETHPy150Open PublicMapping/DistrictBuilder/django/publicmapping/redistricting/views.py/scoreplan/swapped operands of `%`