Skip to content

Commit

Permalink
Merge pull request #236 from lzaoral/add-django-5
Browse files Browse the repository at this point in the history
Add support for Django 5.0
  • Loading branch information
rohanpm authored Dec 12, 2023
2 parents a470ecf + 800d485 commit 308ea96
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ jobs:
py310-django4,
py311-django4,
py312-django4,
py310-django5,
py311-django5,
py312-django5,
py39-bandit,
]

Expand Down
5 changes: 4 additions & 1 deletion kobo/django/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
from django.core import exceptions
from django.utils.text import capfirst
from django.forms.widgets import Select
from django.forms.fields import CallableChoiceIterator

import kobo.django.forms
from kobo.types import StateEnum
from kobo.django.compat import gettext_lazy as _
from kobo.django.django_version import django_version_ge

if django_version_ge('5.0.0'):
from django.utils.choices import CallableChoiceIterator
else:
from django.forms.fields import CallableChoiceIterator

'''
StateEnumField
Expand Down
16 changes: 16 additions & 0 deletions kobo/hub/static/kobo/css/screen.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@ body {
float: right;
}

#logout-form {
display: inline;
}

#logout-form button {
font-size: inherit;
font-weight: normal;
color: #ffffff;
background: none;
border: none;
cursor: pointer;
padding: 0;
text-decoration: underline;
font-family: inherit;
}

#menu {
border: 1px solid #8c8f91;
border-top: none;
Expand Down
8 changes: 7 additions & 1 deletion kobo/hub/templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
<body>
<div id="header">{% block header_site_name %}{% endblock %}{% if title %} - {{ title }}{% endif %}
<div id="login">
{% if user.is_authenticated %}user: <strong>{{ user }}</strong> | <a href="{% url 'auth/logout' %}?next={{ request.path }}">logout</a>{% else %}{% block login %}<a href="{% url 'auth/login' %}?next={{ request.path }}">login</a>{% endblock %}{% endif %}
{% if user.is_authenticated %}
user: <strong>{{ user }}</strong> | <form id="logout-form" method="post" action="{% url 'auth/logout' %}">
{% csrf_token %}
<button type="submit">logout</button>
<input type="hidden" name="next" value="{{ request.path }}"/>
</form>
{% else %}{% block login %}<a href="{% url 'auth/login' %}?next={{ request.path }}">login</a>{% endblock %}{% endif %}
{% if user.is_superuser %} | <a href="{% url 'index' %}admin/">admin</a>{% endif %}
{% block header_login %}{% endblock %}
</div>
Expand Down
2 changes: 1 addition & 1 deletion tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_krb5login_redirect_to(self):
self.assertIn(response['Location'], ['http://testserver/auth/login/', '/auth/login/'])

def test_logout(self):
response = self.client.get('/auth/logout/')
response = self.client.post('/auth/logout/')
self.assertIn(response.status_code, [200, 302])
self.client.post('/auth/login/', self.credentials)
self.client.logout()
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
# Don't forget to update GA config when changing this
envlist = {py36, py38, py39, py310, py311}-{django2, django3}, {py38, py39, py310, py311, py312}-django4, py39-bandit
envlist = {py36, py38, py39, py310, py311}-{django2, django3}, {py38, py39, py310, py311, py312}-django4, {py310, py311, py312}-django5, py39-bandit
skip_missing_interpreters = True

[testenv]
Expand All @@ -11,6 +11,7 @@ deps =
django2: Django~=2.2.0 # Django 2 LTS (EOL 4/2022)
django3: Django~=3.2.0 # Django 3 LTS (EOL 4/2024)
django4: Django~=4.2.0 # Django 4 LTS (EOL 4/2026)
django5: Django~=5.0.0
# for testing with python-rpm
sitepackages = True

Expand Down

0 comments on commit 308ea96

Please sign in to comment.