Skip to content

Commit

Permalink
chore(deps): upgrade to django 2, python 3.8 and everything else
Browse files Browse the repository at this point in the history
Upgrade from django 1 to 2, along with other dependencies.
Only minor changes were required, including that monthly reports use a
constructed primary key that now has the format "YYYYMM" instead of
"YYYY-M".
  • Loading branch information
Stefan Borer committed Feb 7, 2020
1 parent c0a1dd4 commit 413fa08
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 23 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.6
FROM python:3.8

WORKDIR /app

Expand Down
24 changes: 12 additions & 12 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
python-dateutil==2.8.0
django==1.11.22 # pyup: >=1.11,<1.12
django-auth-ldap==1.7.0
django-filter==2.1.0
django-multiselectfield==0.1.8
djangorestframework==3.9.4
python-dateutil==2.8.1
django==2.2.10 # pyup: <3.0
django-auth-ldap==2.1.0
django-filter==2.2.0
django-multiselectfield==0.1.11
djangorestframework==3.11.0
djangorestframework-jwt==1.11.0
djangorestframework-jsonapi==2.7.0
psycopg2-binary==2.8.2
pytz==2019.1
djangorestframework-jsonapi==3.0.0
psycopg2-binary==2.8.4
pytz==2019.3
pyexcel-webio==0.1.4
pyexcel-io==0.5.17
pyexcel-io==0.5.20
django-excel==0.0.10
pyexcel-ods3==0.5.3
pyexcel-xlsx==0.5.7
pyexcel-xlsx==0.5.8
pyexcel-ezodf==0.3.4
django-environ==0.4.5
django-money==0.14.4
django-money==1.0
python-redmine==2.2.1
uwsgi==2.0.18
4 changes: 2 additions & 2 deletions timed/projects/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Viewsets for the projects app."""

from rest_framework.viewsets import ReadOnlyModelViewSet
from rest_framework_json_api.views import PrefetchForIncludesHelperMixin
from rest_framework_json_api.views import PreloadIncludesMixin

from timed.projects import filters, models, serializers

Expand Down Expand Up @@ -38,7 +38,7 @@ def get_queryset(self):
return models.CostCenter.objects.all()


class ProjectViewSet(PrefetchForIncludesHelperMixin, ReadOnlyModelViewSet):
class ProjectViewSet(PreloadIncludesMixin, ReadOnlyModelViewSet):
"""Project view set."""

serializer_class = serializers.ProjectSerializer
Expand Down
6 changes: 4 additions & 2 deletions timed/redmine/management/commands/redmine_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ def handle(self, *args, **options):
.values("id")
)
# calculate total hours
projects = Project.objects.filter(id__in=affected_projects).annotate(
total_hours=Sum("tasks__reports__duration")
projects = (
Project.objects.filter(id__in=affected_projects)
.order_by("name")
.annotate(total_hours=Sum("tasks__reports__duration"))
)

for project in projects:
Expand Down
4 changes: 2 additions & 2 deletions timed/reports/tests/test_month_statistic.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ def test_month_statistic_list(auth_client):
expected_json = [
{
"type": "month-statistics",
"id": "2015-12",
"id": "201512",
"attributes": {"year": 2015, "month": 12, "duration": "03:00:00"},
},
{
"type": "month-statistics",
"id": "2016-1",
"id": "201601",
"attributes": {"year": 2016, "month": 1, "duration": "01:00:00"},
},
]
Expand Down
2 changes: 1 addition & 1 deletion timed/reports/tests/test_notify_supervisors_shorttime.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_notify_supervisors(db, mailoutbox):
mail = mailoutbox[0]
assert mail.to == [supervisor.email]
body = mail.body
assert "Time range: 17.07.2017 - 23.07.2017\nRatio: 0.9" in body
assert "Time range: July 17, 2017 - July 23, 2017\nRatio: 0.9" in body
expected = ("{0} 35.0/42.5 (Ratio 0.82 Delta -7.5 Balance -9.0)").format(
supervisee.get_full_name()
)
Expand Down
6 changes: 3 additions & 3 deletions timed/reports/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from zipfile import ZipFile

from django.conf import settings
from django.db.models import F, Sum, Value
from django.db.models.functions import Concat, ExtractMonth, ExtractYear
from django.db.models import F, Sum
from django.db.models.functions import ExtractMonth, ExtractYear
from django.http import HttpResponse, HttpResponseBadRequest
from ezodf import Cell, opendoc
from rest_framework.viewsets import GenericViewSet, ReadOnlyModelViewSet
Expand Down Expand Up @@ -49,7 +49,7 @@ def get_queryset(self):
)
queryset = queryset.values("year", "month")
queryset = queryset.annotate(duration=Sum("duration"))
queryset = queryset.annotate(pk=Concat("year", Value("-"), "month"))
queryset = queryset.annotate(pk=F("year") * 100 + F("month"))
return queryset


Expand Down

0 comments on commit 413fa08

Please sign in to comment.