Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using counter0 instead of revcounter0 to check if item is last in ForLoopSimulator #942

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

andreatulimiero
Copy link

@andreatulimiero andreatulimiero commented Nov 13, 2019

Hi there,
While using the formset utilities I ran into a strange behavior: when you try to use forloop.last to apply specific settings like shown in the docs, the forloop.last variable is never evaluted to True, if there is more than a form in the formset.

Digging a bit in the code I found out the ForLoopSimulator, and I believe that in ForLoopSimulator::iter(...) , self.last is wrongly updated.
The fix I submitted changes just the variable used to check against self.len_values-1 from self.revcounter0 to self.counter0 (although, there are a ton of different ways to check if the current item is the last item 馃槄)

@codecov-io
Copy link

codecov-io commented Nov 13, 2019

Codecov Report

Merging #942 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #942   +/-   ##
=======================================
  Coverage   95.23%   95.23%           
=======================================
  Files          24       24           
  Lines        2772     2772           
  Branches      251      251           
=======================================
  Hits         2640     2640           
  Misses         88       88           
  Partials       44       44
Impacted Files Coverage 螖
crispy_forms/templatetags/crispy_forms_tags.py 97.45% <酶> (酶) 猬嗭笍

Continue to review full report at Codecov.

Legend - Click here to learn more
螖 = absolute <relative> (impact), 酶 = not affected, ? = missing data
Powered by Codecov. Last update 948a267...d21af91. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants