1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-08-08 07:30:12 +02:00

Compare commits

...

32 Commits

Author SHA1 Message Date
Otthorn
3eed93e346 Remove unused file 2021-02-23 23:38:54 +01:00
Otthorn
4da523a1ba Merge branch 'faster_ci' of https://gitlab.crans.org/bde/nk20 into faster_ci 2021-02-23 23:38:26 +01:00
Otthorn
e74ff54468 please use the configuration I have written for hadolint 2021-02-23 22:23:16 +00:00
Otthorn
2e49c9ffbd Add CI docker linter for CI Dockerfiles 2021-02-23 22:23:16 +00:00
Otthorn
d20a1038a8 Add CI docker linter for nk20 Dockerfile 2021-02-23 22:23:16 +00:00
Otthorn
f6b711bb1b Add hadolint configuration file 2021-02-23 22:23:16 +00:00
Otthorn
893d87a9e1 Add ansible linting to the CI 2021-02-23 22:23:16 +00:00
Otthorn
9f3323c73e Add docker image for ansible lint to be used in CI 2021-02-23 22:23:16 +00:00
Otthorn
c57f81b920 Add skip list for ansible-lint 2021-02-23 22:23:16 +00:00
Otthorn
0636d84286 Add docker image for tox linting to be used in CI 2021-02-23 22:23:16 +00:00
Otthorn
ed06901fae fix typo (added image: twice) 2021-02-23 22:23:16 +00:00
Otthorn
28932f316b copy paste is a bad practice 2021-02-23 22:23:16 +00:00
Otthorn
9b50ba722c Add custom pre-built docker images to be used for the CI 2021-02-23 22:23:16 +00:00
Otthorn
3e3e61d23f Use prebuilt docker images in the CI 2021-02-23 22:23:16 +00:00
Otthorn
1129815ca3 please use the configuration I have written for hadolint 2021-02-23 23:22:51 +01:00
Otthorn
c13172d3ff Add CI docker linter for CI Dockerfiles 2021-02-23 23:14:35 +01:00
Otthorn
fcc4121225 Add CI docker linter for nk20 Dockerfile 2021-02-23 23:14:00 +01:00
Otthorn
a06f355559 Add hadolint configuration file 2021-02-23 23:10:30 +01:00
Otthorn
08df5fcccd Add ansible linting to the CI 2021-02-23 23:02:51 +01:00
Otthorn
b6c0f9758d Add docker image for ansible lint to be used in CI 2021-02-23 23:02:29 +01:00
Otthorn
a23093851f Add skip list for ansible-lint 2021-02-23 22:57:33 +01:00
d5a9bf175f Add script to force delete a user, in case of duplicates
Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
2021-02-22 11:54:23 +01:00
Otthorn
d803ab5ec2 Add docker image for tox linting to be used in CI 2021-02-22 00:17:49 +01:00
Otthorn
d7a537b6b5 fix typo (added image: twice) 2021-02-21 23:52:42 +01:00
Otthorn
0941ee954d copy paste is a bad practice 2021-02-21 23:46:20 +01:00
Otthorn
fd11d96d95 Add custom pre-built docker images to be used for the CI 2021-02-21 23:40:03 +01:00
Otthorn
4bfc057454 Use prebuilt docker images in the CI 2021-02-21 23:39:08 +01:00
b597a6ac5b Fix soge credit deletion when the account is not validated yet
Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
2021-02-21 23:05:27 +01:00
Rida LALI
a704b92c3d Prez BDE : ajout transaction random + see all buttons 2021-02-20 15:12:08 +01:00
53090b1a21 Fix JS texts
Signed-off-by: ynerant <ynerant@crans.org>
2021-02-14 11:52:37 +01:00
c49af0b83a Merge branch 'beta' into 'master'
Fix memberships

