def new_file(request): if request.method == 'POST': form = UploadFileForm(request.POST, request.FILES) if form.is_valid(): f = form.save(commit=False) f.user = request.user f.date_uploaded = datetime.datetime.now() f.save() current_id = f.id print(current_id) file = Files.objects.get(id=current_id).get_dir() background(file, current_id) #subprocess.run(["python","manage.py","process_tasks"]) return redirect('index') else: print("nie") form = UploadFileForm() return render(request, 'salesman/new.html', {'form': form})
def test_shortcut(self): '''check shortcut to decorator works''' proxy = background()(empty_task) self.failIfEqual(proxy, empty_task) self.assertEqual(proxy.task_function, empty_task)
def test_shortcut(self): '''check shortcut to decorator works''' proxy = background()(empty_task) self.failIfEqual(proxy, empty_task) self.assertEqual(proxy.task_function, empty_task)
target_id: int = 0, actor_cls_str: str = "", actor_id: int = 0, ): object_model = apps.get_model(object_cls_str) obj = object_model.objects.get(pk=object_id) object_ct = ContentType.objects.get_for_model(obj) target = None if target_cls_str != "": model = apps.get_model(target_cls_str) target = model.objects.get(pk=target_id) actor = None if actor_cls_str != "": model = apps.get_model(actor_cls_str) actor = model.objects.get(pk=actor_id) notification = django_vox.models.Notification.objects.get( codename=codename, object_type=object_ct) notification.issue(obj, actor=actor, target=target) try: from background_task import background issue_notification = background(queue="django-vox")(issue_notification) except ImportError: pass except RuntimeError: pass