[Fixed]-Restrict access to view based on if request came from other view

1👍

✅

I guess you can totally achieve what you’re doing using only one of those APIs, you can simply call your celery task from your CompletionView.

class CompletionView(TemplateView):
    def post(self, request, *args, **kwargs):

        ...

        if 'save_and_submit' in request.POST:
            # This is the only place I would like ScheduleTask to
            # run from.
             schedule_task.delay(obj.uuid, context)
             return redirect(reverse(
                'users:user-list',
               kwargs={'user': obj.user.uuid}))

In fact if you don’t want this API exposed, just Don’t expose it.

Leave a comment