From ad33d33e6c60e05ed1fc8f7ec43e98cd1512c0d5 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Wed, 23 Sep 2020 20:14:44 +0200 Subject: [PATCH 01/11] Test project on Debian and Ubuntu --- .gitlab-ci.yml | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 081f023..7e28664 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,22 +1,37 @@ -image: python:3.8 - stages: - test + - quality-assurance -before_script: - - pip install tox - -python37: - image: python:3.7 +py37-django22: stage: test + image: debian:buster-backports + before_script: + - > + apt-get update && + apt-get install --no-install-recommends -t buster-backports -y + python3-django python3-django-casclient python3-django-reversion python3-djangorestframework \ + python3-docutils python3-pil python3-tz python3-six python3-sqlparse python3-stdnum python3-yaml python3-coreapi script: tox -e py37 -python38: - image: python:3.8 +py38-django22: stage: test + image: ubuntu:20.04 + before_script: + # Fix tzdata prompt + - ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime && echo Europe/Paris > /etc/timezone + - > + apt-get update && + apt-get install --no-install-recommends -y + python3-django python3-django-casclient python3-django-reversion python3-djangorestframework \ + python3-docutils python3-pil python3-tz python3-six python3-sqlparse python3-stdnum python3-yaml python3-coreapi script: tox -e py37 linters: - stage: test + stage: quality-assurance + image: debian:buster-backports + before_script: + - apt-get update && apt-get install -y tox script: tox -e linters + + # Be nice to new contributors, but please use `tox` allow_failure: true From 8d20b14cbbae905d92a741e4dfe93273b15e7124 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Wed, 23 Sep 2020 20:19:31 +0200 Subject: [PATCH 02/11] Remove additional newline in imports --- logs/tests/test_templates.py | 1 - logs/views.py | 1 - media/admin.py | 5 ++--- media/management/commands/import_cds.py | 1 - media/management/commands/import_future_media.py | 1 - media/management/commands/import_isbn.py | 1 - media/management/commands/import_no_isbn_roman.py | 1 - media/management/commands/import_vinyles.py | 1 - media/management/commands/split_media_types.py | 1 - media/scraper.py | 1 - media/tests/test_templates.py | 1 - users/admin.py | 5 ++--- users/models.py | 1 - users/tests/test_templates.py | 1 - users/views.py | 3 +-- 15 files changed, 5 insertions(+), 20 deletions(-) diff --git a/logs/tests/test_templates.py b/logs/tests/test_templates.py index 9c6b0e9..d953ff5 100644 --- a/logs/tests/test_templates.py +++ b/logs/tests/test_templates.py @@ -3,7 +3,6 @@ from django.test import TestCase from django.urls import reverse - from users.models import User """ diff --git a/logs/views.py b/logs/views.py index 4eac1a9..0b45c67 100644 --- a/logs/views.py +++ b/logs/views.py @@ -9,7 +9,6 @@ from django.db.models import Count from django.shortcuts import render from django.utils.translation import gettext_lazy as _ from reversion.models import Revision - from med.settings import PAGINATION_NUMBER from users.models import User diff --git a/media/admin.py b/media/admin.py index 3ecbab2..bffb4a1 100644 --- a/media/admin.py +++ b/media/admin.py @@ -6,10 +6,9 @@ from django.urls import reverse from django.utils.html import format_html from django.utils.translation import ugettext_lazy as _ from reversion.admin import VersionAdmin - from med.admin import admin_site -from .forms import MediaAdminForm -from .models import Auteur, BD, CD, Emprunt, FutureMedia, Jeu, Manga,\ +from media.forms import MediaAdminForm +from media.models import Auteur, BD, CD, Emprunt, FutureMedia, Jeu, Manga,\ Revue, Roman, Vinyle diff --git a/media/management/commands/import_cds.py b/media/management/commands/import_cds.py index d783a12..3498958 100644 --- a/media/management/commands/import_cds.py +++ b/media/management/commands/import_cds.py @@ -2,7 +2,6 @@ from argparse import FileType from sys import stdin from django.core.management import BaseCommand - from media.models import Auteur, CD diff --git a/media/management/commands/import_future_media.py b/media/management/commands/import_future_media.py index 3e39022..d028b4e 100644 --- a/media/management/commands/import_future_media.py +++ b/media/management/commands/import_future_media.py @@ -2,7 +2,6 @@ from time import sleep from django.core.exceptions import ValidationError from django.core.management import BaseCommand - from media.forms import MediaAdminForm from media.models import BD, FutureMedia, Manga, Roman diff --git a/media/management/commands/import_isbn.py b/media/management/commands/import_isbn.py index 9db98cb..c7bd893 100644 --- a/media/management/commands/import_isbn.py +++ b/media/management/commands/import_isbn.py @@ -3,7 +3,6 @@ from sys import stdin from django.core.exceptions import ValidationError from django.core.management import BaseCommand - from media.models import BD, FutureMedia, Manga, Roman from media.validators import isbn_validator diff --git a/media/management/commands/import_no_isbn_roman.py b/media/management/commands/import_no_isbn_roman.py index 5e822fc..64d5811 100644 --- a/media/management/commands/import_no_isbn_roman.py +++ b/media/management/commands/import_no_isbn_roman.py @@ -4,7 +4,6 @@ from argparse import FileType from sys import stdin from django.core.management import BaseCommand - from media.models import Auteur, Roman diff --git a/media/management/commands/import_vinyles.py b/media/management/commands/import_vinyles.py index dc64372..029fbff 100644 --- a/media/management/commands/import_vinyles.py +++ b/media/management/commands/import_vinyles.py @@ -2,7 +2,6 @@ from argparse import FileType from sys import stdin from django.core.management import BaseCommand - from media.models import Auteur, Vinyle diff --git a/media/management/commands/split_media_types.py b/media/management/commands/split_media_types.py index 823009a..fe7fd7d 100644 --- a/media/management/commands/split_media_types.py +++ b/media/management/commands/split_media_types.py @@ -1,7 +1,6 @@ from time import sleep from django.core.management import BaseCommand - from media.forms import MediaAdminForm from media.models import BD, Manga diff --git a/media/scraper.py b/media/scraper.py index 84de5a8..0026d61 100644 --- a/media/scraper.py +++ b/media/scraper.py @@ -4,7 +4,6 @@ import re import requests - from media.models import Auteur diff --git a/media/tests/test_templates.py b/media/tests/test_templates.py index c103359..bdea46d 100644 --- a/media/tests/test_templates.py +++ b/media/tests/test_templates.py @@ -3,7 +3,6 @@ from django.test import TestCase from django.urls import reverse - from media.models import Auteur, BD from users.models import User diff --git a/users/admin.py b/users/admin.py index effd1c0..6332258 100644 --- a/users/admin.py +++ b/users/admin.py @@ -10,10 +10,9 @@ from django.urls import reverse from django.utils.html import format_html from django.utils.translation import ugettext_lazy as _ from reversion.admin import VersionAdmin - from med.admin import admin_site -from .forms import UserCreationAdminForm -from .models import Adhesion, User +from users.forms import UserCreationAdminForm +from users.models import Adhesion, User class AdhesionAdmin(VersionAdmin): diff --git a/users/models.py b/users/models.py index e333b58..bdd5092 100644 --- a/users/models.py +++ b/users/models.py @@ -6,7 +6,6 @@ from django.contrib.auth.models import AbstractUser from django.db import models from django.utils import timezone from django.utils.translation import gettext_lazy as _ - from med.settings import MAX_EMPRUNT diff --git a/users/tests/test_templates.py b/users/tests/test_templates.py index 1a8b9c9..f94e9b7 100644 --- a/users/tests/test_templates.py +++ b/users/tests/test_templates.py @@ -4,7 +4,6 @@ from django.core import mail from django.test import TestCase from django.urls import reverse - from users.models import User """ diff --git a/users/views.py b/users/views.py index 08e8238..cd65089 100644 --- a/users/views.py +++ b/users/views.py @@ -11,10 +11,9 @@ from django.template.context_processors import csrf from django.utils.translation import ugettext_lazy as _ from rest_framework import viewsets from reversion import revisions as reversion - from users.forms import BaseInfoForm from users.models import Adhesion, User -from .serializers import GroupSerializer, UserSerializer +from users.serializers import GroupSerializer, UserSerializer def form(ctx, template, request): From 9a7304f5735a01fe0583607794059659f72c8270 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Wed, 23 Sep 2020 20:21:55 +0200 Subject: [PATCH 03/11] Add __str__ on Adhesion model --- users/models.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/users/models.py b/users/models.py index bdd5092..56fd01e 100644 --- a/users/models.py +++ b/users/models.py @@ -69,3 +69,6 @@ class Adhesion(models.Model): class Meta: verbose_name = _('membership year') verbose_name_plural = _('membership years') + + def __str__(self): + return f"{self.starting_in} - {self.ending_in}" From 91b361d7a673a6e2c61062651e5de6890d5de4e5 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Wed, 23 Sep 2020 20:31:25 +0200 Subject: [PATCH 04/11] Do not make string nullable in database --- media/migrations/0038_auto_20200923_2030.py | 55 +++++++++++++++++++++ media/models.py | 7 --- users/migrations/0041_auto_20200923_2030.py | 25 ++++++++++ users/models.py | 2 - 4 files changed, 80 insertions(+), 9 deletions(-) create mode 100644 media/migrations/0038_auto_20200923_2030.py create mode 100644 users/migrations/0041_auto_20200923_2030.py diff --git a/media/migrations/0038_auto_20200923_2030.py b/media/migrations/0038_auto_20200923_2030.py new file mode 100644 index 0000000..07d7ee4 --- /dev/null +++ b/media/migrations/0038_auto_20200923_2030.py @@ -0,0 +1,55 @@ +# Generated by Django 2.2.12 on 2020-09-23 18:30 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('media', '0037_revue_double'), + ] + + operations = [ + migrations.AlterField( + model_name='bd', + name='external_url', + field=models.URLField(blank=True, default='', verbose_name='external URL'), + preserve_default=False, + ), + migrations.AlterField( + model_name='bd', + name='subtitle', + field=models.CharField(blank=True, default='', max_length=255, verbose_name='subtitle'), + preserve_default=False, + ), + migrations.AlterField( + model_name='jeu', + name='comment', + field=models.CharField(blank=True, default='', max_length=255, verbose_name='comment'), + preserve_default=False, + ), + migrations.AlterField( + model_name='manga', + name='external_url', + field=models.URLField(blank=True, default='', verbose_name='external URL'), + preserve_default=False, + ), + migrations.AlterField( + model_name='manga', + name='subtitle', + field=models.CharField(blank=True, default='', max_length=255, verbose_name='subtitle'), + preserve_default=False, + ), + migrations.AlterField( + model_name='roman', + name='external_url', + field=models.URLField(blank=True, default='', verbose_name='external URL'), + preserve_default=False, + ), + migrations.AlterField( + model_name='roman', + name='subtitle', + field=models.CharField(blank=True, default='', max_length=255, verbose_name='subtitle'), + preserve_default=False, + ), + ] diff --git a/media/models.py b/media/models.py index d6df7ba..eb40416 100644 --- a/media/models.py +++ b/media/models.py @@ -48,13 +48,11 @@ class BD(models.Model): verbose_name=_('subtitle'), max_length=255, blank=True, - null=True, ) external_url = models.URLField( verbose_name=_('external URL'), blank=True, - null=True, ) side_identifier = models.CharField( @@ -109,13 +107,11 @@ class Manga(models.Model): verbose_name=_('subtitle'), max_length=255, blank=True, - null=True, ) external_url = models.URLField( verbose_name=_('external URL'), blank=True, - null=True, ) side_identifier = models.CharField( @@ -167,13 +163,11 @@ class Roman(models.Model): verbose_name=_('subtitle'), max_length=255, blank=True, - null=True, ) external_url = models.URLField( verbose_name=_('external URL'), blank=True, - null=True, ) side_identifier = models.CharField( @@ -415,7 +409,6 @@ class Jeu(models.Model): comment = models.CharField( max_length=255, blank=True, - null=True, verbose_name=_('comment'), ) diff --git a/users/migrations/0041_auto_20200923_2030.py b/users/migrations/0041_auto_20200923_2030.py new file mode 100644 index 0000000..e9db553 --- /dev/null +++ b/users/migrations/0041_auto_20200923_2030.py @@ -0,0 +1,25 @@ +# Generated by Django 2.2.12 on 2020-09-23 18:30 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0040_delete_clef'), + ] + + operations = [ + migrations.AlterField( + model_name='user', + name='address', + field=models.CharField(blank=True, default='', max_length=255, verbose_name='address'), + preserve_default=False, + ), + migrations.AlterField( + model_name='user', + name='telephone', + field=models.CharField(blank=True, default='', max_length=15, verbose_name='phone number'), + preserve_default=False, + ), + ] diff --git a/users/models.py b/users/models.py index 56fd01e..acea90d 100644 --- a/users/models.py +++ b/users/models.py @@ -13,13 +13,11 @@ class User(AbstractUser): telephone = models.CharField( verbose_name=_('phone number'), max_length=15, - null=True, blank=True, ) address = models.CharField( verbose_name=_('address'), max_length=255, - null=True, blank=True, ) maxemprunt = models.IntegerField( From 952a3ddddfe28e110be0d077f2547ae8c028759b Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Wed, 23 Sep 2020 20:32:23 +0200 Subject: [PATCH 05/11] Do not force install mysqlclient --- README.md | 1 + requirements.txt | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 475c1f3..c82653e 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ chmod go-rwx -R django-med python3 -m venv venv --system-site-packages . venv/bin/activate pip install -r requirements.txt +pip install mysqlclient~=1.4.0 # si base MySQL ./entrypoint.sh # lance en shell ``` diff --git a/requirements.txt b/requirements.txt index b07f6e7..097de08 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,4 +11,3 @@ djangorestframework~=3.9.0 pyyaml~=3.13 coreapi~=2.3.3 uwsgi~=2.0.18 -mysqlclient~=1.4.0 From 5e3003720f5d86eab9572272691296ac73fb304d Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Wed, 23 Sep 2020 20:33:49 +0200 Subject: [PATCH 06/11] Docutils is useless for testing --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7e28664..d0937fd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,7 +10,7 @@ py37-django22: apt-get update && apt-get install --no-install-recommends -t buster-backports -y python3-django python3-django-casclient python3-django-reversion python3-djangorestframework \ - python3-docutils python3-pil python3-tz python3-six python3-sqlparse python3-stdnum python3-yaml python3-coreapi + python3-pil python3-tz python3-six python3-sqlparse python3-stdnum python3-yaml python3-coreapi script: tox -e py37 py38-django22: @@ -23,7 +23,7 @@ py38-django22: apt-get update && apt-get install --no-install-recommends -y python3-django python3-django-casclient python3-django-reversion python3-djangorestframework \ - python3-docutils python3-pil python3-tz python3-six python3-sqlparse python3-stdnum python3-yaml python3-coreapi + python3-pil python3-tz python3-six python3-sqlparse python3-stdnum python3-yaml python3-coreapi script: tox -e py37 linters: From 8d76bd255ac9dabd23a9709dbfe8b43a1f840ac4 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Wed, 23 Sep 2020 20:38:26 +0200 Subject: [PATCH 07/11] Fix syntax of gitlabci --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d0937fd..9fc7fd8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,7 +9,7 @@ py37-django22: - > apt-get update && apt-get install --no-install-recommends -t buster-backports -y - python3-django python3-django-casclient python3-django-reversion python3-djangorestframework \ + python3-django python3-django-casclient python3-django-reversion python3-djangorestframework python3-pil python3-tz python3-six python3-sqlparse python3-stdnum python3-yaml python3-coreapi script: tox -e py37 @@ -22,7 +22,7 @@ py38-django22: - > apt-get update && apt-get install --no-install-recommends -y - python3-django python3-django-casclient python3-django-reversion python3-djangorestframework \ + python3-django python3-django-casclient python3-django-reversion python3-djangorestframework python3-pil python3-tz python3-six python3-sqlparse python3-stdnum python3-yaml python3-coreapi script: tox -e py37 From 73615afa77769545d145f365ed51d1eb2eff2010 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Wed, 23 Sep 2020 20:42:01 +0200 Subject: [PATCH 08/11] It's better with tox --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9fc7fd8..35ff27a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,7 +10,7 @@ py37-django22: apt-get update && apt-get install --no-install-recommends -t buster-backports -y python3-django python3-django-casclient python3-django-reversion python3-djangorestframework - python3-pil python3-tz python3-six python3-sqlparse python3-stdnum python3-yaml python3-coreapi + python3-pil python3-tz python3-six python3-sqlparse python3-stdnum python3-yaml python3-coreapi tox script: tox -e py37 py38-django22: @@ -23,7 +23,7 @@ py38-django22: apt-get update && apt-get install --no-install-recommends -y python3-django python3-django-casclient python3-django-reversion python3-djangorestframework - python3-pil python3-tz python3-six python3-sqlparse python3-stdnum python3-yaml python3-coreapi + python3-pil python3-tz python3-six python3-sqlparse python3-stdnum python3-yaml python3-coreapi tox script: tox -e py37 linters: From 35ecc2800f76e5b9f3d272e6796d329702c3f2e8 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Wed, 23 Sep 2020 20:47:24 +0200 Subject: [PATCH 09/11] Remove uwsgi from testing --- .gitlab-ci.yml | 4 ++-- README.md | 1 + requirements.txt | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 35ff27a..d3e7b4f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,7 +10,7 @@ py37-django22: apt-get update && apt-get install --no-install-recommends -t buster-backports -y python3-django python3-django-casclient python3-django-reversion python3-djangorestframework - python3-pil python3-tz python3-six python3-sqlparse python3-stdnum python3-yaml python3-coreapi tox + python3-docutils python3-pil python3-tz python3-six python3-sqlparse python3-stdnum python3-yaml python3-coreapi tox script: tox -e py37 py38-django22: @@ -23,7 +23,7 @@ py38-django22: apt-get update && apt-get install --no-install-recommends -y python3-django python3-django-casclient python3-django-reversion python3-djangorestframework - python3-pil python3-tz python3-six python3-sqlparse python3-stdnum python3-yaml python3-coreapi tox + python3-docutils python3-pil python3-tz python3-six python3-sqlparse python3-stdnum python3-yaml python3-coreapi tox script: tox -e py37 linters: diff --git a/README.md b/README.md index c82653e..3810be9 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ python3 -m venv venv --system-site-packages . venv/bin/activate pip install -r requirements.txt pip install mysqlclient~=1.4.0 # si base MySQL +pip install uwsgi~=2.0.18 # si production ./entrypoint.sh # lance en shell ``` diff --git a/requirements.txt b/requirements.txt index 097de08..8231dbc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,4 +10,3 @@ python-stdnum~=1.10 djangorestframework~=3.9.0 pyyaml~=3.13 coreapi~=2.3.3 -uwsgi~=2.0.18 From b2f0ee0b4490cfadea1d36afdce0e2346219e244 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Wed, 23 Sep 2020 20:51:42 +0200 Subject: [PATCH 10/11] Ubuntu is Python 3.8 --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d3e7b4f..c20e809 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,7 +24,7 @@ py38-django22: apt-get install --no-install-recommends -y python3-django python3-django-casclient python3-django-reversion python3-djangorestframework python3-docutils python3-pil python3-tz python3-six python3-sqlparse python3-stdnum python3-yaml python3-coreapi tox - script: tox -e py37 + script: tox -e py38 linters: stage: quality-assurance From dc4cb56dd04d334d9cfffed4c23aa082e6ad75e3 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Wed, 23 Sep 2020 20:56:57 +0200 Subject: [PATCH 11/11] More recent Pillow are fine --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 8231dbc..1ae0283 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ Django~=2.2.10 docutils~=0.14 -Pillow~=5.4.1 +Pillow>=5.4.1 pytz~=2019.1 six~=1.12.0 sqlparse~=0.2.4