Skip to content

Commit 137be8f

Browse files
committed
Updated backend.
1 parent 671a225 commit 137be8f

15 files changed

Lines changed: 181 additions & 110 deletions

File tree

.github/workflows/django.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ jobs:
1313
strategy:
1414
max-parallel: 4
1515
matrix:
16-
python-version: [3.7, 3.8, 3.9]
16+
python-version: [3.8, 3.9, "3.10", "3.11"]
1717

1818
steps:
1919
- uses: actions/checkout@v4
2020
- name: Set up Python ${{ matrix.python-version }}
21-
uses: actions/setup-python@v3
21+
uses: actions/setup-python@v5
2222
with:
2323
python-version: ${{ matrix.python-version }}
2424
- name: Install Dependencies
@@ -27,4 +27,6 @@ jobs:
2727
pip install -r requirements.txt
2828
- name: Run Tests
2929
run: |
30+
python manage.py collectstatic --noinput
31+
python manage.py check
3032
python manage.py test

.github/workflows/pylint.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
python-version: ["3.8", "3.9", "3.10"]
10+
python-version: ["3.8", "3.9", "3.10", "3.11"]
1111
steps:
1212
- uses: actions/checkout@v4
1313
- name: Set up Python ${{ matrix.python-version }}
14-
uses: actions/setup-python@v3
14+
uses: actions/setup-python@v5
1515
with:
1616
python-version: ${{ matrix.python-version }}
1717
- name: Install dependencies
1818
run: |
1919
python -m pip install --upgrade pip
2020
pip install pylint
21+
pip install -r requirements.txt
2122
- name: Analysing the code with pylint
2223
run: |
23-
pylint $(git ls-files '*.py')
24+
pylint $(find . -name "*.py" | xargs)
Lines changed: 70 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,87 @@
1-
# -*- coding: utf-8 -*-
2-
"""Generated by Django 1.9.4 on 2016-03-08 15:04"""
3-
from __future__ import unicode_literals
1+
# Generated by Django 4.2.15 on 2025-09-19 04:02
42

5-
import django.contrib.auth.models
63
from django.db import migrations, models
74
import django.utils.timezone
85

96

107
class Migration(migrations.Migration):
11-
"""
12-
Initial database migration.
13-
"""
8+
149
initial = True
1510

1611
dependencies = [
17-
('auth', '0007_alter_validators_add_error_messages'),
12+
("auth", "0012_alter_user_first_name_max_length"),
1813
]
1914

2015
operations = [
2116
migrations.CreateModel(
22-
name='EmailUser',
17+
name="EmailUser",
2318
fields=[
24-
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
25-
('password', models.CharField(max_length=128, verbose_name='password')),
26-
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
27-
('is_superuser', models.BooleanField(
28-
default=False,
29-
help_text='Designates that this user has all permissions without explicitly assigning them.',
30-
verbose_name='superuser status')),
31-
('first_name', models.CharField(max_length=30)),
32-
('last_name', models.CharField(max_length=30)),
33-
('email', models.EmailField(error_messages={'unique': 'That email address is already taken.'},
34-
max_length=254, unique=True)),
35-
('is_staff', models.BooleanField(default=False)),
36-
('is_active', models.BooleanField(default=True)),
37-
('date_joined', models.DateTimeField(default=django.utils.timezone.now)),
38-
('groups', models.ManyToManyField(
39-
blank=True,
40-
help_text='The groups this user belongs to. A user will get all permissions granted to each of '
41-
'their groups.',
42-
related_name='user_set',
43-
related_query_name='user',
44-
to='auth.Group',
45-
verbose_name='groups')),
46-
('user_permissions', models.ManyToManyField(blank=True,
47-
help_text='Specific permissions for this user.',
48-
related_name='user_set',
49-
related_query_name='user',
50-
to='auth.Permission',
51-
verbose_name='user permissions')),
52-
],
53-
options={
54-
'permissions': (('view_emailuser', 'Can view email users'),),
55-
},
56-
managers=[
57-
('objects', django.contrib.auth.models.UserManager()),
19+
(
20+
"id",
21+
models.BigAutoField(
22+
auto_created=True,
23+
primary_key=True,
24+
serialize=False,
25+
verbose_name="ID",
26+
),
27+
),
28+
("password", models.CharField(max_length=128, verbose_name="password")),
29+
(
30+
"last_login",
31+
models.DateTimeField(
32+
blank=True, null=True, verbose_name="last login"
33+
),
34+
),
35+
(
36+
"is_superuser",
37+
models.BooleanField(
38+
default=False,
39+
help_text="Designates that this user has all permissions without explicitly assigning them.",
40+
verbose_name="superuser status",
41+
),
42+
),
43+
("first_name", models.CharField(max_length=30)),
44+
("last_name", models.CharField(max_length=30)),
45+
(
46+
"email",
47+
models.EmailField(
48+
error_messages={
49+
"unique": "That email address is already taken."
50+
},
51+
max_length=254,
52+
unique=True,
53+
),
54+
),
55+
("is_staff", models.BooleanField(default=False)),
56+
("is_active", models.BooleanField(default=True)),
57+
(
58+
"date_joined",
59+
models.DateTimeField(default=django.utils.timezone.now),
60+
),
61+
("last_updated", models.DateTimeField(auto_now=True)),
62+
(
63+
"groups",
64+
models.ManyToManyField(
65+
blank=True,
66+
help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.",
67+
related_name="user_set",
68+
related_query_name="user",
69+
to="auth.group",
70+
verbose_name="groups",
71+
),
72+
),
73+
(
74+
"user_permissions",
75+
models.ManyToManyField(
76+
blank=True,
77+
help_text="Specific permissions for this user.",
78+
related_name="user_set",
79+
related_query_name="user",
80+
to="auth.permission",
81+
verbose_name="user permissions",
82+
),
83+
),
5884
],
85+
options={"abstract": False,},
5986
),
6087
]

