Skip to content

Commit

Permalink
upgrade python version (huge performance boost)
Browse files Browse the repository at this point in the history
  • Loading branch information
mk2301 committed Feb 2, 2023
1 parent e78a9c8 commit 620ddde
Show file tree
Hide file tree
Showing 26 changed files with 182 additions and 226 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.10
FROM python:3.11
ARG TAPIR_VERSION
ENV TAPIR_VERSION=$TAPIR_VERSION
ENV PYTHONUNBUFFERED=1
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ services:
VIRTUAL_HOST: localhost
DEBUG: 1
depends_on:
# - openldap
- db
- selenium
- keycloak
Expand Down
311 changes: 152 additions & 159 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ description = ""
authors = ["Leon Handreke <leonh@ndreke.de>"]

[tool.poetry.dependencies]
python = "^3.10"
python = "^3.11"
Django = "~3.2.12"
django-weasyprint = "^1.1.0.post2"
django-extensions = "3.1.5"
django-bootstrap-datepicker-plus = "^3.0.6"
django-bootstrap-datepicker-plus = "^5.0.2"
psycopg2-binary = "^2.9.3"
django-tables2 = "^2.4.1"
django-filter = "^2.4.0"
Expand Down
7 changes: 0 additions & 7 deletions tapir/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from tapir.configuration.parameter import get_parameter_value
from tapir.core.models import generate_id, ID_LENGTH, TapirModel
from tapir.log.models import UpdateModelLogEntry
from tapir.settings import PERMISSIONS
from tapir.utils.models import CountryField
from tapir.utils.user_utils import UserUtils
from tapir.wirgarten.parameters import Parameter
Expand Down Expand Up @@ -221,12 +220,6 @@ def has_perms(self, perms):
return False
return True

def get_permissions_display(self):
user_perms = [perm for perm in PERMISSIONS if self.has_perm(perm)]
if len(user_perms) == 0:
return _("None")
return ", ".join(user_perms)


class EmailChangeRequest(TapirModel):
user = models.ForeignKey(TapirUser, on_delete=models.DO_NOTHING, null=False)
Expand Down
2 changes: 1 addition & 1 deletion tapir/configuration/forms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from importlib.resources import _
from django.utils.translation import gettext_lazy as _

from django import forms
from django.forms import Textarea
Expand Down
11 changes: 5 additions & 6 deletions tapir/core/templates/core/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
</span>

{% if request.user.is_authenticated %}
<a class="text-light nav-link"
href="/">{{ request.user.first_name }} {{ request.user.last_name }}</a>
<button class="btn text-light nav-link" id="logout">Logout</button>
{% else %}
<a class="text-light nav-link" href="{% url 'login' %}">Login</a>
<div style="width: 100%; display: flex; justify-content: space-between">
<a class="text-light nav-link" style="white-space:nowrap"
href="/">{{ request.user.first_name }} {{ request.user.last_name }}</a>
<button class="btn text-light nav-link" id="logout">Logout</button>
</div>
{% endif %}
</nav>

Expand Down Expand Up @@ -88,6 +88,5 @@
elem.classList.add('form-select');
elem.classList.add('is-valid');
}

</script>
</html>
24 changes: 0 additions & 24 deletions tapir/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,30 +233,6 @@

WEASYPRINT_BASEURL = "/"

LDAP_BASE_DN = "dc=lueneburg,dc=wirgarten,dc=com"
REG_PERSON_BASE_DN = "ou=people," + LDAP_BASE_DN
REG_PERSON_OBJECT_CLASSES = ["inetOrgPerson", "organizationalPerson", "person"]
REG_GROUP_BASE_DN = "ou=groups," + LDAP_BASE_DN
REG_GROUP_OBJECT_CLASSES = ["groupOfNames"]

# Groups are stored in the LDAP tree
GROUP_ADMIN = "admin"
GROUP_VORSTAND = "vorstand"
GROUP_MEMBER_OFFICE = "member-office"
# This is our own little stupid permission system. See explanation in accounts/models.py.
PERMISSIONS = {
"coop.view": [GROUP_VORSTAND, GROUP_ADMIN, GROUP_MEMBER_OFFICE],
"coop.manage": [GROUP_VORSTAND, GROUP_ADMIN],
# TODO(Leon Handreke): Reserve this to a list of knowledgeable superusers
"coop.admin": [GROUP_VORSTAND, GROUP_ADMIN],
"accounts.view": [GROUP_VORSTAND, GROUP_ADMIN, GROUP_MEMBER_OFFICE],
"accounts.manage": [GROUP_VORSTAND, GROUP_ADMIN, GROUP_MEMBER_OFFICE],
"payments.view": [GROUP_VORSTAND, GROUP_ADMIN, GROUP_MEMBER_OFFICE],
"payments.manage": [GROUP_VORSTAND, GROUP_ADMIN],
"products.view": [GROUP_VORSTAND, GROUP_ADMIN],
"products.manage": [GROUP_VORSTAND, GROUP_ADMIN],
}

AUTH_USER_MODEL = "accounts.TapirUser"
# LOGIN_REDIRECT_URL = "index"
LOGIN_URL = "login"
Expand Down
2 changes: 1 addition & 1 deletion tapir/wirgarten/forms/member/forms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime, timezone
from importlib.resources import _
from django.utils.translation import gettext_lazy as _

