示例#1
0
文件: tests.py 项目: TheDr1ver/crits
 def testChangingReason(self):
     relationship1 = self.campaign1.relationships[0]
     relationship2 = self.campaign2.relationships[0]
     self.assertEqual(relationship1.rel_reason, "")
     self.assertEqual(relationship2.rel_reason, "")
     update_relationship_reasons(left_class=self.campaign1,
                                 right_class=self.campaign2,
                                 rel_type=TRELATIONSHIP_TYPE,
                                 analyst=self.user2.username,
                                 new_reason=TRELATIONSHIP_NEW_REASON)
     campaign1 = Campaign.objects.get(id=self.campaign1.id)
     campaign2 = Campaign.objects.get(id=self.campaign2.id)
     relationship1 = campaign1.relationships[0]
     relationship2 = campaign2.relationships[0]
     self.assertEqual(relationship1.rel_reason, TRELATIONSHIP_NEW_REASON)
     self.assertEqual(relationship2.rel_reason, TRELATIONSHIP_NEW_REASON)
示例#2
0
文件: views.py 项目: armtash/crits
def update_relationship_reason(request):
    """
    Update relationship reason. Should be an AJAX POST.

    :param request: Django request object (Required)
    :type request: :class:`django.http.HttpRequest`
    :returns: :class:`django.http.HttpResponse`
    """
    if request.method == 'POST' and request.is_ajax():
        results = update_relationship_reasons(left_type=request.POST['my_type'],
                                            left_id=request.POST['my_value'],
                                            right_type=request.POST['reverse_type'],
                                            right_id=request.POST['dest_id'],
                                            rel_type=request.POST['forward_relationship'],
                                            rel_date=request.POST['relationship_date'],
                                            analyst=request.user.username,
                                            new_reason=request.POST['new_reason'])
        if results['success']:
            message = "Successfully updated relationship: %s" % results['message']
            result = {'success': True, 'message': message}
        else:
            message = "Error updating relationship: %s" % results['message']
            result = {'success': False, 'message': message}
        return HttpResponse(json.dumps(result), content_type="application/json")
    else:
        error = "Expected AJAX POST"
        return render(request, "error.html",
                                  {"error" : error })
示例#3
0
 def testChangingReason(self):
     relationship1 = self.campaign1.relationships[0]
     relationship2 = self.campaign2.relationships[0]
     self.assertEqual(relationship1.rel_reason, "N/A")
     self.assertEqual(relationship2.rel_reason, "N/A")
     update_relationship_reasons(left_class=self.campaign1,
                                 right_class=self.campaign2,
                                 rel_type=TRELATIONSHIP_TYPE,
                                 analyst=self.user2.username,
                                 new_reason=TRELATIONSHIP_NEW_REASON)
     campaign1 = Campaign.objects.get(id=self.campaign1.id)
     campaign2 = Campaign.objects.get(id=self.campaign2.id)
     relationship1 = campaign1.relationships[0]
     relationship2 = campaign2.relationships[0]
     self.assertEqual(relationship1.rel_reason, TRELATIONSHIP_NEW_REASON)
     self.assertEqual(relationship2.rel_reason, TRELATIONSHIP_NEW_REASON)
示例#4
0
def update_relationship_reason(request):
    """
    Update relationship reason. Should be an AJAX POST.

    :param request: Django request object (Required)
    :type request: :class:`django.http.HttpRequest`
    :returns: :class:`django.http.HttpResponse`
    """
    if request.method == 'POST' and request.is_ajax():
        results = update_relationship_reasons(left_type=request.POST['my_type'],
                                            left_id=request.POST['my_value'],
                                            right_type=request.POST['reverse_type'],
                                            right_id=request.POST['dest_id'],
                                            rel_type=request.POST['forward_relationship'],
                                            rel_date=request.POST['relationship_date'],
                                            analyst=request.user.username,
                                            new_reason=request.POST['new_reason'])
        if results['success']:
            message = "Successfully updated relationship: %s" % results['message']
            result = {'success': True, 'message': message}
        else:
            message = "Error updating relationship: %s" % results['message']
            result = {'success': False, 'message': message}
        return HttpResponse(json.dumps(result), mimetype="application/json")
    else:
        error = "Expected AJAX POST"
        return render_to_response("error.html",
                                  {"error" : error },
                                  RequestContext(request))