backend/apps/users/migrations/0002_auto_20160309_1423.py

Lines changed: 0 additions & 28 deletions
This file was deleted.

backend/apps/users/models.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,8 @@ class EmailUser(AbstractBaseUser, PermissionsMixin):
7373
USERNAME_FIELD = 'email'
7474
REQUIRED_FIELDS = ['first_name', 'last_name']
7575

76-
class Meta:
77-
permissions = (
78-
('view_emailuser', 'Can view email users'),
79-
)
80-
81-
def __unicode__(self):
82-
return self.email
76+
def __str__(self):
77+
return str(self.email)
8378

8479
def get_short_name(self):
8580
return '{first_name}'.format(

backend/apps/users/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ class UserViewSet(viewsets.ModelViewSet):
1010
serializer_class = UserSerializer
1111
queryset = User.objects.all()
1212
search_fields = ('first_name', 'last_name', 'email')
13-
filter_fields = ('id', 'first_name', 'last_name', 'email')
13+
filterset_fields = ('id', 'first_name', 'last_name', 'email')

backend/requirements/common.pip

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
django==1.9.4
2-
django-extensions==1.6.1
3-
django-filter==0.12.0
4-
djangorestframework==3.3.2
5-
psycopg2==2.6.1
1+
Django>=4.2,<5.0
2+
django-extensions>=3.2.0
3+
django-filter>=22.1
4+
djangorestframework>=3.14.0
5+
psycopg2-binary>=2.9.0

backend/requirements/devl.pip

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
-r ./common.pip
2-
django-autofixture==0.12.0
3-
flake8==2.5.4
2+
model-bakery>=1.17,<2.0
3+
flake8>=6.1,<8.0

backend/settings/common.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
from sys import path
33
from os.path import join
44

5-
from django.core.urlresolvers import reverse_lazy
5+
from django.urls import reverse_lazy
66

77
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
88
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
99

10+
# Define the default primary key field type
11+
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
12+
1013
path.append(join(BASE_DIR, 'apps'))
1114

1215
ALLOWED_HOSTS = []
@@ -23,6 +26,7 @@
2326
THIRD_PARTY_APPS = [
2427
"django_extensions",
2528
"rest_framework",
29+
"django_filters",
2630
]
2731

2832
LOCAL_APPS = [
@@ -31,13 +35,12 @@
3135

3236
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
3337

34-
MIDDLEWARE_CLASSES = [
38+
MIDDLEWARE = [
3539
"django.middleware.security.SecurityMiddleware",
3640
"django.contrib.sessions.middleware.SessionMiddleware",
3741
"django.middleware.common.CommonMiddleware",
3842
"django.middleware.csrf.CsrfViewMiddleware",
3943
"django.contrib.auth.middleware.AuthenticationMiddleware",
40-
"django.contrib.auth.middleware.SessionAuthenticationMiddleware",
4144
"django.contrib.messages.middleware.MessageMiddleware",
4245
"django.middleware.clickjacking.XFrameOptionsMiddleware",
4346
]
@@ -114,7 +117,7 @@
114117
"DEFAULT_PAGINATION_CLASS": "backend.pagination.StandardPagination",
115118
"DEFAULT_FILTER_BACKENDS": (
116119
"rest_framework.filters.SearchFilter",
117-
"rest_framework.filters.DjangoFilterBackend",
120+
"django_filters.rest_framework.DjangoFilterBackend",
118121
),
119122
}
120123

backend/settings/devl.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,19 @@
33
from .common import *
44

55
# SECURITY WARNING: keep the secret key used in production secret!
6-
SECRET_KEY = '{{ secret_key }}'
6+
SECRET_KEY = 'django-insecure-dev-key-for-testing-only'
77

88
# SECURITY WARNING: don't run with debug turned on in production!
99
DEBUG = True
1010

1111
DATABASES = {
1212
'default': {
13-
'ENGINE': 'django.db.backends.postgresql',
14-
'USER': '',
15-
'NAME': '{{ project_name }}',
13+
'ENGINE': 'django.db.backends.sqlite3',
14+
'NAME': os.path.join(BASE_DIR, os.pardir, 'db.sqlite3'),
1615
}
1716
}
1817

19-
INTERNAL_IPS = ['192.168.56.1']
20-
21-
INSTALLED_APPS += (
22-
'autofixture',
23-
)
18+
INTERNAL_IPS = ['192.168.56.1', '127.0.0.1']
2419

2520
STATICFILES_DIRS.append(
2621
os.path.join(BASE_DIR, os.pardir, 'frontend', 'build'),

0 commit comments

Comments
 (0)