Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
Fix django deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Sauder committed Jan 4, 2018
1 parent 42d013a commit ec000da
Show file tree
Hide file tree
Showing 31 changed files with 52 additions and 35 deletions.
9 changes: 7 additions & 2 deletions timed/employment/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class PublicHoliday(models.Model):
name = models.CharField(max_length=50)
date = models.DateField()
location = models.ForeignKey(Location,
on_delete=models.CASCADE,
related_name='public_holidays')

def __str__(self):
Expand Down Expand Up @@ -132,9 +133,10 @@ class AbsenceCredit(models.Model):
"""

user = models.ForeignKey(settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
related_name='absence_credits')
comment = models.CharField(max_length=255, blank=True)
absence_type = models.ForeignKey(AbsenceType)
absence_type = models.ForeignKey(AbsenceType, on_delete=models.PROTECT)
date = models.DateField()
days = models.IntegerField(default=0)
transfer = models.BooleanField(default=False)
Expand All @@ -151,6 +153,7 @@ class OvertimeCredit(models.Model):
"""

user = models.ForeignKey(settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
related_name='overtime_credits')
comment = models.CharField(max_length=255, blank=True)
date = models.DateField()
Expand Down Expand Up @@ -209,8 +212,10 @@ class Employment(models.Model):
"""

user = models.ForeignKey(settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
related_name='employments')
location = models.ForeignKey(Location, related_name='employments')
location = models.ForeignKey(Location, related_name='employments',
on_delete=models.PROTECT)
percentage = models.IntegerField(validators=[
MinValueValidator(0),
MaxValueValidator(100)])
Expand Down
2 changes: 1 addition & 1 deletion timed/employment/tests/test_absence_balance.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import date, timedelta

from django.core.urlresolvers import reverse
from django.urls import reverse
from rest_framework import status

from timed.employment.factories import (AbsenceCreditFactory,
Expand Down
2 changes: 1 addition & 1 deletion timed/employment/tests/test_absence_credit.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.core.urlresolvers import reverse
from django.urls import reverse
from rest_framework import status

from timed.employment.factories import (AbsenceCreditFactory,
Expand Down
2 changes: 1 addition & 1 deletion timed/employment/tests/test_absence_type.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.core.urlresolvers import reverse
from django.urls import reverse
from rest_framework import status

from timed.employment.factories import AbsenceTypeFactory
Expand Down
2 changes: 1 addition & 1 deletion timed/employment/tests/test_employment.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from datetime import date, timedelta

import pytest
from django.core.urlresolvers import reverse
from django.urls import reverse
from rest_framework import status

from timed.employment import factories
Expand Down
2 changes: 1 addition & 1 deletion timed/employment/tests/test_location.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.core.urlresolvers import reverse
from django.urls import reverse
from rest_framework import status

from timed.employment.factories import LocationFactory
Expand Down
2 changes: 1 addition & 1 deletion timed/employment/tests/test_overtime_credit.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Tests for the overtime credits endpoint."""

from django.core.urlresolvers import reverse
from django.urls import reverse
from rest_framework import status

from timed.employment.factories import OvertimeCreditFactory, UserFactory
Expand Down
2 changes: 1 addition & 1 deletion timed/employment/tests/test_public_holiday.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import date

from django.core.urlresolvers import reverse
from django.urls import reverse
from rest_framework import status

from timed.employment.factories import PublicHolidayFactory
Expand Down
2 changes: 1 addition & 1 deletion timed/employment/tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest
from django.contrib.auth import get_user_model
from django.core.urlresolvers import reverse
from django.urls import reverse
from rest_framework import status

