Exemplo n.º 1
0
    def test_notifySU(self):
        self.group = Group.objects.create(name='superuser')
        self.user = User.objects.create(username='******',
                                        password='******',
                                        first_name="pavel",
                                        email="*****@*****.**")
        self.group.user_set.add(self.user)
        self.user = User.objects.create(username='******',
                                        password='******',
                                        first_name="stefano",
                                        email="*****@*****.**")
        self.group.user_set.add(self.user)
        # self.user

        self.account = Account.objects.create(title='test', creator=self.user)
        Membership.objects.create(user=self.user, account=self.account)
        self.app = App.objects.create(account=self.account,
                                      creator=self.user,
                                      title='test')

        self.job1 = Job.objects.create(
            app=self.app,
            creator=self.user,
            title='job title 1',
            description='job desc',
            category='CF',
            units_per_page='2',
            device_type='AD',
            judgements_webhook_url='http://example.com',
            userinterface_url="http://example.com/ui/")
        notifySuperUser(self.job1.id)
Exemplo n.º 2
0
 def create(self,request,job_pk):
     job = get_object_or_404(Job, pk=job_pk, app=request.app)
     input = request.DATA
     # it expects an array
     if isinstance(input,list):
         for d in input:
             Unit.objects.create(job=job, input_data=json.dumps(d))
     else:
         new_unit = Unit.objects.create(job=job, input_data=json.dumps(input))
         return self.get_object(kwargs = {'pk':new_unit.pk})
         # serializer = UnitSerializer(new_unit)
         # return Response(serializer.data,status=status.HTTP_201_CREATED)
     # this notifies SU once a day
     notifySuperUser(job_pk)
     return Response(status=status.HTTP_201_CREATED)
Exemplo n.º 3
0
 def create(self, request, job_pk):
     job = get_object_or_404(Job, pk=job_pk, app=request.app)
     input = request.DATA
     # it expects an array
     if isinstance(input, list):
         for d in input:
             Unit.objects.create(job=job, input_data=json.dumps(d))
     else:
         new_unit = Unit.objects.create(job=job,
                                        input_data=json.dumps(input))
         return self.get_object(kwargs={'pk': new_unit.pk})
         # serializer = UnitSerializer(new_unit)
         # return Response(serializer.data,status=status.HTTP_201_CREATED)
     # this notifies SU once a day
     notifySuperUser(job_pk)
     return Response(status=status.HTTP_201_CREATED)
Exemplo n.º 4
0
    def test_notifySU(self):
        self.group = Group.objects.create(name='superuser')
        self.user = User.objects.create(username='******', password='******', first_name="pavel",
                                        email="*****@*****.**")
        self.group.user_set.add(self.user)
        self.user = User.objects.create(username='******', password='******', first_name="stefano",
                                        email="*****@*****.**")
        self.group.user_set.add(self.user)
        # self.user

        self.account = Account.objects.create(title='test', creator=self.user)
        Membership.objects.create(user=self.user, account=self.account)
        self.app = App.objects.create(account=self.account, creator=self.user, title='test')

        self.job1 = Job.objects.create(app=self.app, creator=self.user, title='job title 1',
                                       description='job desc', category='CF', units_per_page='2', device_type='AD',
                                       judgements_webhook_url='http://example.com',
                                       userinterface_url="http://example.com/ui/")
        notifySuperUser(self.job1.id)