See merge request bde/nk20!147
2021-02-11 20:49:30 +00:00
5a05997d9d Fix date comparison when checking a membership from the parent club
Signed-off-by: ynerant <ynerant@crans.org>
2021-02-11 21:38:44 +01:00
16 changed files with 144 additions and 44 deletions

3
.ansible-lint Normal file
View File

@@ -0,0 +1,3 @@
skip_list:
- command-instead-of-shell # Use shell only when shell functionality is required
- experimental # all rules tagged as experimental

View File

@@ -10,50 +10,22 @@ variables:
# Debian Buster # Debian Buster
py37-django22: py37-django22:
stage: test stage: test
image: debian:buster-backports image: otthorn/nk20_ci_37
before_script:
- >
apt-get update &&
apt-get install --no-install-recommends -t buster-backports -y
python3-django python3-django-crispy-forms
python3-django-extensions python3-django-filters python3-django-polymorphic
python3-djangorestframework python3-django-oauth-toolkit python3-psycopg2 python3-pil
python3-babel python3-lockfile python3-pip python3-phonenumbers python3-memcache
python3-bs4 python3-setuptools tox texlive-xetex
script: tox -e py37-django22 script: tox -e py37-django22
# Ubuntu 20.04 # Ubuntu 20.04
py38-django22: py38-django22:
stage: test stage: test
image: ubuntu:20.04 image: otthorn/nk20_ci_38
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-crispy-forms
python3-django-extensions python3-django-filters python3-django-polymorphic
python3-djangorestframework python3-django-oauth-toolkit python3-psycopg2 python3-pil
python3-babel python3-lockfile python3-pip python3-phonenumbers python3-memcache
python3-bs4 python3-setuptools tox texlive-xetex
script: tox -e py38-django22 script: tox -e py38-django22
# Debian Bullseye # Debian Bullseye
py39-django22: py39-django22:
stage: test stage: test
image: debian:bullseye image: otthorn/nk20_ci_39
before_script:
- >
apt-get update &&
apt-get install --no-install-recommends -y
python3-django python3-django-crispy-forms
python3-django-extensions python3-django-filters python3-django-polymorphic
python3-djangorestframework python3-django-oauth-toolkit python3-psycopg2 python3-pil
python3-babel python3-lockfile python3-pip python3-phonenumbers python3-memcache
python3-bs4 python3-setuptools tox texlive-xetex
script: tox -e py39-django22 script: tox -e py39-django22
# Tox linter
linters: linters:
stage: quality-assurance stage: quality-assurance
image: debian:buster-backports image: debian:buster-backports
@@ -64,6 +36,20 @@ linters:
# Be nice to new contributors, but please use `tox` # Be nice to new contributors, but please use `tox`
allow_failure: true allow_failure: true
# Ansible linter
ansible-linter:
stage: quality-assurance
image: otthorn/nk20_ci_ansiblelint
script: ansible-lint ansible/
# Docker linter
docker-linter:
stage: quality-assurance
image: hadolint/hadolint
script:
- hadolint -c .hadolint Dockerfile
- hadolint -c .hadolint docker_ci/Dockerfile.*
# Compile documentation # Compile documentation
documentation: documentation:
stage: docs stage: docs

4
.hadolint Normal file
View File

@@ -0,0 +1,4 @@
ignored:
- DL3008 # Do not force to pin version in apt (Debian)
- DL3013 # Do not force to pin version in pip (PyPI)
- DL3018 # Do not force to pin version in apk (Alpine)

View File

@@ -658,8 +658,8 @@ class ClubAddMemberView(ProtectQuerysetMixin, ProtectedCreateView):
if club.name != "Kfet" and club.parent_club and not Membership.objects.filter( if club.name != "Kfet" and club.parent_club and not Membership.objects.filter(
user=form.instance.user, user=form.instance.user,
club=club.parent_club, club=club.parent_club,
date_start__gte=club.parent_club.membership_start, date_start__lte=timezone.now(),
date_end__lte=club.parent_club.membership_end, date_end__gte=club.parent_club.membership_end,
).exists(): ).exists():
form.add_error('user', _('User is not a member of the parent club') + ' ' + club.parent_club.name) form.add_error('user', _('User is not a member of the parent club') + ' ' + club.parent_club.name)
error = True error = True

