コード例 #1
0
    def withdraw(self, request, pk=None):
        self.check_permissions(request)
        application = self.get_object()
        self.check_object_permissions(request, application)

        application.withdraw()
        serializer = self.get_serializer(application)
        stats.application_status_update(application)
        return Response(data=serializer.data)
コード例 #2
0
    def test_group_application_status_update(self, write_points):
        two_hours_ago = timezone.now() - relativedelta(hours=2)
        application = GroupApplicationFactory(group=GroupFactory(), user=UserFactory(), created_at=two_hours_ago)
        application.status = 'accepted'
        application.save()

        write_points.reset_mock()
        stats.application_status_update(application)
        write_points.assert_called_with([{
            'measurement': 'karrot.events',
            'tags': {
                'group': str(application.group.id)
            },
            'fields': {
                'application_accepted': 1,
                'application_accepted_seconds': 60 * 60 * 2,
            },
        }])
コード例 #3
0
ファイル: models.py プロジェクト: toiinnn/karrot-backend
 def save(self, **kwargs):
     old = type(self).objects.get(pk=self.pk) if self.pk else None
     super().save(**kwargs)
     if old is None or old.status != self.status:
         application_status_update(self)