Exemplo n.º 1
0
 def create(print, event_type):
     event = PrintEvent.objects.create(print=print,
                                       event_type=event_type,
                                       alert_muted=(print.alert_muted_at
                                                    is not None))
     if event_type in PrintEvent.ENDED:
         celery_app.send_task(settings.PRINT_EVENT_HANDLER, args=[print.id])
Exemplo n.º 2
0
 def create(print, event_type):
     event = PrintEvent.objects.create(print=print,
                                       event_type=event_type,
                                       alert_muted=(print.alert_muted_at
                                                    is not None))
     if event_type in PrintEvent.ENDED:
         celery_app.send_task('app_ent.tasks.process_print_events',
                              args=[print.id])
 def create(print_, event_type):
     event = PrintEvent.objects.create(
         print=print_,
         event_type=event_type,
         alert_muted=(print_.alert_muted_at is not None)
     )
     celery_app.send_task(
         settings.PRINT_EVENT_HANDLER,
         args=(event.id, ),
     )
Exemplo n.º 4
0
    def update(self, request, *args, **kwargs):
        unanswered_print_shots = self.get_queryset().filter(answered_at__isnull=True)
        should_credit = len(unanswered_print_shots) == 1 and unanswered_print_shots.first().id == int(kwargs['pk'])

        if should_credit:
            _print = unanswered_print_shots.first().print
            celery_app.send_task('app_ent.tasks.credit_dh_for_contribution',
                                 args=[request.user.id, 2, f'Credit | Focused Feedback - "{_print.filename[:100]}"', f'ff:p:{_print.id}']
                                 )

        resp = super(PrintShotFeedbackViewSet, self).update(request, *args, **kwargs)
        return Response({'instance': resp.data, 'credited_dhs': 2 if should_credit else 0})
Exemplo n.º 5
0
    def alert_overwrite(self, request, pk=None):
        print = get_object_or_404(self.get_queryset(), pk=pk)

        user_credited = False
        if print.alert_overwrite == None:
            celery_app.send_task('app_ent.tasks.credit_dh_for_contribution', args=[print.user.id, 1, 'Credit | Tag "{}"'.format(print.filename[:100])])
            user_credited = True

        print.alert_overwrite = request.GET.get('value', None)
        print.save()

        return Response(dict(user_credited=user_credited))
Exemplo n.º 6
0
    def acknowledge_alert(self, alert_overwrite):
        if not self.current_print.alerted_at:
            return False

        user_credited = False
        if self.current_print.alert_overwrite == None:
            celery_app.send_task('app_ent.tasks.credit_dh_for_contribution', args=[self.user.id, 1, 'Credit | Tag "{}"'.format(self.current_print.filename[:100])])
            user_credited = True

        self.current_print.alert_acknowledged_at = timezone.now()
        self.current_print.alert_overwrite = alert_overwrite
        self.current_print.save()
        return user_credited
Exemplo n.º 7
0
    def unset_current_print_with_ts(self):
        print = self.current_print
        self.current_print = None
        self.save()

        self.printerprediction.reset_for_new_print()

        if print.cancelled_at is None:
            print.finished_at = timezone.now()
            print.save()

        celery_app.send_task('app.tasks.compile_timelapse', args=[print.id])
        PrintEvent.create(print, PrintEvent.ENDED)