from django.core.validators import (
EmailValidator,
Expand Down
2 changes: 1 addition & 1 deletion tapir/wirgarten/forms/pickup_location.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import json
from importlib.resources import _
from django.utils.translation import gettext_lazy as _

from django import forms

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import datetime
from importlib.resources import _
from django.utils.translation import gettext_lazy as _

from dateutil.relativedelta import relativedelta
from django import forms
Expand Down
2 changes: 1 addition & 1 deletion tapir/wirgarten/forms/registration/bestellcoop.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import date
from importlib.resources import _
from django.utils.translation import gettext_lazy as _

from django import forms
from django.db import transaction
Expand Down
2 changes: 1 addition & 1 deletion tapir/wirgarten/forms/registration/chicken_shares.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import date
from importlib.resources import _
from django.utils.translation import gettext_lazy as _

from django import forms
from django.db import transaction
Expand Down
2 changes: 1 addition & 1 deletion tapir/wirgarten/forms/registration/consents.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from importlib.resources import _
from django.utils.translation import gettext_lazy as _

from django import forms

Expand Down
2 changes: 1 addition & 1 deletion tapir/wirgarten/forms/registration/coop_shares.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from importlib.resources import _
from django.utils.translation import gettext_lazy as _

from django import forms
from django.core.validators import MinValueValidator
Expand Down
2 changes: 1 addition & 1 deletion tapir/wirgarten/forms/registration/harvest_shares.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import date
from importlib.resources import _
from django.utils.translation import gettext_lazy as _

from django import forms
from django.db import transaction
Expand Down
3 changes: 1 addition & 2 deletions tapir/wirgarten/forms/registration/payment_data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from importlib.resources import _
from django.utils.translation import gettext_lazy as _

from django import forms
from localflavor.exceptions import ValidationError
Expand Down Expand Up @@ -35,7 +35,6 @@ def get_initial_for_field(self, field, field_name):
return

if field_name in ["account_owner", "iban", "bic"]:
print(self.instance)
return getattr(self.instance, field_name)
else:
return super().get_initial_for_field(field, field_name)
Expand Down
2 changes: 1 addition & 1 deletion tapir/wirgarten/forms/registration/summary.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from importlib.resources import _
from django.utils.translation import gettext_lazy as _

from django import forms

Expand Down
3 changes: 1 addition & 2 deletions tapir/wirgarten/parameters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from importlib.resources import _

from django.utils.translation import gettext_lazy as _
from django.core.validators import (
MinValueValidator,
MaxValueValidator,
Expand Down
2 changes: 1 addition & 1 deletion tapir/wirgarten/service/file_export.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import csv
from importlib.resources import _
from django.utils.translation import gettext_lazy as _

from django.core.mail import EmailMultiAlternatives

Expand Down
1 change: 0 additions & 1 deletion tapir/wirgarten/service/member.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ def create_mandate_ref(member: str | Member, coop_shares: bool):
"""

member_id = resolve_member_id(member)
print(member_id)
ref = generate_mandate_ref(member_id, coop_shares)
return MandateReference.objects.create(
ref=ref, member_id=member_id, start_ts=datetime.now(timezone.utc)
Expand Down
11 changes: 5 additions & 6 deletions tapir/wirgarten/templates/wirgarten/member/member_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,13 @@ <h5 class="card-header d-flex justify-content-between align-items-center">
</div>
</div>

<div class="d-flex m-1 mt-4">
<div class="d-flex justify-content-end gap-2">
{% if object.pk == request.user.pk %}
<a class="btn tapir-btn btn-outline-info ms-1" href="{% url 'password_change' %}"><span
{% if object.pk == request.user.pk %}
<div>
<hr/>
<a style="float: right" class="btn tapir-btn btn-outline-primary ms-1" href="{% url 'password_change' %}"><span
class="material-icons">vpn_key</span>{% translate "Passwort ändern" %}</a>
{% endif %}
</div>
</div>
{% endif %}
</div>

</div>
Expand Down
2 changes: 1 addition & 1 deletion tapir/wirgarten/validators.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import io
import re
from datetime import date
from importlib.resources import _
from django.utils.translation import gettext_lazy as _

from django.core.exceptions import ValidationError

Expand Down
2 changes: 1 addition & 1 deletion tapir/wirgarten/views/default_redirect.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from importlib.resources import _
from django.utils.translation import gettext_lazy as _

from django.http import HttpResponseRedirect, HttpResponse
from django.urls import reverse_lazy
Expand Down
2 changes: 1 addition & 1 deletion tapir/wirgarten/views/member.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import mimetypes
from copy import copy
from datetime import date, datetime, timezone
from importlib.resources import _
from django.utils.translation import gettext_lazy as _

from dateutil.relativedelta import relativedelta
from django.core.mail import EmailMultiAlternatives
Expand Down
2 changes: 1 addition & 1 deletion tapir/wirgarten/views/registration_view.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from importlib.resources import _
from django.utils.translation import gettext_lazy as _

from django.db import transaction
from django.http import HttpResponseRedirect
Expand Down

0 comments on commit 620ddde

Please sign in to comment.