Ejemplo n.º 1
0
 def post(self, request):
     status = Status.objects.create(payment_status="Pending",
                                    order_status="Pending",
                                    delivery_status="Pending",
                                    message_status="Pending")
     status.save()
     return Response({"success": "status update created successfully"})
    def put(self, request, order=None):
        orderstatus = StatusModel.objects.get(order=order)
        if orderstatus.status == "Created":
            status = StatusModel.objects.get(order_id=order)
            status.status = "Issued"
            status.save()

        return self.partial_update(request, order)
Ejemplo n.º 3
0
 def add_circle_status(self, request, *args, **kwargs):
     serializer = StatusSerializer(data=self.request.DATA)
     if serializer.is_valid():
         status = serializer.object
         status = serializer.save(force_insert=True)
         status.target_cirlce = self.parent
         status.owner = self.user
         header = {'Location': serializer.data['url']}
         status.save()
         return Response(data=serializer(status), header=header,
                         status=status.HTTP_201_CREATED)
     return Response(serializer.error, status=status.HTTP_400_BAD_REQUEST)
Ejemplo n.º 4
0
def status_order(request, company_slug, status_id):
    """
    Card Order for kanban. Currently not being used on the frontend...
    """
    status = get_object_or_404(Status, pk=status_id)

    if not has_admin_permission(
            request.user,
            status.company) and status.created_by != request.user:
        return HttpResponseForbidden()

    if request.data.get('order'):
        status.order = request.data.get('order')

    status.save()
    return Response(status=status.HTTP_200_OK)
    def test_downtime_metric(self):
        # Setup
        self.session = None
        dt = datetime(2017, 1, 1, tzinfo=timezone.utc)

        self.primary_service.up = False
        self.primary_service.save()

        # last up status
        status = self.make_status()
        status.created_at = dt - timedelta(minutes=65)
        status.save()

        # up status that's a little bit older
        status = self.make_status()
        status.created_at = dt - timedelta(minutes=90)
        status.save()

        # newer down status
        status = self.make_status()
        status.created_at = dt - timedelta(minutes=20)
        status.up = False
        status.save()

        # mock health lookup
        responses.add(
            responses.GET,
            'http://example.org/api/health/',
            json={
                "up": True,
                "result": {
                    "database": "Response in <0.1> seconds"
                }
            },
            status=200, content_type='application/json',
        )

        responses.add(responses.POST,
                      "http://metrics-url/metrics/",
                      json={"foo": "bar"},
                      status=200, content_type='application/json')

        # Execute
        with patch.object(timezone, 'now', return_value=dt):
            poll_service.apply_async(
                kwargs={
                    "service_id": str(self.primary_service.id)
                })

        # Check
        self.assertEqual(len(responses.calls), 2)
        self.assertEqual(json.loads(responses.calls[1].request.body), {
            "services.downtime.test_service.sum": 65.0
        })
def updateDeliveryStatus(sender, instance, **kwargs):
    """update the status to created"""
    status = StatusModel.objects.get(order_id=instance.order_id)
    status.status = "Delivery Scheduled"
    status.save()
def updateStatus(sender, instance, **kwargs):
    """update the status to created"""
    status = StatusModel(status="Created", order_id=instance.orderNumber)
    status.save()
 def get(self, request, order=None):
     status = StatusModel.objects.get(order_id=order)
     status.status = "Invoiced"
     status.save()
     return self.retrieve(request, order)