Skip to content

Commit

Permalink
Django backwards compatability + missing migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
farridav committed Mar 27, 2022
1 parent 502e9c6 commit 9cd2702
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 41 deletions.
3 changes: 3 additions & 0 deletions Makefile
Expand Up @@ -37,3 +37,6 @@ test_app: check-venv ## Run the test app
@printf "$(CYAN)Running test app$(COFF)\n"
$(environment) python tests/test_app/manage.py migrate
$(environment) python tests/test_app/manage.py runserver_plus

test_user: ## Make the test user
$(environment) python tests/test_app/manage.py shell -c "from django.contrib.auth.models import User; User.objects.create_superuser('test@test.com', password='test')"
4 changes: 2 additions & 2 deletions jazzmin/templates/registration/password_reset_complete.html
Expand Up @@ -3,11 +3,11 @@
{% load i18n %}

{% block content %}
<p class="login-box-msg">{% translate "Your password has been set. You may go ahead and log in now." %}</p>
<p class="login-box-msg">{% trans "Your password has been set. You may go ahead and log in now." %}</p>
<div class="row">
<div class="col-12">
<a href="{{ login_url }}">
<button class="btn {{ jazzmin_ui.button_classes.primary }} btn-block">{% translate 'Log in' %}</button>
<button class="btn {{ jazzmin_ui.button_classes.primary }} btn-block">{% trans 'Log in' %}</button>
</a>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions jazzmin/templates/registration/password_reset_confirm.html
Expand Up @@ -5,7 +5,7 @@
{% block content %}
{% if validlink %}
<p class="login-box-msg">
{% translate "Please enter your new password twice so we can verify you typed it in correctly." %}
{% trans "Please enter your new password twice so we can verify you typed it in correctly." %}
</p>
<form method="post">{% csrf_token %}
{% if form.errors %}
Expand Down Expand Up @@ -47,14 +47,14 @@
<div class="row">
<div class="col-12">
<button type="submit" class="btn {{ jazzmin_ui.button_classes.primary }} btn-block">
{% translate 'Change my password' %}
{% trans 'Change my password' %}
</button>
</div>
</div>
</form>
{% else %}
<p>
{% translate "The password reset link was invalid, possibly because it has already been used. Please request a new password reset." %}
{% trans "The password reset link was invalid, possibly because it has already been used. Please request a new password reset." %}
</p>
{% endif %}
{% endblock %}
2 changes: 1 addition & 1 deletion jazzmin/templates/registration/password_reset_form.html
Expand Up @@ -38,7 +38,7 @@
<div class="row">
<div class="col-12">
<button type="submit" class="btn {{ jazzmin_ui.button_classes.primary }} btn-block">
{% translate 'Reset my password' %}
{% trans 'Reset my password' %}
</button>
</div>
</div>
Expand Down
28 changes: 28 additions & 0 deletions tests/test_app/library/books/migrations/0006_auto_20220327_0814.py
@@ -0,0 +1,28 @@
# Generated by Django 3.2.12 on 2022-03-27 07:14

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("books", "0005_book_last_print"),
]

operations = [
migrations.AlterField(
model_name="author",
name="id",
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID"),
),
migrations.AlterField(
model_name="book",
name="id",
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID"),
),
migrations.AlterField(
model_name="genre",
name="id",
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID"),
),
]
18 changes: 18 additions & 0 deletions tests/test_app/library/loans/migrations/0003_alter_library_id.py
@@ -0,0 +1,18 @@
# Generated by Django 3.2.12 on 2022-03-27 07:14

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("loans", "0002_auto_20201015_1222"),
]

operations = [
migrations.AlterField(
model_name="library",
name="id",
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID"),
),
]
2 changes: 2 additions & 0 deletions tests/test_app/library/settings.py
Expand Up @@ -103,6 +103,8 @@

DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"

EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"

if DEBUG and not TEST:
os.environ.setdefault("WERKZEUG_DEBUG_PIN", "off")
INSTALLED_APPS.extend(["debug_toolbar", "django_extensions"])
Expand Down
41 changes: 6 additions & 35 deletions tests/test_app/library/urls.py
Expand Up @@ -3,17 +3,10 @@
from django.contrib import admin, messages
from django.contrib.auth import views as auth_views
from django.http import HttpResponseRedirect
from django.urls import path, re_path, reverse
from django.urls import include, path, re_path, reverse
from django.views.generic import RedirectView
from django.views.static import serve

try:
from django.urls import include, path
except ImportError:
from django.conf.urls import include, path
except ImportError:
from django.conf.urls.defaults import include, path


def make_messages(request):
messages.add_message(request, messages.INFO, "Info message")
Expand All @@ -32,37 +25,15 @@ def make_messages(request):
]

urlpatterns += i18n_patterns(
path(
"admin/password_reset/",
auth_views.PasswordResetView.as_view(),
name="admin_password_reset",
),
path(
"admin/password_reset/done/",
auth_views.PasswordResetDoneView.as_view(),
name="password_reset_done",
),
path(
"reset/<uidb64>/<token>/",
auth_views.PasswordResetConfirmView.as_view(),
name="password_reset_confirm",
),
path(
"reset/done/",
auth_views.PasswordResetCompleteView.as_view(),
name="password_reset_complete",
),
path("admin/password_reset/", auth_views.PasswordResetView.as_view(), name="admin_password_reset"),
path("admin/password_reset/done/", auth_views.PasswordResetDoneView.as_view(), name="password_reset_done"),
path("reset/<uidb64>/<token>/", auth_views.PasswordResetConfirmView.as_view(), name="password_reset_confirm"),
path("reset/done/", auth_views.PasswordResetCompleteView.as_view(), name="password_reset_complete"),
path("admin/", admin.site.urls),
)

if settings.DEBUG:
urlpatterns.append(
re_path(
r"^static/(?P<path>.*)$",
serve,
kwargs={"document_root": settings.STATIC_ROOT},
)
)
urlpatterns.append(re_path(r"^static/(?P<path>.*)$", serve, kwargs={"document_root": settings.STATIC_ROOT}))

if "debug_toolbar" in settings.INSTALLED_APPS:
try:
Expand Down

0 comments on commit 9cd2702

Please sign in to comment.