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

Update project #215

Closed
wants to merge 6 commits into from
Closed

Update project #215

wants to merge 6 commits into from

Conversation

aDramaQueen
Copy link
Contributor

Hi, this is a big one...

As I read through this project for my last PR #214, I was baffled that you're supporting Python 2...
A part of me admires this, that you want to support this very old versions. Backwards compatibility is always nice, but you have to do some cuts, otherwise, you will eventually go insane. I mean even the Python organization does not support Python 2 any longer: Python.org

Same goes for Django. Django 1.9 is waaaaayyy outdated. This is a serious security problem: security.snyk.io

Take a look at the roadmap from Django itself. You should orientate at the lates LTS version: djangoproject.com.

I would suggest you drop support for everthing older than Django 3.2.
If you do that, you may now even use the mighty type hint system.

This is basically what I did in this PR. I updated this Project to Django 3.2 with Python 3.8. This comes with some benefits:

  • You have now type hints
  • This whole setup with a Docker Image is not necessary any more. Just follow standard Django rules:
    • Clone this project
    • Migrate
    • Start the project with the built in SQLite
  • Also the test now support a wider range of variations for the Selenium Browsers: Firefox, Chromium, Edge, Safari

I know, it seems, like I changed a lot. But this is just the surface. In fact I did NOT change the functionallity of the Prject at all. All I did was a refactoring.
OK not 100% true, I did change on line. In the bootstrap_modal_forms.compatibility.LoginView class in method get_redirect_url(...) I changed the deprecated is_safe_url(...) method with the current one url_has_allowed_host_and_scheme(...). But that's it.
I ran all your test, and they succeded 100%.

Long story short: Have a look at the changes & take what like, leave what you don't like. If there are any questions. Just ask.

Thanks

Updated deprecated "is_safe_url" function to "url_has_allowed_host_and_scheme".
Added automatically database population, if DB is empty.
Updated requirements to current version.
Updated settings.
Removed outdated version support.
Updated gitignore.
Added type hints.
Updated test cases.
Removed last remaining snippets for outdated Django versions.
@trco
Copy link
Owner

trco commented Apr 12, 2023

That's a huge contribution. I'll consider it ASAP, but it won't be instant, since I have to go through it thoroughly. Will be in touch here. Thanks.

Removed __slots__ from dataclass, to match Python 3.8 support.
Copy link
Owner

@trco trco left a comment

Choose a reason for hiding this comment

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

All the changes were checked. I'll work on PR to remove and update all the necessary things.

Copy link
Owner

Choose a reason for hiding this comment

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

This file should be removed, since it was meant only for compatibility with Django < 1.11.

# Import custom LoginView for Django versions < 1.11
if DJANGO_MAJOR_VERSION == '1' and '11' not in DJANGO_MINOR_VERSION:
    from .compatibility import LoginView
else:
    from django.contrib.auth.views import LoginView

Copy link
Owner

Choose a reason for hiding this comment

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

Should be removed from PR.


from .utils import is_ajax
AuthForm = TypeVar('AuthForm', bound=AuthenticationForm)
Copy link
Owner

Choose a reason for hiding this comment

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

It would be better to define all the types in separate file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You need these types explicitly just in this module mixins.py. Are you sure to create another module and shifting these types into this new module, just to import them here anyways?

Copy link
Owner

Choose a reason for hiding this comment

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

Remove.

@trco trco mentioned this pull request Apr 30, 2023
@trco
Copy link
Owner

trco commented May 1, 2023

This PR was merged in #216. Thanks @aDramaQueen for your huge contribution. I didn't include types for now.

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

Successfully merging this pull request may close these issues.

2 participants