Skip to content
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.

Fixed Values are not retained in forms (event, job and shift) #742 #1131

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

Conversation

codesankalp
Copy link
Member

Modified post view of forms to retain the values of submitted form
when there is an error in form validation to increase users experience.

Fixes #742

Screenshots

Before submission of form:

event_edit_1

After submission of form:

event_edit_2

Tasks done:

  • Modified form to retain values after edit
  • tested the functionality.

@codecov
Copy link

codecov bot commented Sep 25, 2020

Codecov Report

Merging #1131 into develop will decrease coverage by 0.07%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1131      +/-   ##
===========================================
- Coverage    87.18%   87.10%   -0.08%     
===========================================
  Files           85       85              
  Lines         4057     4080      +23     
  Branches       237      238       +1     
===========================================
+ Hits          3537     3554      +17     
- Misses         450      455       +5     
- Partials        70       71       +1     
Impacted Files Coverage Δ
vms/event/views.py 79.61% <100.00%> (+0.29%) ⬆️
vms/shift/views.py 61.40% <0.00%> (-1.21%) ⬇️
vms/job/views.py 89.93% <0.00%> (+2.68%) ⬆️

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 0189ce8...4fc514c. Read the comment docs.

@codesankalp
Copy link
Member Author

@gaurivn please review this.

city = None
for field in data.keys():
try:
data[field] = data.get(field)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just do data.get(field, '')

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SanketDG please review it again. Thanks.

@keshakaneria
Copy link
Member

@codesankalp codecov test is failing, did you check the tests locally?

@codesankalp
Copy link
Member Author

codesankalp commented Sep 30, 2020

@codesankalp codecov test is failing, did you check the tests locally?

Yes, I don't know why, should I change anything @keshakaneria.

Copy link
Member

@devkapilbansal devkapilbansal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be due to the try-except block @codesankalp

@codesankalp
Copy link
Member Author

@devkapilbansal in this commit I have removed the try except block inside for loop as mentioned by mentors.

Copy link
Member

@devkapilbansal devkapilbansal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codesankalp you have some try except blocks in your code. Therefore you have to cover those in tests too, else find a way to reduce the numbers of try except blocks here.

One method that can be used here is .first() method. Filter your queryset instead of get and fetch the first object. Then codecov will pass

@devkapilbansal
Copy link
Member

@codesankalp like you can change this line
city = City.objects.get(name=city_name) to city = City.objects.filter(name=city_name).first() and remove the try except block.

Modified post view of forms to retain the values of submitted form
when there is an error in form validation to increase users experience.

Fixes #742
@codesankalp
Copy link
Member Author

@devkapilbansal can you please check the build of Travis as I think the error in the build is not related to my commit.

@devkapilbansal
Copy link
Member

@gaurivn @keshakaneria @SanketDG can you please look into the problem

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

Successfully merging this pull request may close these issues.

Values are not retained in forms (event, job and shift)
4 participants