Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
luto committed Nov 2, 2024
1 parent a784311 commit 3330b4b
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/crowdprinter/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ def get_context_data(self, object):
def take_print_job(request, slug):
job = get_object_or_404(models.PrintJob, slug=slug)
if request.method == "POST" and can_take_job(request.user, job):
models.PrintAttempt.objects.create(job=job, user=request.user)
models.PrintAttempt.objects.create(
job=job,
user=request.user,
)

return HttpResponseRedirect(reverse("printjob_detail", kwargs={"slug": slug}))

Expand All @@ -96,7 +99,10 @@ def take_print_job(request, slug):
def give_back_print_job(request, slug):
if request.method == "POST":
attempt = get_object_or_404(
models.PrintAttempt, job__slug=slug, user=request.user, ended__isnull=True
models.PrintAttempt,
job__slug=slug,
user=request.user,
ended__isnull=True,
)
attempt.ended = datetime.date.today()
attempt.save()
Expand All @@ -108,7 +114,10 @@ def give_back_print_job(request, slug):
def printjob_done(request, slug):
if request.method == "POST":
attempt = get_object_or_404(
models.PrintAttempt, job__slug=slug, user=request.user, ended__isnull=True
models.PrintAttempt,
job__slug=slug,
user=request.user,
ended__isnull=True,
)
attempt.ended = datetime.date.today()
attempt.finished = True
Expand Down Expand Up @@ -136,7 +145,10 @@ def get_file_path(self, **kwargs):

class ServeStlView(ServeFileView):
def get_file_path(self, **kwargs):
printjob = get_object_or_404(models.PrintJob, slug=kwargs["slug"])
printjob = get_object_or_404(
models.PrintJob,
slug=kwargs["slug"],
)
if self.request.user not in printjob.attempting_users:
raise Http404()
return printjob.file_stl.path
Expand All @@ -147,7 +159,10 @@ class ServeRenderView(ServeFileView):
as_attachment = False

def get_file_path(self, **kwargs):
printjob = get_object_or_404(models.PrintJob, slug=kwargs["slug"])
printjob = get_object_or_404(
models.PrintJob,
slug=kwargs["slug"],
)
return printjob.file_render.path


Expand Down

0 comments on commit 3330b4b

Please sign in to comment.