Skip to content

Commit

Permalink
fix logic error
Browse files Browse the repository at this point in the history
  • Loading branch information
evinjaff committed Jul 14, 2024
1 parent 9a64cd4 commit 80cf0ed
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions server/pokepoll/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def get_random_objects(model, count):
return model.objects.none() # No objects in the model

# check quantity of objects in the model
if count < model.objects.count():
if count > model.objects.count():
raise ValueError("Count must be greater than the number of objects in the model")

random_ids = set()
Expand All @@ -188,8 +188,12 @@ def saveGenView(request):
# Validate the form: the captcha field will automatically
# check the input
if form.is_valid():

egg_quantity = form.cleaned_data['num_eggs']
print("egg_quantity: {}".format(egg_quantity))

# get 5 eggs from the database
five_eggs = get_random_objects(Pokemon, 3)
five_eggs = get_random_objects(Pokemon, egg_quantity)

# create a list of dictionaries to hold the egg data
egg_data = []
Expand Down

0 comments on commit 80cf0ed

Please sign in to comment.