Commit 94bb94a7 authored by Erlend Ydse's avatar Erlend Ydse
Browse files

Remove unused imports and sort imports

parent 2b822777
Pipeline #128399 passed with stage
in 1 minute and 7 seconds
......@@ -3,5 +3,4 @@ from django.contrib import admin
# Register your models here.
from .models import Comment
admin.site.register(Comment)
from django.contrib.auth import get_user_model
from django.db import models
from django.conf import settings
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.urls import reverse
from django.db import models
from django.contrib.auth import get_user_model
from workouts.models import Workout
# Create your models here.
class Comment(models.Model):
"""Django model for a comment left on a workout.
......
from rest_framework import serializers
from rest_framework.serializers import HyperlinkedRelatedField
from comments.models import Comment
from workouts.models import Workout
......
from django.urls import path, include
from comments.models import Comment
from comments.views import CommentList, CommentDetail
from rest_framework.urlpatterns import format_suffix_patterns
from django.urls import path
from comments.views import CommentDetail, CommentList
urlpatterns = [
path("api/comments/", CommentList.as_view(), name="comment-list"),
......
from django.shortcuts import render
from rest_framework import generics, mixins
from django.db.models import Q
from rest_framework import generics, mixins, permissions
from rest_framework.filters import OrderingFilter
from comments.models import Comment
from rest_framework import permissions
from comments.permissions import IsCommentVisibleToUser
from workouts.permissions import IsOwner, IsReadOnly
from comments.serializers import CommentSerializer
from django.db.models import Q
from rest_framework.filters import OrderingFilter
from workouts.permissions import IsOwner, IsReadOnly
# Create your views here.
class CommentList(
......
import os
import dj_database_url
from django.test.runner import DiscoverRunner
MAX_CONN_AGE = 600
......
......@@ -10,10 +10,10 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""
from pathlib import Path
import os
from secfit.djangoHeroku import settings
from pathlib import Path
from secfit.djangoHeroku import settings
# Get the GROUPID variable to accept connections from the application server and NGINX
groupid = os.environ.get("GROUPID", "0")
......
......@@ -13,10 +13,10 @@ Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path("admin/", admin.site.urls),
......
from abc import ABC
from typing import List
from django.http.response import HttpResponse
from django.test import TestCase
from rest_framework.test import APIClient, APIRequestFactory, APITestCase
from rest_framework.test import APIClient, APITestCase
from users.models import User
class Fields:
def __init__(self) -> None:
self.usernames = [Username("alice", True), Username("/", False)]
......@@ -130,5 +132,3 @@ class UserRegistration2WayDomainTests(APITestCase):
except AssertionError as e:
failures.append({ first_field.name: first_field.value, second_field.name: second_field.value, "error": e })
self.assertEqual(len(failures), 0)
\ No newline at end of file
from io import FileIO
from django.http import response
from django.test import TestCase
from django.urls.conf import path
from rest_framework.test import APIClient, APIRequestFactory, APITestCase
from PIL import Image
from rest_framework.test import APIClient, APITestCase
class EditProfileAPITests(APITestCase):
def setUp(self):
......@@ -60,4 +57,4 @@ class EditProfileAPITests(APITestCase):
data = { "bio": "hello", "athletes": self.alice_data['athletes'] }
response = self.client.put(path=f"{self.path}{self.alice_data['id']}/", data=data)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.data["bio"], "hello")
\ No newline at end of file
self.assertEqual(response.data["bio"], "hello")
from django.test import TestCase
from django.urls.conf import path
from rest_framework.test import APIClient, APIRequestFactory, APITestCase
import unittest
from rest_framework.test import APIClient, APITestCase
#@unittest.skip("not finished")
class FriendRequestAPITests(APITestCase):
......@@ -101,4 +99,4 @@ class FriendRequestAPITests(APITestCase):
# response = self.client.patch(path=self.fr_path + "accept_request/", data=self.data)
# print(response.__dict__)
# print(response.status_code)
# print(response.data)
\ No newline at end of file
# print(response.data)
from datetime import time
from users.models import User
from django.utils import timezone
from django.test import TestCase
from rest_framework.test import APIClient, APIRequestFactory, APITestCase
from workouts.models import Exercise
from sys import maxsize
from django.db.utils import IntegrityError
from PIL import Image
from django.utils import timezone
from rest_framework.test import APIClient, APITestCase
class WorkoutCreationTests(APITestCase):
def setUp(self):
......@@ -223,4 +218,4 @@ class WorkoutCreationTests(APITestCase):
self.assertEqual(response.status_code, 201)
data["notes"] = "Bad workout"
response = self.client.put(f"{self.path}{response.data['id']}/", data=data, format="json")
self.assertEqual(response.status_code, 200)
\ No newline at end of file
self.assertEqual(response.status_code, 200)
from django.test import TestCase
from rest_framework.test import APIClient, APIRequestFactory, APITestCase
from rest_framework.test import APIClient, APITestCase
class UserRegistrationTests(APITestCase):
......@@ -124,4 +123,4 @@ class UserRegistrationTests(APITestCase):
"city": "",
"street_address": ""}
response = self.client.post(path=self.path, data=data)
self.assertEqual(response.status_code, 201)
\ No newline at end of file
self.assertEqual(response.status_code, 201)
from typing import Dict
from django.db.models.base import Model
from rest_framework import serializers
import rest_framework
from rest_framework.exceptions import ValidationError
from users.serializers import AthleteFileSerializer, OfferSerializer, UserGetSerializer, UserPutSerializer, UserSerializer
from django.db.utils import IntegrityError
from django.test import TestCase
from rest_framework.exceptions import ValidationError
from users.models import AthleteFile, Offer, User
from django.db.utils import IntegrityError
from users.serializers import (AthleteFileSerializer, OfferSerializer,
UserPutSerializer, UserSerializer)
# Create your tests here.
......@@ -159,4 +160,3 @@ class UserSerializerTests(TestCase):
}
result = off_ser.create(validated_data=validated_data)
self.assertIsInstance(result, Offer)
"""
Tests for the workouts application.
"""
from workouts.models import Exercise, Workout
from django.http.request import HttpRequest
from workouts.permissions import IsCoachAndVisibleToCoach, IsCoachOfWorkoutAndVisibleToCoach, IsOwner, IsOwnerOfWorkout, IsPublic, IsReadOnly, IsWorkoutPublic
from django.test import TestCase
from users.models import User
from django.utils import timezone
from users.models import User
from workouts.models import Workout
from workouts.permissions import (IsCoachAndVisibleToCoach,
IsCoachOfWorkoutAndVisibleToCoach, IsOwner,
IsOwnerOfWorkout, IsPublic, IsReadOnly,
IsWorkoutPublic)
# Create your tests here.
......
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from .models import Offer, AthleteFile
from django.contrib.auth import get_user_model
from django.contrib.auth.admin import UserAdmin
from .forms import CustomUserChangeForm, CustomUserCreationForm
from .models import AthleteFile, Offer
# Register your models here.
......
from django import forms
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
from django.contrib.auth import get_user_model
from django.contrib.auth.forms import UserChangeForm, UserCreationForm
class CustomUserCreationForm(UserCreationForm):
......
from django.db import models
from django.contrib.auth.models import AbstractUser
from django.contrib.auth import get_user_model
from django.contrib.auth.models import AbstractUser
from django.db import models
def profile_image_directory_path(instance, filename):
......
from rest_framework import permissions
from django.contrib.auth import get_user_model
from rest_framework import permissions
class IsCurrentUser(permissions.BasePermission):
......
from typing import Dict
from rest_framework import serializers
from django.contrib.auth import get_user_model, password_validation
from users.models import Offer, AthleteFile
from django import forms
from django.contrib.auth import get_user_model, password_validation
from rest_framework import serializers
from users.models import AthleteFile, Offer
class UserSerializer(serializers.HyperlinkedModelSerializer):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment