Skip to content

Commit

Permalink
Merge pull request #380 from uw-it-aca/task/django-container-2.0.1
Browse files Browse the repository at this point in the history
update django-container 2.0.1 (python3.10)
  • Loading branch information
jlaney authored Feb 12, 2024
2 parents 651e08e + 37bc714 commit 32c7076
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 18 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ on:

jobs:
context:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

outputs:
commit_hash: ${{ steps.context.outputs.commit_hash }}
Expand All @@ -62,7 +62,7 @@ jobs:
release_name: ${{ env.RELEASE_NAME }}

build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

needs: context

Expand All @@ -73,7 +73,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: '3.10'

- name: Run Python Linters
uses: uw-it-aca/actions/python-linters@main
Expand Down Expand Up @@ -145,7 +145,7 @@ jobs:
outputs:
context: ${{ steps.context.outputs.context }}

runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- name: Checkout Repo
Expand Down Expand Up @@ -182,7 +182,7 @@ jobs:

needs: [context, build, deploy]

runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- name: House Keeping
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG DJANGO_CONTAINER_VERSION=1.4.1
ARG DJANGO_CONTAINER_VERSION=2.0.1

FROM us-docker.pkg.dev/uwit-mci-axdd/containers/django-container:${DJANGO_CONTAINER_VERSION} as app-prebundler-container

Expand Down
4 changes: 3 additions & 1 deletion compass/dao/contact.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2024 UW-IT, University of Washington
# SPDX-License-Identifier: Apache-2.0

from django.conf import settings
from compass.models import ContactType, AccessGroup, AppUser
from dateutil import parser

Expand Down Expand Up @@ -52,7 +53,8 @@ def parse_checkin_date_str(checkin_date_str):
raise ValueError("Check-in date not specified")
else:
try:
dt = parser.parse(checkin_date_str)
dt = parser.parse(checkin_date_str,
tzinfos=getattr(settings, "TZINFOS", {}))
if dt.tzinfo is None:
raise ValueError("Invalid check-in date, missing timezone")
return dt
Expand Down
4 changes: 2 additions & 2 deletions compass/management/commands/process_omad_contacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from django.core.management.base import BaseCommand
from compass.models import OMADContactQueue
from datetime import datetime
from datetime import datetime, timezone
import json
from compass.models import (
AccessGroup, AppUser, Contact, Student)
Expand Down Expand Up @@ -34,7 +34,7 @@ def handle(self, *args, **options):
except Exception as e:
logger.exception(f"Error processing contact {contact.id}")
contact.processing_attempts += 1
contact.process_attempted_date = datetime.now()
contact.process_attempted_date = datetime.now(timezone.utc)
contact.processing_error = repr(e)
contact.stack_trace = traceback.format_exc()
contact.save()
Expand Down
7 changes: 3 additions & 4 deletions compass/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
from django.db import models, transaction
from django.db.utils import IntegrityError
from django.utils.text import slugify
from django.utils.timezone import utc
from simple_history.models import HistoricalRecords
from compass.clients import CompassPersonClient, PersonNotFoundException
from compass.dao.group import is_group_member
from compass.dao import current_datetime
from datetime import datetime, timedelta
from datetime import datetime, timedelta, timezone


class AppUserManager(models.Manager):
Expand Down Expand Up @@ -233,8 +232,8 @@ def by_adviser(self, adviser_uwnetid, offset_hours=72):
kwargs = {"app_user__uwnetid": adviser_uwnetid, "source": "Checkin"}

if offset_hours is not None and offset_hours > 0:
cutoff_dt = current_datetime() - timedelta(hours=offset_hours)
kwargs["checkin_date__gte"] = cutoff_dt.replace(tzinfo=utc)
cutoffdt = current_datetime() - timedelta(hours=offset_hours)
kwargs["checkin_date__gte"] = cutoffdt.replace(tzinfo=timezone.utc)

return super().get_queryset().filter(**kwargs).order_by("checkin_date")

Expand Down
5 changes: 3 additions & 2 deletions compass/views/api/visit.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2024 UW-IT, University of Washington
# SPDX-License-Identifier: Apache-2.0


from django.conf import settings
from compass.views.api import BaseAPIView, TokenAPIView
from compass.models import Visit, Student, AccessGroup, VisitType
from compass.serializers import VisitReadSerializer, VisitTypeSerializer
Expand Down Expand Up @@ -77,7 +77,8 @@ def _valid_date(self, date_str):
return None

try:
dt = parser.parse(date_str)
dt = parser.parse(date_str,
tzinfos=getattr(settings, "TZINFOS", {}))
if dt.tzinfo is None:
raise ValueError("Invalid check-in date, missing timezone")
return dt.astimezone(UTC)
Expand Down
2 changes: 2 additions & 0 deletions docker/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@
UW_PERSON_DB_POOL_SIZE = os.getenv('UW_PERSON_DB_POOL_SIZE', 1)
UW_PERSON_DB_MAX_OVERFLOW = os.getenv('UW_PERSON_DB_MAX_OVERFLOW', 2)

TZINFOS = {"PDT": -7 * 3600}

LOGGING = {
'version': 1,
'disable_existing_loggers': False,
Expand Down
2 changes: 1 addition & 1 deletion docker/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ elif [ -d ${DJANGO_APP}/static/js ]; then
run_test "jshint ${DJANGO_APP}/static/js --verbose"
fi

run_test "coverage run --source=${DJANGO_APP} '--omit=*/migrations/*' manage.py test ${DJANGO_APP}"
run_test "python -Wd -m coverage run --source=${DJANGO_APP} '--omit=*/migrations/*' manage.py test ${DJANGO_APP}"

# put generated coverage result where it will get processed
cp .coverage.* /coverage
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
'Django-Persistent-Message~=1.3',
'UW-RestClients-Django-Utils~=2.3',
'djangorestframework~=3.12',
'UW-RestClients-SWS>=2.4.7,<2.5',
'UW-RestClients-SWS~=2.4',
'UW-RestClients-GWS~=2.3',
'UW-RestClients-PWS~=2.1',
'UW-Django-SAML2~=1.7',
'UW-Django-SAML2~=1.8',
'urllib3~=1.25',
'uw-person-client~=1.2',
'python-dateutil~=2.8',
Expand Down

0 comments on commit 32c7076

Please sign in to comment.