View File

@@ -223,7 +223,8 @@ class Transaction(PolymorphicModel):
# Check that the amounts stay between big integer bounds # Check that the amounts stay between big integer bounds
diff_source, diff_dest = self.validate() diff_source, diff_dest = self.validate()
if not self.source.is_active or not self.destination.is_active: if not (hasattr(self, '_force_save') and self._force_save) \
and (not self.source.is_active or not self.destination.is_active):
raise ValidationError(_("The transaction can't be saved since the source note " raise ValidationError(_("The transaction can't be saved since the source note "
"or the destination note is not active.")) "or the destination note is not active."))
@@ -271,7 +272,7 @@ class RecurrentTransaction(Transaction):
) )
def clean(self): def clean(self):
if self.template.destination != self.destination: if self.template.destination != self.destination and not (hasattr(self, '_force_save') and self._force_save):
raise ValidationError( raise ValidationError(
_("The destination of this transaction must equal to the destination of the template.")) _("The destination of this transaction must equal to the destination of the template."))
return super().clean() return super().clean()

View File

@@ -43,4 +43,5 @@ def delete_transaction(instance, **_kwargs):
""" """
if not hasattr(instance, "_no_signal"): if not hasattr(instance, "_no_signal"):
instance.valid = False instance.valid = False
instance._force_save = True
instance.save() instance.save()

View File

@@ -223,13 +223,14 @@ function consume (source, source_alias, dest, quantity, amount, reason, type, ca
const newBalance = source.balance - quantity * amount const newBalance = source.balance - quantity * amount
if (newBalance <= -5000) { if (newBalance <= -5000) {
addMsg(interpolate(gettext('Warning, the transaction from the note %s succeed, ' + addMsg(interpolate(gettext('Warning, the transaction from the note %s succeed, ' +
'but the emitter note %s is very negative.', [source_alias, source_alias])), 'danger', 30000) 'but the emitter note %s is very negative.'), [source_alias, source_alias]), 'danger', 30000)
} else if (newBalance < 0) { } else if (newBalance < 0) {
addMsg(interpolate(gettext('Warning, the transaction from the note %s succeed, ' + addMsg(interpolate(gettext('Warning, the transaction from the note %s succeed, ' +
'but the emitter note %s is negative.', [source_alias, source_alias])), 'warning', 30000) 'but the emitter note %s is negative.'), [source_alias, source_alias]), 'warning', 30000)
} }
if (source.membership && source.membership.date_end < new Date().toISOString()) { if (source.membership && source.membership.date_end < new Date().toISOString()) {
addMsg(interpolate(gettext('Warning, the emitter note %s is no more a BDE member.', [source_alias])), 'danger', 30000) addMsg(interpolate(gettext('Warning, the emitter note %s is no more a BDE member.'), [source_alias]),
'danger', 30000)
} }
} }
reset() reset()

View File

@@ -3024,7 +3024,9 @@
24, 24,
25, 25,
26, 26,
27 27,
30,
33
] ]
} }
}, },

View File

@@ -381,9 +381,14 @@ class SogeCredit(models.Model):
tr.valid = True tr.valid = True
tr.created_at = timezone.now() tr.created_at = timezone.now()
tr.save() tr.save()
self.credit_transaction.valid = False if self.credit_transaction:
self.credit_transaction.reason += " (invalide)" # If the soge credit is deleted while the user is not validated yet,
self.credit_transaction.save() # there is not credit transaction.
# There is a credit transaction iff the user declares that no bank account
# was opened after the validation of the account.
self.credit_transaction.valid = False
self.credit_transaction.reason += " (invalide)"
self.credit_transaction.save()
super().delete(**kwargs) super().delete(**kwargs)
class Meta: class Meta:

