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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compliance with the principle of DRY in the email.py file #689

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mojtabaakbari221b
Copy link

file: https://github.com/sunscrapers/djoser/blob/master/djoser/email.py

In the get_context_data() method of three of the classes, many lines of code are repeated. (Dont Repeat Yourself)
If we want to add a line of code, we have to do this 3 times, it is definitely difficult to maintain this code.
I wrote a mixin in the email_mixins.py file and put these duplicates in it and inherited the desired classes from it.
Also, the common part of the code that caused this to be repeated 3 times was the different context["url"], so I solved this problem by adding a parameter to the class.

@codecov
Copy link

codecov bot commented May 20, 2023

Codecov Report

Merging #689 (3c68325) into master (82c837e) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #689      +/-   ##
==========================================
- Coverage   99.02%   99.01%   -0.01%     
==========================================
  Files          26       27       +1     
  Lines         820      814       -6     
==========================================
- Hits          812      806       -6     
  Misses          8        8              
Impacted Files Coverage Δ
djoser/email.py 100.00% <100.00%> (ø)
djoser/email_mixins.py 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

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