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

Code refactored #216

Merged
merged 2 commits into from
Mar 12, 2024
Merged

Code refactored #216

merged 2 commits into from
Mar 12, 2024

Conversation

Domejko
Copy link
Contributor

@Domejko Domejko commented Mar 12, 2024

Description

I have done code refactoring #160. As I mentioned in comment I did shorten some nested if statements and when it was possible and clean looking made them one liners. Added a specific expected errors to the except blocks. In auth_backends.py I did change code accordingly because either way if user.check_password(password) was successful it did return user:

Before:

if user.check_password(password):
    if user.is_active:
        return user

    if user.awaiting_email_verification:
        return user
    return user

After:

if user.check_password(password):
    return user

From file create.py in /backend/views/core/invoices I did delete function named edit_invoice_page because it was exactly the same as this function:

@require_http_methods(["GET", "POST"])
def create_invoice_page(request: HttpRequest):
    if request.method == "POST":
        return invoice_page_post(request)
    return invoice_page_get(request)

and it have not been used anywhere in the code, so this function can be renamed to let say create_edit_invoice_page if would be needed for editing purposes anywhere in future.

I did noticed that some functions like edit_invoice are repeating through out the code with some slight changes here and there which possibly could be reduced to one function and repurposed with additional arguments. If you like I could try to work on that.

Hope you will be satisfied with those small changes.

Checklist

  • Ran the Black Formatter and
    djLint-er on any new code
    (checks
    will
    fail without)
  • Made any changes or additions to the documentation where required
  • Changes generate no new warnings/errors
  • New and existing unit tests pass locally with my
    changes

What type of PR is this?

  • ♻️ Code Refactor

Added/updated tests?

  • 🙅 no, because they aren't needed

Related PRs, Issues etc

  • Related Issue #
  • Closes #

Copy link
Owner

@TreyWW TreyWW left a comment

Choose a reason for hiding this comment

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

Great cleanup! Really appreciate your contribution :)

@TreyWW TreyWW merged commit 5fd0e5c into TreyWW:main Mar 12, 2024
14 checks passed
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.

2 participants