Skip to content

Commit

Permalink
fix: Handle max_attempts for AnonymousUser
Browse files Browse the repository at this point in the history
  • Loading branch information
jadyndev committed Dec 17, 2024
1 parent 84283bf commit 9ab595b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/crowdprinter/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,11 @@ class PrintJobDetailView(DetailView):

def get_context_data(self, object):
context = super().get_context_data()
max_jobs = settings.CROWDPRINTER_DEFAULT_MAX_ATTEMPTS
if self.request.user.is_authenticated:
context["can_take_job"] = can_take_job(self.request.user, self.object)
if self.request.user.max_attempts is None:
max_jobs = settings.CROWDPRINTER_DEFAULT_MAX_ATTEMPTS
else:
max_jobs = self.request.user.max_attempts
if self.request.user.max_attempts is not None:
max_jobs = self.request.user.max_attempts
context["max_jobs"] = max_jobs
return context

Expand Down

0 comments on commit 9ab595b

Please sign in to comment.