from timed.employment.factories import (AbsenceTypeFactory, EmploymentFactory,
Expand Down
2 changes: 1 addition & 1 deletion timed/employment/tests/test_worktime_balance.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from datetime import date, timedelta

import pytest
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.utils.duration import duration_string
from rest_framework import status

Expand Down
2 changes: 2 additions & 0 deletions timed/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class Project(models.Model):
archived = models.BooleanField(default=False)
estimated_time = models.DurationField(blank=True, null=True)
customer = models.ForeignKey('projects.Customer',
on_delete=models.CASCADE,
related_name='projects')
billing_type = models.ForeignKey(BillingType, on_delete=models.SET_NULL,
blank=True, null=True,
Expand Down Expand Up @@ -108,6 +109,7 @@ class Task(models.Model):
estimated_time = models.DurationField(blank=True, null=True)
archived = models.BooleanField(default=False)
project = models.ForeignKey('projects.Project',
on_delete=models.CASCADE,
related_name='tasks')
cost_center = models.ForeignKey(CostCenter, on_delete=models.SET_NULL,
blank=True, null=True,
Expand Down
2 changes: 1 addition & 1 deletion timed/projects/tests/test_billing_type.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.core.urlresolvers import reverse
from django.urls import reverse
from rest_framework.status import HTTP_200_OK

from timed.projects.factories import BillingTypeFactory
Expand Down
2 changes: 1 addition & 1 deletion timed/projects/tests/test_cost_center.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.core.urlresolvers import reverse
from django.urls import reverse
from rest_framework.status import HTTP_200_OK

from timed.projects.factories import CostCenterFactory
Expand Down
2 changes: 1 addition & 1 deletion timed/projects/tests/test_customer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Tests for the customers endpoint."""

from django.core.urlresolvers import reverse
from django.urls import reverse
from rest_framework import status

from timed.projects.factories import CustomerFactory
Expand Down
2 changes: 1 addition & 1 deletion timed/projects/tests/test_project.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Tests for the projects endpoint."""
from datetime import timedelta

from django.core.urlresolvers import reverse
from django.urls import reverse
from rest_framework import status

from timed.employment.factories import UserFactory
Expand Down
2 changes: 1 addition & 1 deletion timed/projects/tests/test_task.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Tests for the tasks endpoint."""
from datetime import date, timedelta

from django.core.urlresolvers import reverse
from django.urls import reverse
from rest_framework import status

from timed.projects.factories import TaskFactory
Expand Down
2 changes: 1 addition & 1 deletion timed/reports/tests/test_customer_statistic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import timedelta

from django.core.urlresolvers import reverse
from django.urls import reverse

from timed.tracking.factories import ReportFactory

Expand Down
2 changes: 1 addition & 1 deletion timed/reports/tests/test_month_statistic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import date, timedelta

from django.core.urlresolvers import reverse
from django.urls import reverse

from timed.tracking.factories import ReportFactory

Expand Down
2 changes: 1 addition & 1 deletion timed/reports/tests/test_project_statistic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import timedelta

from django.core.urlresolvers import reverse
from django.urls import reverse

from timed.tracking.factories import ReportFactory

Expand Down
2 changes: 1 addition & 1 deletion timed/reports/tests/test_task_statistic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import timedelta

from django.core.urlresolvers import reverse
from django.urls import reverse

from timed.projects.factories import TaskFactory
from timed.tracking.factories import ReportFactory
Expand Down
2 changes: 1 addition & 1 deletion timed/reports/tests/test_user_statistic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import timedelta

from django.core.urlresolvers import reverse
from django.urls import reverse

from timed.tracking.factories import ReportFactory

Expand Down
2 changes: 1 addition & 1 deletion timed/reports/tests/test_work_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import ezodf
import pytest
from django.core.urlresolvers import reverse
from django.urls import reverse
from rest_framework.status import HTTP_200_OK, HTTP_400_BAD_REQUEST

from timed.projects.factories import (CustomerFactory, ProjectFactory,
Expand Down
2 changes: 1 addition & 1 deletion timed/reports/tests/test_year_statistic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import date, timedelta

from django.core.urlresolvers import reverse
from django.urls import reverse

from timed.tracking.factories import ReportFactory

Expand Down
8 changes: 5 additions & 3 deletions timed/subscription/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __str__(self):
class Package(models.Model):
"""Representing a subscription package."""

subscription = models.ForeignKey(Subscription)
subscription = models.ForeignKey(Subscription, on_delete=models.CASCADE)
duration = models.DurationField()
price = MoneyField(max_digits=7, decimal_places=2,
default_currency='CHF')
Expand All @@ -36,7 +36,8 @@ class SubscriptionProject(models.Model):
A project can only be assigned to one subscription.
"""

project = models.OneToOneField('projects.Project')
project = models.OneToOneField('projects.Project',
on_delete=models.CASCADE)
subscription = models.ForeignKey(Subscription, on_delete=models.CASCADE)


Expand All @@ -63,6 +64,7 @@ class CustomerPassword(models.Model):
once customer center will go live.
"""

customer = models.OneToOneField('projects.Customer')
customer = models.OneToOneField('projects.Customer',
on_delete=models.CASCADE)
password = models.CharField(_('password'), max_length=128,
null=True, blank=True)
2 changes: 1 addition & 1 deletion timed/tests/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import json

from django.core.urlresolvers import reverse
from django.urls import reverse
from rest_framework import exceptions, status
from rest_framework.test import APIClient
from rest_framework_jwt.settings import api_settings
Expand Down
14 changes: 11 additions & 3 deletions timed/tracking/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ class Activity(models.Model):
task = models.ForeignKey('projects.Task',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='activities')
user = models.ForeignKey(settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
related_name='activities')

@property
Expand Down Expand Up @@ -56,6 +58,7 @@ class ActivityBlock(models.Model):
"""

activity = models.ForeignKey('tracking.Activity',
on_delete=models.CASCADE,
related_name='blocks')
from_time = models.TimeField()
to_time = models.TimeField(blank=True, null=True)
Expand All @@ -77,6 +80,7 @@ class Attendance(models.Model):
from_time = models.TimeField()
to_time = models.TimeField()
user = models.ForeignKey(settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
related_name='attendances')

def __str__(self):
Expand Down Expand Up @@ -106,13 +110,15 @@ class Report(models.Model):
duration = models.DurationField()
review = models.BooleanField(default=False)
not_billable = models.BooleanField(default=False)
task = models.ForeignKey('projects.Task', related_name='reports')
task = models.ForeignKey('projects.Task', related_name='reports',
on_delete=models.PROTECT)
activity = models.ForeignKey(Activity,
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='reports')
user = models.ForeignKey(settings.AUTH_USER_MODEL,
on_delete=models.PROTECT,
related_name='reports')
verified_by = models.ForeignKey(settings.AUTH_USER_MODEL,
on_delete=models.SET_NULL,
Expand Down Expand Up @@ -161,7 +167,7 @@ def get_queryset(self):
models.Q(end_date__isnull=True)
),
start_date__lte=models.OuterRef('date'),
user_id=models.OuterRef(models.OuterRef('user'))
user=models.OuterRef(models.OuterRef('user'))
).values('location')[:1]

queryset = super().get_queryset()
Expand All @@ -183,8 +189,10 @@ class Absence(models.Model):
comment = models.TextField(blank=True)
date = models.DateField()
type = models.ForeignKey('employment.AbsenceType',
related_name='absences')
related_name='absences',
on_delete=models.PROTECT)
user = models.ForeignKey(settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
related_name='absences')
objects = AbsenceManager()

Expand Down
2 changes: 1 addition & 1 deletion timed/tracking/tests/test_absence.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime

from django.core.urlresolvers import reverse
from django.urls import reverse
from rest_framework import status

from timed.employment.factories import (AbsenceTypeFactory, EmploymentFactory,
Expand Down
2 changes: 1 addition & 1 deletion timed/tracking/tests/test_activity.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import date, timedelta

from django.core.urlresolvers import reverse
from django.urls import reverse
from rest_framework import status

from timed.projects.factories import TaskFactory
Expand Down
2 changes: 1 addition & 1 deletion timed/tracking/tests/test_activity_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from datetime import time

from django.core.urlresolvers import reverse
from django.urls import reverse
from rest_framework import status

from timed.tracking.factories import ActivityBlockFactory, ActivityFactory
Expand Down
2 changes: 1 addition & 1 deletion timed/tracking/tests/test_attendance.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.core.urlresolvers import reverse
from django.urls import reverse
from rest_framework import status

from timed.tracking.factories import AttendanceFactory
Expand Down
2 changes: 1 addition & 1 deletion timed/tracking/tests/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pyexcel
import pytest
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.utils.duration import duration_string
from rest_framework import status

Expand Down

0 comments on commit ec000da

Please sign in to comment.