예제 #1
0
def get_premise(request):
    """AJAX"""
    group, bridge = group_and_bridge(request)

    is_member = group.user_is_member(request.user)

    if not is_member:
        return HttpResponseForbidden("You must be a project member to do this")

    if request.method == 'POST':
        imp_pk = request.POST['imp_pk']
        try:
            attributes_ids = ExplorationWrapper.get_premise(group, int(imp_pk))
        except:
            return HttpResponse("reload")

        return HttpResponse(simplejson.dumps(list(attributes_ids),
                                             ensure_ascii=False),
                            mimetype='application/json')
    else:
        raise Http404
예제 #2
0
def reject_implication(request):
    group, bridge = group_and_bridge(request)
    is_member = group.user_is_member(request.user)

    if not is_member:
        return HttpResponseForbidden("You must be a project member to do this")

    if request.method == 'POST':
        try:
            object_name = request.POST['example_name']
            if len(object_name) == 0:
                raise Exception("Object's name can't be empty")
            imp_pk = int(request.POST['imp_pk'])
            intent = set()
            for key in request.POST:
                if key != 'example_name' and key != 'imp_pk':
                    intent.add(int(key))
            premise = ExplorationWrapper.get_premise(group, int(imp_pk))
            ExplorationWrapper.reject_implication_with_counterexample(
                group, imp_pk, object_name, premise | intent)
            status = 'ok'
        except Exception as details:
            status = str(details)
        else:
            if notification:
                notification.send(
                    group.member_users.all(), "attr_imp_reject", {
                        "user": request.user,
                        "project": group,
                        "counterexample_name": object_name,
                    })
        return HttpResponse(simplejson.dumps({'status': status},
                                             ensure_ascii=False),
                            mimetype='application/json')
    else:
        raise Http404