18
docker_ci/Dockerfile.37 Normal file
View File

@@ -0,0 +1,18 @@
FROM debian:buster-backports
LABEL maintainer="otthorn@crans.org"
LABEL description="Debian Buster backports image with django and tox \
installed for testing purposes"
RUN apt-get update \
&& apt-get install --no-install-recommends -t buster-backports -y \
python3-django python3-django-crispy-forms \
python3-django-extensions python3-django-filters \
python3-django-polymorphic \
python3-djangorestframework python3-django-oauth-toolkit \
python3-psycopg2 python3-pil \
python3-babel python3-lockfile python3-pip python3-phonenumbers \
python3-memcache \
python3-bs4 python3-setuptools tox texlive-xetex \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

22
docker_ci/Dockerfile.38 Normal file
View File

@@ -0,0 +1,22 @@
FROM ubuntu:20.04
LABEL maintainer="otthorn@crans.org"
LABEL description="Ubuntu 20.04 image with django and tox \
installed for testing purposes"
# fix tzdata prompt
RUN ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime && echo Europe/Paris > /etc/timezone
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
python3-django python3-django-crispy-forms \
python3-django-extensions python3-django-filters \
python3-django-polymorphic \
python3-djangorestframework python3-django-oauth-toolkit \
python3-psycopg2 python3-pil \
python3-babel python3-lockfile python3-pip python3-phonenumbers \
python3-memcache \
python3-bs4 python3-setuptools tox texlive-xetex \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

18
docker_ci/Dockerfile.39 Normal file
View File

@@ -0,0 +1,18 @@
FROM debian:bullseye
LABEL maintainer="otthorn@crans.org"
LABEL description="Debian Bulleye image with django and tox \
installed for testing purposes"
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
python3-django python3-django-crispy-forms \
python3-django-extensions python3-django-filters \
python3-django-polymorphic \
python3-djangorestframework python3-django-oauth-toolkit \
python3-psycopg2 python3-pil \
python3-babel python3-lockfile python3-pip python3-phonenumbers \
python3-memcache \
python3-bs4 python3-setuptools tox texlive-xetex \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

View File

@@ -0,0 +1,10 @@
FROM python:3.9-alpine
LABEL maintainer="otthorn@crans.org"
LABEL description="Alpine image with ansible-lint and yamllint \
installed for linting purposes"
RUN apk add --no-cache gcc musl-dev python3-dev libffi-dev openssl-dev cargo
RUN pip install --no-cache-dir "yamllint>=1.26.0,<2.0"
RUN pip install --no-cache-dir "ansible-lint==5.0.0"
RUN pip install --no-cache-dir "ansible>=2.10,<2.11"

8
docker_ci/Dockerfile.tox Normal file
View File

@@ -0,0 +1,8 @@
FROM alpine:3.13
LABEL maintainer="otthorn@crans.org"
LABEL description="Alpine image with tox \
installed for linting purposes"
RUN apk --no-cache add py3-pip=20.3.4-r0
RUN pip install --no-cache-dir tox==3.22.0

21
docker_ci/README.md Normal file
View File

@@ -0,0 +1,21 @@
# Docker CI
Ce dossier contient les images docker à construire pour la CI. L'idée est
d'avoir une image pré-construire, au dessus laquel il y a besoin de faire
tourner uniquement les commandes qui nous intéresse. Cela permet notamment de
réduire drastiquement le temps que nécessite chaque test car seul la dernière
couche (layer) de l'image a besoin d'etre éxécuter.
## Build les images
Pour build les images il suffit de lancer les commandes suivantes
```
cd docker_ci/
docker build -t nk20_ci_37 -f Dockerfile.37 .
docker build -t nk20_ci_38 -f Dockerfile.38 .
docker build -t nk20_ci_39 -f Dockerfile.39 .
```
Elles sont acutellement build et disponible sur dockerhub
https://hub.docker.com/otthorn/nk20_ci_37