mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-12 21:09:24 +00:00
Compare commits
101 Commits
features/m
...
fix/licens
Author | SHA1 | Date | |
---|---|---|---|
6169d09ac0 | |||
f876bc3599 | |||
147b3619f5 | |||
d97602e60b | |||
a5cbac1f97 | |||
3143d3d91a | |||
9bdf3fc4ac | |||
e06bc7dba3 | |||
a8b9f38000 | |||
ca27b89a8b | |||
e1bf7caa9a | |||
e681c17a0f | |||
5416d88c97 | |||
ee437649f0 | |||
4303d51c0a | |||
d16bf12611 | |||
4231a7972d | |||
51a12814f9 | |||
00ae6e4623 | |||
4b587e8711 | |||
d2f377b54f | |||
193c820757 | |||
aaf30ab965 | |||
2db66e6154 | |||
38295e591d | |||
544b0248b2 | |||
2bccf633d5 | |||
84768eb74e | |||
8852ef990e | |||
87295ad9b7 | |||
5ab5ef681c | |||
c9e70889dd | |||
b30ee0a27a | |||
ef968f3673 | |||
96dede5077 | |||
66fcb76cb5 | |||
63c8e51137 | |||
12bec5c553 | |||
08460a6964 | |||
b5a40cfda9 | |||
c78953b036 | |||
427f7ceaff | |||
1055385bcc | |||
c1022642a2 | |||
06253f029c | |||
0501e6417a | |||
a198f5252d | |||
d83842af27 | |||
f605f7dcc6 | |||
8e7c025e47 | |||
1bfe929ab3 | |||
93cc2c883e | |||
44290a20a6 | |||
1f10a284f2 | |||
28f397574f | |||
6c1fa6de0b | |||
f0a08afd31 | |||
9e0b5b0b82 | |||
25c5a3297c | |||
5ea181829e | |||
0cf203669f | |||
559bfcac60 | |||
db8a1ed0ab | |||
16150905a0 | |||
9a376887ac | |||
773808fa59 | |||
c1e59a0676 | |||
05febc60bd | |||
a73fe598ef | |||
585923c827 | |||
394e17d599 | |||
59136850b8 | |||
d726f4b1e8 | |||
705b9b1e6a | |||
31e8ad8a3e | |||
99827e005b | |||
751c8a8bc6 | |||
37216cd16b | |||
dae68638cf | |||
7cadc0bc28 | |||
cce686f3a8 | |||
4fe46fbcef | |||
fe8b8f46aa | |||
7079761ffe | |||
f681c981c6 | |||
5d97146d14 | |||
7b56bd697d | |||
14cd268d69 | |||
754be1c9c9 | |||
da2c155254 | |||
ceb2888f82 | |||
26c94c9ec6 | |||
639197f4c8 | |||
faccc1367f | |||
22b83b0814 | |||
1d82e2a7d9 | |||
b8a72c57e1 | |||
9188565a86 | |||
4d7d22c337 | |||
b58116b023 | |||
fe9e5ce861 |
10
.github/actions/setup_project/action.yml
vendored
10
.github/actions/setup_project/action.yml
vendored
@ -6,13 +6,13 @@ runs:
|
||||
- name: Install apt packages
|
||||
uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
with:
|
||||
packages: gettext libxapian-dev libgraphviz-dev
|
||||
packages: gettext libgraphviz-dev
|
||||
version: 1.0 # increment to reset cache
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install gettext libxapian-dev libgraphviz-dev
|
||||
sudo apt install gettext libgraphviz-dev
|
||||
shell: bash
|
||||
|
||||
- name: Set up python
|
||||
@ -45,7 +45,11 @@ runs:
|
||||
${{ runner.os }}-poetry-
|
||||
|
||||
- name: Install dependencies
|
||||
run: poetry install -E testing -E docs
|
||||
run: poetry install --with docs,tests
|
||||
shell: bash
|
||||
|
||||
- name: Install xapian
|
||||
run: poetry run ./manage.py install_xapian
|
||||
shell: bash
|
||||
|
||||
- name: Compile gettext messages
|
||||
|
20
.github/workflows/ci.yml
vendored
20
.github/workflows/ci.yml
vendored
@ -8,27 +8,29 @@ on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
black:
|
||||
name: Black format
|
||||
ruff:
|
||||
name: Ruff lint & format
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Setup Project
|
||||
uses: ./.github/actions/setup_project
|
||||
- run: poetry run black --check .
|
||||
- uses: actions/checkout@v4
|
||||
- name: ruff format
|
||||
uses: chartboost/ruff-action@v1 # format
|
||||
with:
|
||||
args: format --diff
|
||||
- name: ruff check
|
||||
uses: chartboost/ruff-action@v1 # lint
|
||||
|
||||
tests:
|
||||
name: Run tests and generate coverage report
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- uses: ./.github/actions/setup_project
|
||||
- uses: ./.github/actions/setup_xapian
|
||||
- uses: ./.github/actions/compile_messages
|
||||
- name: Run tests
|
||||
run: poetry run coverage run ./manage.py test
|
||||
run: poetry run coverage run -m pytest
|
||||
- name: Generate coverage report
|
||||
run: |
|
||||
poetry run coverage report
|
||||
|
31
CONTRIBUTORS.md
Normal file
31
CONTRIBUTORS.md
Normal file
@ -0,0 +1,31 @@
|
||||
# Contributors
|
||||
|
||||
Thanks to everyone who has contributed to this project! We appreciate your time and effort.
|
||||
|
||||
## Copyright
|
||||
|
||||
> All contributions to this project are subject to the copyright owned by the Association des Étudiants de l'Université de Technologie de Belfort-Montbéliard (AE UTBM), for both past and future years. By making a contribution to this project, you acknowledge and agree that AE UTBM has the exclusive right to use, distribute, and modify your contribution, as well as to license others to do the same, in any way they see fit.
|
||||
|
||||
## License
|
||||
|
||||
This project was previously released under the MIT license, but it has since been changed to the GPL v3 license. Any contributions made to this project before the switch to GPL v3 are still subject to the MIT license, while contributions made after the switch are subject to the GPL v3 license.
|
||||
|
||||
## List of Contributors
|
||||
|
||||
- [@Hyask](https://github.com/Hyask) — Florent "Skia" Jacquet <skia@hya.sk>
|
||||
- [@klmp200](https://github.com/klmp200) — Antoine "Sli" Bartuccio <antoine@bartuccio.fr>
|
||||
- [@nab-os](https://github.com/nab-os) (AKA Gnikwo) — Sasha "Nabos" Ballet <nabos@glargh.fr>
|
||||
- [@Krophil](https://github.com/Krophil) — Pierre "Krophil'" Brunet <pierre.brunet@krophil.fr>
|
||||
- [@guillaume-renaud](https://github.com/guillaume-renaud) — Guillaume "Lo-J" RENAUD <renaudg779@gmail.com>
|
||||
- [@imperosol](https://github.com/imperosol) — Thomas "Maréchal" Girod <thgirod@hotmail.com>
|
||||
- [@TheoDurr](https://github.com/TheoDurr) — Théo "Ailé" Durr <git@theodurr.fr>
|
||||
- [@RTrioux](https://github.com/RTrioux) — Robin "Vial" Trioux
|
||||
- [@TheRolfFR](https://github.com/TheRolfFR) — Yann "Réseau" Le Vaguerès
|
||||
- [@Magador](https://github.com/Magador) — Lucie "Magador" Lenglet
|
||||
- [@lsacienne](https://github.com/lsacienne) — Alexandre "L'Sacienne" Viala
|
||||
- [@Juknum](https://github.com/Juknum) — Julien "Tinople" Constant
|
||||
- [@Tartofraise](https://github.com/Tartofraise) — Ryan "Soldat" Hadj-Mebarek
|
||||
- [@FrancescoWitz](https://github.com/FrancescoWitz) — Francesco "Och" WITZ
|
||||
- [@maxence-leblanc](https://github.com/maxence-leblanc) — Maxence "Juste" LEBLANC
|
||||
|
||||
_If you've contributed to this project and your name isn't on the list, please let us know so we can add you. And if you've contributed anonymously, thank you! We appreciate your contributions just as much as those from named contributors._
|
21
LICENSE.old
Normal file
21
LICENSE.old
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Skia
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
@ -1,15 +1,19 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
@ -1,24 +1,27 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
from django.contrib import admin
|
||||
|
||||
from accounting.models import *
|
||||
|
||||
|
||||
admin.site.register(BankAccount)
|
||||
admin.site.register(ClubAccount)
|
||||
admin.site.register(GeneralJournal)
|
||||
|
@ -1,10 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.core.validators
|
||||
import accounting.models
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
import accounting.models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,8 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,8 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import phonenumber_field.modelfields
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,8 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,32 +1,36 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
from django.urls import reverse
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core import validators
|
||||
from django.db import models
|
||||
from django.conf import settings
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.template import defaultfilters
|
||||
from decimal import Decimal
|
||||
|
||||
from django.conf import settings
|
||||
from django.core import validators
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db import models
|
||||
from django.template import defaultfilters
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from phonenumber_field.modelfields import PhoneNumberField
|
||||
|
||||
from decimal import Decimal
|
||||
from core.models import User, SithFile
|
||||
from club.models import Club
|
||||
from core.models import SithFile, User
|
||||
|
||||
|
||||
class CurrencyField(models.DecimalField):
|
||||
|
@ -1,100 +1,99 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
from datetime import date, timedelta
|
||||
|
||||
from django.test import TestCase
|
||||
from django.urls import reverse
|
||||
from django.core.management import call_command
|
||||
from datetime import date, timedelta
|
||||
|
||||
from core.models import User
|
||||
from accounting.models import (
|
||||
GeneralJournal,
|
||||
Operation,
|
||||
Label,
|
||||
AccountingType,
|
||||
GeneralJournal,
|
||||
Label,
|
||||
Operation,
|
||||
SimplifiedAccountingType,
|
||||
)
|
||||
from core.models import User
|
||||
|
||||
|
||||
class RefoundAccountTest(TestCase):
|
||||
def setUp(self):
|
||||
self.skia = User.objects.filter(username="skia").first()
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
cls.skia = User.objects.get(username="skia")
|
||||
# reffil skia's account
|
||||
self.skia.customer.amount = 800
|
||||
self.skia.customer.save()
|
||||
cls.skia.customer.amount = 800
|
||||
cls.skia.customer.save()
|
||||
cls.refound_account_url = reverse("accounting:refound_account")
|
||||
|
||||
def test_permission_denied(self):
|
||||
self.client.login(username="guy", password="plop")
|
||||
self.client.force_login(User.objects.get(username="guy"))
|
||||
response_post = self.client.post(
|
||||
reverse("accounting:refound_account"), {"user": self.skia.id}
|
||||
self.refound_account_url, {"user": self.skia.id}
|
||||
)
|
||||
response_get = self.client.get(reverse("accounting:refound_account"))
|
||||
self.assertTrue(response_get.status_code == 403)
|
||||
self.assertTrue(response_post.status_code == 403)
|
||||
response_get = self.client.get(self.refound_account_url)
|
||||
assert response_get.status_code == 403
|
||||
assert response_post.status_code == 403
|
||||
|
||||
def test_root_granteed(self):
|
||||
self.client.login(username="root", password="plop")
|
||||
response_post = self.client.post(
|
||||
reverse("accounting:refound_account"), {"user": self.skia.id}
|
||||
)
|
||||
self.skia = User.objects.filter(username="skia").first()
|
||||
response_get = self.client.get(reverse("accounting:refound_account"))
|
||||
self.assertFalse(response_get.status_code == 403)
|
||||
self.assertTrue('<form action="" method="post">' in str(response_get.content))
|
||||
self.assertFalse(response_post.status_code == 403)
|
||||
self.assertTrue(self.skia.customer.amount == 0)
|
||||
self.client.force_login(User.objects.get(username="root"))
|
||||
response = self.client.post(self.refound_account_url, {"user": self.skia.id})
|
||||
self.assertRedirects(response, self.refound_account_url)
|
||||
self.skia.refresh_from_db()
|
||||
response = self.client.get(self.refound_account_url)
|
||||
assert response.status_code == 200
|
||||
assert '<form action="" method="post">' in str(response.content)
|
||||
assert self.skia.customer.amount == 0
|
||||
|
||||
def test_comptable_granteed(self):
|
||||
self.client.login(username="comptable", password="plop")
|
||||
response_post = self.client.post(
|
||||
reverse("accounting:refound_account"), {"user": self.skia.id}
|
||||
)
|
||||
self.skia = User.objects.filter(username="skia").first()
|
||||
response_get = self.client.get(reverse("accounting:refound_account"))
|
||||
self.assertFalse(response_get.status_code == 403)
|
||||
self.assertTrue('<form action="" method="post">' in str(response_get.content))
|
||||
self.assertFalse(response_post.status_code == 403)
|
||||
self.assertTrue(self.skia.customer.amount == 0)
|
||||
self.client.force_login(User.objects.get(username="comptable"))
|
||||
response = self.client.post(self.refound_account_url, {"user": self.skia.id})
|
||||
self.assertRedirects(response, self.refound_account_url)
|
||||
self.skia.refresh_from_db()
|
||||
response = self.client.get(self.refound_account_url)
|
||||
assert response.status_code == 200
|
||||
assert '<form action="" method="post">' in str(response.content)
|
||||
assert self.skia.customer.amount == 0
|
||||
|
||||
|
||||
class JournalTest(TestCase):
|
||||
def setUp(self):
|
||||
self.journal = GeneralJournal.objects.filter(id=1).first()
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
cls.journal = GeneralJournal.objects.get(id=1)
|
||||
|
||||
def test_permission_granted(self):
|
||||
self.client.login(username="comptable", password="plop")
|
||||
self.client.force_login(User.objects.get(username="comptable"))
|
||||
response_get = self.client.get(
|
||||
reverse("accounting:journal_details", args=[self.journal.id])
|
||||
)
|
||||
|
||||
self.assertTrue(response_get.status_code == 200)
|
||||
self.assertTrue(
|
||||
"<td>M\\xc3\\xa9thode de paiement</td>" in str(response_get.content)
|
||||
)
|
||||
assert response_get.status_code == 200
|
||||
assert "<td>M\\xc3\\xa9thode de paiement</td>" in str(response_get.content)
|
||||
|
||||
def test_permission_not_granted(self):
|
||||
self.client.login(username="skia", password="plop")
|
||||
self.client.force_login(User.objects.get(username="skia"))
|
||||
response_get = self.client.get(
|
||||
reverse("accounting:journal_details", args=[self.journal.id])
|
||||
)
|
||||
|
||||
self.assertTrue(response_get.status_code == 403)
|
||||
self.assertFalse(
|
||||
"<td>M\xc3\xa9thode de paiement</td>" in str(response_get.content)
|
||||
)
|
||||
assert response_get.status_code == 403
|
||||
assert "<td>M\xc3\xa9thode de paiement</td>" not in str(response_get.content)
|
||||
|
||||
|
||||
class OperationTest(TestCase):
|
||||
@ -108,9 +107,8 @@ class OperationTest(TestCase):
|
||||
code="443", label="Ce code n'existe pas", movement_type="CREDIT"
|
||||
)
|
||||
at.save()
|
||||
l = Label(club_account=self.journal.club_account, name="bob")
|
||||
l.save()
|
||||
self.client.login(username="comptable", password="plop")
|
||||
l = Label.objects.create(club_account=self.journal.club_account, name="bob")
|
||||
self.client.force_login(User.objects.get(username="comptable"))
|
||||
self.op1 = Operation(
|
||||
journal=self.journal,
|
||||
date=date.today(),
|
||||
@ -139,8 +137,7 @@ class OperationTest(TestCase):
|
||||
self.op2.save()
|
||||
|
||||
def test_new_operation(self):
|
||||
self.client.login(username="comptable", password="plop")
|
||||
at = AccountingType.objects.filter(code="604").first()
|
||||
at = AccountingType.objects.get(code="604")
|
||||
response = self.client.post(
|
||||
reverse("accounting:op_new", args=[self.journal.id]),
|
||||
{
|
||||
@ -172,8 +169,7 @@ class OperationTest(TestCase):
|
||||
self.assertTrue("<td>Le fantome de la nuit</td>" in str(response_get.content))
|
||||
|
||||
def test_bad_new_operation(self):
|
||||
self.client.login(username="comptable", password="plop")
|
||||
AccountingType.objects.filter(code="604").first()
|
||||
AccountingType.objects.get(code="604")
|
||||
response = self.client.post(
|
||||
reverse("accounting:op_new", args=[self.journal.id]),
|
||||
{
|
||||
@ -199,7 +195,7 @@ class OperationTest(TestCase):
|
||||
)
|
||||
|
||||
def test_new_operation_not_authorized(self):
|
||||
self.client.login(username="skia", password="plop")
|
||||
self.client.force_login(self.skia)
|
||||
at = AccountingType.objects.filter(code="604").first()
|
||||
response = self.client.post(
|
||||
reverse("accounting:op_new", args=[self.journal.id]),
|
||||
@ -226,7 +222,6 @@ class OperationTest(TestCase):
|
||||
)
|
||||
|
||||
def test__operation_simple_accounting(self):
|
||||
self.client.login(username="comptable", password="plop")
|
||||
sat = SimplifiedAccountingType.objects.all().first()
|
||||
response = self.client.post(
|
||||
reverse("accounting:op_new", args=[self.journal.id]),
|
||||
@ -263,14 +258,12 @@ class OperationTest(TestCase):
|
||||
)
|
||||
|
||||
def test_nature_statement(self):
|
||||
self.client.login(username="comptable", password="plop")
|
||||
response = self.client.get(
|
||||
reverse("accounting:journal_nature_statement", args=[self.journal.id])
|
||||
)
|
||||
self.assertContains(response, "bob (Troll Penché) : 3.00", status_code=200)
|
||||
|
||||
def test_person_statement(self):
|
||||
self.client.login(username="comptable", password="plop")
|
||||
response = self.client.get(
|
||||
reverse("accounting:journal_person_statement", args=[self.journal.id])
|
||||
)
|
||||
@ -292,7 +285,6 @@ class OperationTest(TestCase):
|
||||
)
|
||||
|
||||
def test_accounting_statement(self):
|
||||
self.client.login(username="comptable", password="plop")
|
||||
response = self.client.get(
|
||||
reverse("accounting:journal_accounting_statement", args=[self.journal.id])
|
||||
)
|
||||
|
@ -1,17 +1,21 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
from django.urls import path
|
||||
|
@ -1,54 +1,58 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
from django.views.generic import ListView, DetailView
|
||||
from django.views.generic.edit import UpdateView, CreateView, DeleteView, FormView
|
||||
from django.urls import reverse_lazy, reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.forms.models import modelform_factory
|
||||
from django.core.exceptions import PermissionDenied, ValidationError
|
||||
from django.forms import HiddenInput
|
||||
from django.db import transaction
|
||||
from django.db.models import Sum
|
||||
from django.conf import settings
|
||||
from django import forms
|
||||
from django.http import HttpResponse
|
||||
import collections
|
||||
|
||||
from ajax_select.fields import AutoCompleteSelectField
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import PermissionDenied, ValidationError
|
||||
from django.db import transaction
|
||||
from django.db.models import Sum
|
||||
from django.forms import HiddenInput
|
||||
from django.forms.models import modelform_factory
|
||||
from django.http import HttpResponse
|
||||
from django.urls import reverse, reverse_lazy
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.generic import DetailView, ListView
|
||||
from django.views.generic.edit import CreateView, DeleteView, FormView, UpdateView
|
||||
|
||||
from core.views import (
|
||||
CanViewMixin,
|
||||
CanEditMixin,
|
||||
CanEditPropMixin,
|
||||
CanCreateMixin,
|
||||
TabedViewMixin,
|
||||
)
|
||||
from core.views.forms import SelectFile, SelectDate
|
||||
from accounting.models import (
|
||||
AccountingType,
|
||||
BankAccount,
|
||||
ClubAccount,
|
||||
GeneralJournal,
|
||||
Operation,
|
||||
AccountingType,
|
||||
Company,
|
||||
SimplifiedAccountingType,
|
||||
GeneralJournal,
|
||||
Label,
|
||||
Operation,
|
||||
SimplifiedAccountingType,
|
||||
)
|
||||
from counter.models import Counter, Selling, Product
|
||||
from core.views import (
|
||||
CanCreateMixin,
|
||||
CanEditMixin,
|
||||
CanEditPropMixin,
|
||||
CanViewMixin,
|
||||
TabedViewMixin,
|
||||
)
|
||||
from core.views.forms import SelectDate, SelectFile
|
||||
from counter.models import Counter, Product, Selling
|
||||
|
||||
# Main accounting view
|
||||
|
||||
@ -521,14 +525,14 @@ class OperationPDFView(CanViewMixin, DetailView):
|
||||
pk_url_kwarg = "op_id"
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
from reportlab.pdfgen import canvas
|
||||
from reportlab.lib.units import cm
|
||||
from reportlab.platypus import Table, TableStyle
|
||||
from reportlab.lib import colors
|
||||
from reportlab.lib.pagesizes import letter
|
||||
from reportlab.lib.units import cm
|
||||
from reportlab.lib.utils import ImageReader
|
||||
from reportlab.pdfbase.ttfonts import TTFont
|
||||
from reportlab.pdfbase import pdfmetrics
|
||||
from reportlab.pdfbase.ttfonts import TTFont
|
||||
from reportlab.pdfgen import canvas
|
||||
from reportlab.platypus import Table, TableStyle
|
||||
|
||||
pdfmetrics.registerFont(TTFont("DejaVu", "DejaVuSerif.ttf"))
|
||||
|
||||
@ -599,7 +603,7 @@ class OperationPDFView(CanViewMixin, DetailView):
|
||||
payment_mode = ""
|
||||
for m in settings.SITH_ACCOUNTING_PAYMENT_METHOD:
|
||||
if m[0] == mode:
|
||||
payment_mode += "[\u00D7]"
|
||||
payment_mode += "[\u00d7]"
|
||||
else:
|
||||
payment_mode += "[ ]"
|
||||
payment_mode += " %s\n" % (m[1])
|
||||
|
@ -1,15 +1,19 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
10
api/admin.py
10
api/admin.py
@ -1,19 +1,21 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
|
@ -1,19 +1,21 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
|
10
api/tests.py
10
api/tests.py
@ -1,19 +1,21 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
|
12
api/urls.py
12
api/urls.py
@ -1,23 +1,27 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
from django.urls import re_path, path, include
|
||||
from django.urls import include, path, re_path
|
||||
from rest_framework import routers
|
||||
|
||||
from api.views import *
|
||||
from rest_framework import routers
|
||||
|
||||
# Router config
|
||||
router = routers.DefaultRouter()
|
||||
|
@ -1,26 +1,30 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
from rest_framework.response import Response
|
||||
from rest_framework import viewsets
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from rest_framework.decorators import action
|
||||
from django.db.models.query import QuerySet
|
||||
from rest_framework import viewsets
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework.response import Response
|
||||
|
||||
from core.views import can_view, can_edit
|
||||
from core.views import can_edit, can_view
|
||||
|
||||
|
||||
def check_if(obj, user, test):
|
||||
@ -64,10 +68,10 @@ class RightModelViewSet(ManageModelMixin, viewsets.ModelViewSet):
|
||||
|
||||
|
||||
from .api import *
|
||||
from .counter import *
|
||||
from .user import *
|
||||
from .club import *
|
||||
from .counter import *
|
||||
from .group import *
|
||||
from .launderette import *
|
||||
from .uv import *
|
||||
from .sas import *
|
||||
from .user import *
|
||||
from .uv import *
|
||||
|
@ -1,22 +1,26 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.decorators import api_view, renderer_classes
|
||||
from rest_framework.renderers import StaticHTMLRenderer
|
||||
from rest_framework.response import Response
|
||||
|
||||
from core.templatetags.renderer import markdown
|
||||
|
||||
|
@ -1,30 +1,32 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
from rest_framework.response import Response
|
||||
from rest_framework import serializers
|
||||
from rest_framework.decorators import api_view, renderer_classes
|
||||
from rest_framework.renderers import StaticHTMLRenderer
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import PermissionDenied
|
||||
|
||||
from club.models import Club, Mailing
|
||||
from rest_framework import serializers
|
||||
from rest_framework.decorators import api_view, renderer_classes
|
||||
from rest_framework.renderers import StaticHTMLRenderer
|
||||
from rest_framework.response import Response
|
||||
|
||||
from api.views import RightModelViewSet
|
||||
from club.models import Club, Mailing
|
||||
|
||||
|
||||
class ClubSerializer(serializers.ModelSerializer):
|
||||
|
@ -1,26 +1,29 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
from rest_framework import serializers
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.decorators import action
|
||||
|
||||
from counter.models import Counter
|
||||
from rest_framework.response import Response
|
||||
|
||||
from api.views import RightModelViewSet
|
||||
from counter.models import Counter
|
||||
|
||||
|
||||
class CounterSerializer(serializers.ModelSerializer):
|
||||
|
@ -1,24 +1,27 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
from rest_framework import serializers
|
||||
|
||||
from core.models import RealGroup
|
||||
|
||||
from api.views import RightModelViewSet
|
||||
from core.models import RealGroup
|
||||
|
||||
|
||||
class GroupSerializer(serializers.ModelSerializer):
|
||||
|
@ -1,26 +1,29 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
from rest_framework import serializers
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.decorators import action
|
||||
|
||||
from launderette.models import Launderette, Machine, Token
|
||||
from rest_framework.response import Response
|
||||
|
||||
from api.views import RightModelViewSet
|
||||
from launderette.models import Launderette, Machine, Token
|
||||
|
||||
|
||||
class LaunderettePlaceSerializer(serializers.ModelSerializer):
|
||||
|
@ -1,4 +1,5 @@
|
||||
from typing import List
|
||||
|
||||
from rest_framework.decorators import api_view, renderer_classes
|
||||
from rest_framework.exceptions import PermissionDenied
|
||||
from rest_framework.generics import get_object_or_404
|
||||
@ -6,8 +7,8 @@ from rest_framework.renderers import JSONRenderer
|
||||
from rest_framework.request import Request
|
||||
from rest_framework.response import Response
|
||||
|
||||
from core.views import can_edit
|
||||
from core.models import User
|
||||
from core.views import can_edit
|
||||
from sas.models import Picture
|
||||
|
||||
|
||||
|
@ -1,28 +1,31 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
import datetime
|
||||
|
||||
from rest_framework import serializers
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.decorators import action
|
||||
|
||||
from core.models import User
|
||||
from rest_framework.response import Response
|
||||
|
||||
from api.views import RightModelViewSet
|
||||
from core.models import User
|
||||
|
||||
|
||||
class UserSerializer(serializers.ModelSerializer):
|
||||
|
@ -1,11 +1,12 @@
|
||||
from rest_framework.response import Response
|
||||
import json
|
||||
import urllib.request
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from rest_framework import serializers
|
||||
from rest_framework.decorators import api_view, renderer_classes
|
||||
from rest_framework.renderers import JSONRenderer
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.conf import settings
|
||||
from rest_framework import serializers
|
||||
import urllib.request
|
||||
import json
|
||||
from rest_framework.response import Response
|
||||
|
||||
from pedagogy.views import CanCreateUVFunctionMixin
|
||||
|
||||
|
@ -1,15 +1,19 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
@ -1,17 +1,21 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
from ajax_select import make_ajax_form
|
||||
from django.contrib import admin
|
||||
|
@ -1,40 +1,32 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2016,2017
|
||||
# - Skia <skia@libskia.so>
|
||||
# - Sli <antoine@bartuccio.fr>
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||
# http://ae.utbm.fr.
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License a published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
from django.conf import settings
|
||||
from ajax_select.fields import AutoCompleteSelectMultipleField
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from ajax_select.fields import AutoCompleteSelectField, AutoCompleteSelectMultipleField
|
||||
|
||||
from club.models import Mailing, MailingSubscription, Club, Membership
|
||||
|
||||
from club.models import Club, Mailing, MailingSubscription, Membership
|
||||
from core.models import User
|
||||
from core.views.forms import SelectDate, SelectDateTime
|
||||
from core.views.forms import SelectDate, TzAwareDateTimeField
|
||||
from counter.models import Counter
|
||||
from core.views.forms import TzAwareDateTimeField
|
||||
|
||||
|
||||
class ClubEditForm(forms.ModelForm):
|
||||
|
@ -1,9 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.core.validators
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,9 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.conf import settings
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,9 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.conf import settings
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,8 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,8 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.utils.timezone
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,11 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.conf import settings
|
||||
import re
|
||||
|
||||
import django.core.validators
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,11 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
from club.models import Club
|
||||
from core.operations import PsqlRunOnly
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
def generate_club_pages(apps, schema_editor):
|
||||
|
@ -1,9 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import club.models
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
import club.models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,44 +1,37 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2016,2017
|
||||
# - Skia <skia@libskia.so>
|
||||
# - Sli <antoine@bartuccio.fr>
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||
# http://ae.utbm.fr.
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License a published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
from typing import Optional
|
||||
|
||||
from django.core.cache import cache
|
||||
from django.db import models
|
||||
from django.core import validators
|
||||
from django.conf import settings
|
||||
from django.core import validators
|
||||
from django.core.cache import cache
|
||||
from django.core.exceptions import ObjectDoesNotExist, ValidationError
|
||||
from django.core.validators import RegexValidator, validate_email
|
||||
from django.db import models, transaction
|
||||
from django.db.models import Q
|
||||
from django.utils.timezone import now
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.core.exceptions import ValidationError, ObjectDoesNotExist
|
||||
from django.db import transaction
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from django.core.validators import RegexValidator, validate_email
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from core.models import User, MetaGroup, Group, SithFile, RealGroup, Notification, Page
|
||||
from core.models import Group, MetaGroup, Notification, Page, RealGroup, SithFile, User
|
||||
|
||||
# Create your models here.
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
{% from 'core/macros.jinja' import user_profile_link, paginate %}
|
||||
|
||||
{% block content %}
|
||||
<h3>{% trans %}Sellings{% endtrans %}</h3>
|
||||
<h3>{% trans %}Sales{% endtrans %}</h3>
|
||||
<form id="form" action="?page=1" method="post">
|
||||
{% csrf_token %}
|
||||
{{ form }}
|
||||
|
@ -30,7 +30,7 @@
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% if object.club_account.exists() %}
|
||||
<h4>{% trans %}Accouting: {% endtrans %}</h4>
|
||||
<h4>{% trans %}Accounting: {% endtrans %}</h4>
|
||||
<ul>
|
||||
{% for ca in object.club_account.all() %}
|
||||
<li><a href="{{ url('accounting:club_details', c_account_id=ca.id) }}">{{ ca.get_display_name() }}</a></li>
|
||||
|
471
club/tests.py
471
club/tests.py
@ -1,32 +1,35 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
from datetime import timedelta
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.cache import cache
|
||||
from django.test import TestCase
|
||||
from django.utils import timezone, html
|
||||
from django.utils.timezone import now, localtime
|
||||
from django.utils.translation import gettext as _
|
||||
from django.urls import reverse
|
||||
from django.core.management import call_command
|
||||
from django.utils import timezone
|
||||
from django.utils.timezone import localtime, now
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from core.models import User, AnonymousUser
|
||||
from club.models import Club, Membership, Mailing
|
||||
from club.forms import MailingForm
|
||||
from club.models import Club, Mailing, Membership
|
||||
from core.models import AnonymousUser, User
|
||||
from sith.settings import SITH_BAR_MANAGER, SITH_MAIN_CLUB_ID
|
||||
|
||||
|
||||
@ -50,6 +53,7 @@ class ClubTest(TestCase):
|
||||
cls.richard = User.objects.get(username="rbatsbak")
|
||||
cls.comptable = User.objects.get(username="comptable")
|
||||
cls.sli = User.objects.get(username="sli")
|
||||
cls.root = User.objects.get(username="root")
|
||||
|
||||
# subscribed users - not initial members
|
||||
cls.krophil = User.objects.get(username="krophil")
|
||||
@ -103,45 +107,42 @@ class MembershipQuerySetTest(ClubTest):
|
||||
Test that the ongoing queryset method returns the memberships that
|
||||
are not ended.
|
||||
"""
|
||||
current_members = self.club.members.ongoing()
|
||||
current_members = list(self.club.members.ongoing().order_by("id"))
|
||||
expected = [
|
||||
self.skia.memberships.get(club=self.club),
|
||||
self.comptable.memberships.get(club=self.club),
|
||||
self.richard.memberships.get(club=self.club),
|
||||
]
|
||||
self.assertEqual(len(current_members), len(expected))
|
||||
for member in current_members:
|
||||
self.assertIn(member, expected)
|
||||
expected.sort(key=lambda i: i.id)
|
||||
assert current_members == expected
|
||||
|
||||
def test_board(self):
|
||||
"""
|
||||
Test that the board queryset method returns the memberships
|
||||
of user in the club board
|
||||
"""
|
||||
board_members = list(self.club.members.board())
|
||||
board_members = list(self.club.members.board().order_by("id"))
|
||||
expected = [
|
||||
self.skia.memberships.get(club=self.club),
|
||||
self.comptable.memberships.get(club=self.club),
|
||||
# sli is no more member, but he was in the board
|
||||
self.sli.memberships.get(club=self.club),
|
||||
]
|
||||
self.assertEqual(len(board_members), len(expected))
|
||||
for member in board_members:
|
||||
self.assertIn(member, expected)
|
||||
expected.sort(key=lambda i: i.id)
|
||||
assert board_members == expected
|
||||
|
||||
def test_ongoing_board(self):
|
||||
"""
|
||||
Test that combining ongoing and board returns users
|
||||
who are currently board members of the club
|
||||
"""
|
||||
members = list(self.club.members.ongoing().board())
|
||||
members = list(self.club.members.ongoing().board().order_by("id"))
|
||||
expected = [
|
||||
self.skia.memberships.get(club=self.club),
|
||||
self.comptable.memberships.get(club=self.club),
|
||||
]
|
||||
self.assertEqual(len(members), len(expected))
|
||||
for member in members:
|
||||
self.assertIn(member, expected)
|
||||
expected.sort(key=lambda i: i.id)
|
||||
assert members == expected
|
||||
|
||||
def test_update_invalidate_cache(self):
|
||||
"""
|
||||
@ -150,8 +151,9 @@ class MembershipQuerySetTest(ClubTest):
|
||||
mem_skia = self.skia.memberships.get(club=self.club)
|
||||
cache.set(f"membership_{mem_skia.club_id}_{mem_skia.user_id}", mem_skia)
|
||||
self.skia.memberships.update(end_date=localtime(now()).date())
|
||||
self.assertEqual(
|
||||
cache.get(f"membership_{mem_skia.club_id}_{mem_skia.user_id}"), "not_member"
|
||||
assert (
|
||||
cache.get(f"membership_{mem_skia.club_id}_{mem_skia.user_id}")
|
||||
== "not_member"
|
||||
)
|
||||
|
||||
mem_richard = self.richard.memberships.get(club=self.club)
|
||||
@ -160,8 +162,8 @@ class MembershipQuerySetTest(ClubTest):
|
||||
)
|
||||
self.richard.memberships.update(role=5)
|
||||
new_mem = self.richard.memberships.get(club=self.club)
|
||||
self.assertNotEqual(new_mem, "not_member")
|
||||
self.assertEqual(new_mem.role, 5)
|
||||
assert new_mem != "not_member"
|
||||
assert new_mem.role == 5
|
||||
|
||||
def test_delete_invalidate_cache(self):
|
||||
"""
|
||||
@ -178,40 +180,39 @@ class MembershipQuerySetTest(ClubTest):
|
||||
# should delete the subscriptions of skia and comptable
|
||||
self.club.members.ongoing().board().delete()
|
||||
|
||||
self.assertEqual(
|
||||
cache.get(f"membership_{mem_skia.club_id}_{mem_skia.user_id}"), "not_member"
|
||||
assert (
|
||||
cache.get(f"membership_{mem_skia.club_id}_{mem_skia.user_id}")
|
||||
== "not_member"
|
||||
)
|
||||
self.assertEqual(
|
||||
cache.get(f"membership_{mem_comptable.club_id}_{mem_comptable.user_id}"),
|
||||
"not_member",
|
||||
assert (
|
||||
cache.get(f"membership_{mem_comptable.club_id}_{mem_comptable.user_id}")
|
||||
== "not_member",
|
||||
)
|
||||
|
||||
|
||||
class ClubModelTest(ClubTest):
|
||||
def assert_membership_just_started(self, user: User, role: int):
|
||||
def assert_membership_started_today(self, user: User, role: int):
|
||||
"""
|
||||
Assert that the given membership is active and started today
|
||||
"""
|
||||
membership = user.memberships.ongoing().filter(club=self.club).first()
|
||||
self.assertIsNotNone(membership)
|
||||
self.assertEqual(localtime(now()).date(), membership.start_date)
|
||||
self.assertIsNone(membership.end_date)
|
||||
self.assertEqual(membership.role, role)
|
||||
self.assertEqual(membership.club.get_membership_for(user), membership)
|
||||
assert membership is not None
|
||||
assert localtime(now()).date() == membership.start_date
|
||||
assert membership.end_date is None
|
||||
assert membership.role == role
|
||||
assert membership.club.get_membership_for(user) == membership
|
||||
member_group = self.club.unix_name + settings.SITH_MEMBER_SUFFIX
|
||||
board_group = self.club.unix_name + settings.SITH_BOARD_SUFFIX
|
||||
self.assertTrue(user.is_in_group(name=member_group))
|
||||
self.assertTrue(user.is_in_group(name=board_group))
|
||||
assert user.is_in_group(name=member_group)
|
||||
assert user.is_in_group(name=board_group)
|
||||
|
||||
def assert_membership_just_ended(self, user: User):
|
||||
def assert_membership_ended_today(self, user: User):
|
||||
"""
|
||||
Assert that the given user have a membership which ended today
|
||||
"""
|
||||
today = localtime(now()).date()
|
||||
self.assertIsNotNone(
|
||||
user.memberships.filter(club=self.club, end_date=today).first()
|
||||
)
|
||||
self.assertIsNone(self.club.get_membership_for(user))
|
||||
assert user.memberships.filter(club=self.club, end_date=today).exists()
|
||||
assert self.club.get_membership_for(user) is None
|
||||
|
||||
def test_access_unauthorized(self):
|
||||
"""
|
||||
@ -219,20 +220,20 @@ class ClubModelTest(ClubTest):
|
||||
cannot see the page
|
||||
"""
|
||||
response = self.client.post(self.members_url)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
assert response.status_code == 403
|
||||
|
||||
self.client.login(username="public", password="plop")
|
||||
self.client.force_login(self.public)
|
||||
response = self.client.post(self.members_url)
|
||||
self.assertEqual(response.status_code, 403)
|
||||
assert response.status_code == 403
|
||||
|
||||
def test_display(self):
|
||||
"""
|
||||
Test that a GET request return a page where the requested
|
||||
information are displayed.
|
||||
"""
|
||||
self.client.login(username=self.skia.username, password="plop")
|
||||
self.client.force_login(self.skia)
|
||||
response = self.client.get(self.members_url)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
assert response.status_code == 200
|
||||
expected_html = (
|
||||
"<table><thead><tr>"
|
||||
"<td>Utilisateur</td><td>Rôle</td><td>Description</td>"
|
||||
@ -265,20 +266,20 @@ class ClubModelTest(ClubTest):
|
||||
"""
|
||||
Test that root users can add members to clubs, one at a time
|
||||
"""
|
||||
self.client.login(username="root", password="plop")
|
||||
self.client.force_login(self.root)
|
||||
response = self.client.post(
|
||||
self.members_url,
|
||||
{"users": self.subscriber.id, "role": 3},
|
||||
)
|
||||
self.assertRedirects(response, self.members_url)
|
||||
self.subscriber.refresh_from_db()
|
||||
self.assert_membership_just_started(self.subscriber, role=3)
|
||||
self.assert_membership_started_today(self.subscriber, role=3)
|
||||
|
||||
def test_root_add_multiple_club_member(self):
|
||||
"""
|
||||
Test that root users can add multiple members at once to clubs
|
||||
"""
|
||||
self.client.login(username="root", password="plop")
|
||||
self.client.force_login(self.root)
|
||||
response = self.client.post(
|
||||
self.members_url,
|
||||
{
|
||||
@ -288,36 +289,36 @@ class ClubModelTest(ClubTest):
|
||||
)
|
||||
self.assertRedirects(response, self.members_url)
|
||||
self.subscriber.refresh_from_db()
|
||||
self.assert_membership_just_started(self.subscriber, role=3)
|
||||
self.assert_membership_just_started(self.krophil, role=3)
|
||||
self.assert_membership_started_today(self.subscriber, role=3)
|
||||
self.assert_membership_started_today(self.krophil, role=3)
|
||||
|
||||
def test_add_unauthorized_members(self):
|
||||
"""
|
||||
Test that users who are not currently subscribed
|
||||
cannot be members of clubs.
|
||||
"""
|
||||
self.client.login(username="root", password="plop")
|
||||
self.client.force_login(self.root)
|
||||
response = self.client.post(
|
||||
self.members_url,
|
||||
{"users": self.public.id, "role": 1},
|
||||
)
|
||||
self.assertIsNone(self.public.memberships.filter(club=self.club).first())
|
||||
self.assertTrue('<ul class="errorlist"><li>' in str(response.content))
|
||||
assert not self.public.memberships.filter(club=self.club).exists()
|
||||
assert '<ul class="errorlist"><li>' in response.content.decode()
|
||||
|
||||
response = self.client.post(
|
||||
self.members_url,
|
||||
{"users": self.old_subscriber.id, "role": 1},
|
||||
)
|
||||
self.assertIsNone(self.public.memberships.filter(club=self.club).first())
|
||||
self.assertIsNone(self.club.get_membership_for(self.public))
|
||||
self.assertTrue('<ul class="errorlist"><li>' in str(response.content))
|
||||
assert not self.public.memberships.filter(club=self.club).exists()
|
||||
assert self.club.get_membership_for(self.public) is None
|
||||
assert '<ul class="errorlist"><li>' in response.content.decode()
|
||||
|
||||
def test_add_members_already_members(self):
|
||||
"""
|
||||
Test that users who are already members of a club
|
||||
cannot be added again to this club
|
||||
"""
|
||||
self.client.login(username="root", password="plop")
|
||||
self.client.force_login(self.root)
|
||||
current_membership = self.skia.memberships.ongoing().get(club=self.club)
|
||||
nb_memberships = self.skia.memberships.count()
|
||||
self.client.post(
|
||||
@ -325,10 +326,10 @@ class ClubModelTest(ClubTest):
|
||||
{"users": self.skia.id, "role": current_membership.role + 1},
|
||||
)
|
||||
self.skia.refresh_from_db()
|
||||
self.assertEqual(nb_memberships, self.skia.memberships.count())
|
||||
assert nb_memberships == self.skia.memberships.count()
|
||||
new_membership = self.skia.memberships.ongoing().get(club=self.club)
|
||||
self.assertEqual(current_membership, new_membership)
|
||||
self.assertEqual(self.club.get_membership_for(self.skia), new_membership)
|
||||
assert current_membership == new_membership
|
||||
assert self.club.get_membership_for(self.skia) == new_membership
|
||||
|
||||
def test_add_not_existing_users(self):
|
||||
"""
|
||||
@ -336,15 +337,16 @@ class ClubModelTest(ClubTest):
|
||||
If one user in the request is invalid, no membership creation at all
|
||||
can take place.
|
||||
"""
|
||||
self.client.login(username="root", password="plop")
|
||||
self.client.force_login(self.root)
|
||||
nb_memberships = self.club.members.count()
|
||||
response = self.client.post(
|
||||
self.members_url,
|
||||
{"users": [9999], "role": 1},
|
||||
)
|
||||
self.assertContains(response, '<ul class="errorlist"><li>')
|
||||
assert response.status_code == 200
|
||||
assert '<ul class="errorlist"><li>' in response.content.decode()
|
||||
self.club.refresh_from_db()
|
||||
self.assertEqual(self.club.members.count(), nb_memberships)
|
||||
assert self.club.members.count() == nb_memberships
|
||||
response = self.client.post(
|
||||
self.members_url,
|
||||
{
|
||||
@ -353,9 +355,10 @@ class ClubModelTest(ClubTest):
|
||||
"role": 3,
|
||||
},
|
||||
)
|
||||
self.assertContains(response, '<ul class="errorlist"><li>')
|
||||
assert response.status_code == 200
|
||||
assert '<ul class="errorlist"><li>' in response.content.decode()
|
||||
self.club.refresh_from_db()
|
||||
self.assertEqual(self.club.members.count(), nb_memberships)
|
||||
assert self.club.members.count() == nb_memberships
|
||||
|
||||
def test_president_add_members(self):
|
||||
"""
|
||||
@ -364,7 +367,7 @@ class ClubModelTest(ClubTest):
|
||||
president = self.club.members.get(role=10).user
|
||||
nb_club_membership = self.club.members.count()
|
||||
nb_subscriber_memberships = self.subscriber.memberships.count()
|
||||
self.client.login(username=president.username, password="plop")
|
||||
self.client.force_login(president)
|
||||
response = self.client.post(
|
||||
self.members_url,
|
||||
{"users": self.subscriber.id, "role": 9},
|
||||
@ -372,56 +375,55 @@ class ClubModelTest(ClubTest):
|
||||
self.assertRedirects(response, self.members_url)
|
||||
self.club.refresh_from_db()
|
||||
self.subscriber.refresh_from_db()
|
||||
self.assertEqual(self.club.members.count(), nb_club_membership + 1)
|
||||
self.assertEqual(
|
||||
self.subscriber.memberships.count(), nb_subscriber_memberships + 1
|
||||
)
|
||||
self.assert_membership_just_started(self.subscriber, role=9)
|
||||
assert self.club.members.count() == nb_club_membership + 1
|
||||
assert self.subscriber.memberships.count() == nb_subscriber_memberships + 1
|
||||
self.assert_membership_started_today(self.subscriber, role=9)
|
||||
|
||||
def test_add_member_greater_role(self):
|
||||
"""
|
||||
Test that a member of the club member cannot create
|
||||
a membership with a greater role than its own.
|
||||
"""
|
||||
self.client.login(username=self.skia.username, password="plop")
|
||||
self.client.force_login(self.skia)
|
||||
nb_memberships = self.club.members.count()
|
||||
response = self.client.post(
|
||||
self.members_url,
|
||||
{"users": self.subscriber.id, "role": 10},
|
||||
)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
assert response.status_code == 200
|
||||
self.assertInHTML(
|
||||
"<li>Vous n'avez pas la permission de faire cela</li>",
|
||||
response.content.decode(),
|
||||
)
|
||||
self.club.refresh_from_db()
|
||||
self.assertEqual(nb_memberships, self.club.members.count())
|
||||
self.assertIsNone(self.subscriber.memberships.filter(club=self.club).first())
|
||||
assert nb_memberships == self.club.members.count()
|
||||
assert not self.subscriber.memberships.filter(club=self.club).exists()
|
||||
|
||||
def test_add_member_without_role(self):
|
||||
"""
|
||||
Test that trying to add members without specifying their role fails
|
||||
"""
|
||||
self.client.login(username="root", password="plop")
|
||||
self.client.force_login(self.root)
|
||||
response = self.client.post(
|
||||
self.members_url,
|
||||
{"users": self.subscriber.id, "start_date": "12/06/2016"},
|
||||
)
|
||||
self.assertTrue(
|
||||
'<ul class="errorlist"><li>Vous devez choisir un r' in str(response.content)
|
||||
assert (
|
||||
'<ul class="errorlist"><li>Vous devez choisir un r'
|
||||
in response.content.decode()
|
||||
)
|
||||
|
||||
def test_end_membership_self(self):
|
||||
"""
|
||||
Test that a member can end its own membership
|
||||
"""
|
||||
self.client.login(username="skia", password="plop")
|
||||
self.client.force_login(self.skia)
|
||||
self.client.post(
|
||||
self.members_url,
|
||||
{"users_old": self.skia.id},
|
||||
)
|
||||
self.skia.refresh_from_db()
|
||||
self.assert_membership_just_ended(self.skia)
|
||||
self.assert_membership_ended_today(self.skia)
|
||||
|
||||
def test_end_membership_lower_role(self):
|
||||
"""
|
||||
@ -429,14 +431,14 @@ class ClubModelTest(ClubTest):
|
||||
of users with lower roles
|
||||
"""
|
||||
# remainder : skia has role 3, comptable has role 10, richard has role 1
|
||||
self.client.login(username=self.skia.username, password="plop")
|
||||
self.client.force_login(self.skia)
|
||||
response = self.client.post(
|
||||
self.members_url,
|
||||
{"users_old": self.richard.id},
|
||||
)
|
||||
self.assertRedirects(response, self.members_url)
|
||||
self.club.refresh_from_db()
|
||||
self.assert_membership_just_ended(self.richard)
|
||||
self.assert_membership_ended_today(self.richard)
|
||||
|
||||
def test_end_membership_higher_role(self):
|
||||
"""
|
||||
@ -444,18 +446,18 @@ class ClubModelTest(ClubTest):
|
||||
of users with higher roles
|
||||
"""
|
||||
membership = self.comptable.memberships.filter(club=self.club).first()
|
||||
self.client.login(username=self.skia.username, password="plop")
|
||||
self.client.force_login(self.skia)
|
||||
self.client.post(
|
||||
self.members_url,
|
||||
{"users_old": self.comptable.id},
|
||||
)
|
||||
self.club.refresh_from_db()
|
||||
new_membership = self.club.get_membership_for(self.comptable)
|
||||
self.assertIsNotNone(new_membership)
|
||||
self.assertEqual(new_membership, membership)
|
||||
assert new_membership is not None
|
||||
assert new_membership == membership
|
||||
|
||||
membership = self.comptable.memberships.filter(club=self.club).first()
|
||||
self.assertIsNone(membership.end_date)
|
||||
assert membership.end_date is None
|
||||
|
||||
def test_end_membership_as_main_club_board(self):
|
||||
"""
|
||||
@ -467,29 +469,29 @@ class ClubModelTest(ClubTest):
|
||||
Membership.objects.create(club=self.ae, user=self.subscriber, role=3)
|
||||
|
||||
nb_memberships = self.club.members.count()
|
||||
self.client.login(username=self.subscriber.username, password="plop")
|
||||
self.client.force_login(self.subscriber)
|
||||
response = self.client.post(
|
||||
self.members_url,
|
||||
{"users_old": self.comptable.id},
|
||||
)
|
||||
self.assertRedirects(response, self.members_url)
|
||||
self.assert_membership_just_ended(self.comptable)
|
||||
self.assertEqual(self.club.members.ongoing().count(), nb_memberships - 1)
|
||||
self.assert_membership_ended_today(self.comptable)
|
||||
assert self.club.members.ongoing().count() == nb_memberships - 1
|
||||
|
||||
def test_end_membership_as_root(self):
|
||||
"""
|
||||
Test that root users can end the membership of anyone
|
||||
"""
|
||||
nb_memberships = self.club.members.count()
|
||||
self.client.login(username="root", password="plop")
|
||||
self.client.force_login(self.root)
|
||||
response = self.client.post(
|
||||
self.members_url,
|
||||
{"users_old": [self.comptable.id]},
|
||||
)
|
||||
self.assertRedirects(response, self.members_url)
|
||||
self.assert_membership_just_ended(self.comptable)
|
||||
self.assertEqual(self.club.members.ongoing().count(), nb_memberships - 1)
|
||||
self.assertEqual(self.club.members.count(), nb_memberships)
|
||||
self.assert_membership_ended_today(self.comptable)
|
||||
assert self.club.members.ongoing().count() == nb_memberships - 1
|
||||
assert self.club.members.count() == nb_memberships
|
||||
|
||||
def test_end_membership_as_foreigner(self):
|
||||
"""
|
||||
@ -497,16 +499,15 @@ class ClubModelTest(ClubTest):
|
||||
"""
|
||||
nb_memberships = self.club.members.count()
|
||||
membership = self.richard.memberships.filter(club=self.club).first()
|
||||
self.client.login(username="subscriber", password="root")
|
||||
self.client.force_login(self.subscriber)
|
||||
self.client.post(
|
||||
self.members_url,
|
||||
{"users_old": [self.richard.id]},
|
||||
)
|
||||
# nothing should have changed
|
||||
new_mem = self.club.get_membership_for(self.richard)
|
||||
self.assertIsNotNone(new_mem)
|
||||
self.assertEqual(self.club.members.count(), nb_memberships)
|
||||
self.assertEqual(membership, new_mem)
|
||||
assert self.club.members.count() == nb_memberships
|
||||
assert membership == new_mem
|
||||
|
||||
def test_delete_remove_from_meta_group(self):
|
||||
"""
|
||||
@ -519,7 +520,7 @@ class ClubModelTest(ClubTest):
|
||||
|
||||
self.club.delete()
|
||||
for user in users:
|
||||
self.assertFalse(user.is_in_group(name=meta_group))
|
||||
assert not user.is_in_group(name=meta_group)
|
||||
|
||||
def test_add_to_meta_group(self):
|
||||
"""
|
||||
@ -527,11 +528,11 @@ class ClubModelTest(ClubTest):
|
||||
"""
|
||||
group_members = self.club.unix_name + settings.SITH_MEMBER_SUFFIX
|
||||
board_members = self.club.unix_name + settings.SITH_BOARD_SUFFIX
|
||||
self.assertFalse(self.subscriber.is_in_group(name=group_members))
|
||||
self.assertFalse(self.subscriber.is_in_group(name=board_members))
|
||||
assert not self.subscriber.is_in_group(name=group_members)
|
||||
assert not self.subscriber.is_in_group(name=board_members)
|
||||
Membership.objects.create(club=self.club, user=self.subscriber, role=3)
|
||||
self.assertTrue(self.subscriber.is_in_group(name=group_members))
|
||||
self.assertTrue(self.subscriber.is_in_group(name=board_members))
|
||||
assert self.subscriber.is_in_group(name=group_members)
|
||||
assert self.subscriber.is_in_group(name=board_members)
|
||||
|
||||
def test_remove_from_meta_group(self):
|
||||
"""
|
||||
@ -539,24 +540,24 @@ class ClubModelTest(ClubTest):
|
||||
"""
|
||||
group_members = self.club.unix_name + settings.SITH_MEMBER_SUFFIX
|
||||
board_members = self.club.unix_name + settings.SITH_BOARD_SUFFIX
|
||||
self.assertTrue(self.comptable.is_in_group(name=group_members))
|
||||
self.assertTrue(self.comptable.is_in_group(name=board_members))
|
||||
assert self.comptable.is_in_group(name=group_members)
|
||||
assert self.comptable.is_in_group(name=board_members)
|
||||
self.comptable.memberships.update(end_date=localtime(now()))
|
||||
self.assertFalse(self.comptable.is_in_group(name=group_members))
|
||||
self.assertFalse(self.comptable.is_in_group(name=board_members))
|
||||
assert not self.comptable.is_in_group(name=group_members)
|
||||
assert not self.comptable.is_in_group(name=board_members)
|
||||
|
||||
def test_club_owner(self):
|
||||
"""
|
||||
Test that a club is owned only by board members of the main club
|
||||
"""
|
||||
anonymous = AnonymousUser()
|
||||
self.assertFalse(self.club.is_owned_by(anonymous))
|
||||
self.assertFalse(self.club.is_owned_by(self.subscriber))
|
||||
assert not self.club.is_owned_by(anonymous)
|
||||
assert not self.club.is_owned_by(self.subscriber)
|
||||
|
||||
# make sli a board member
|
||||
self.sli.memberships.all().delete()
|
||||
Membership(club=self.ae, user=self.sli, role=3).save()
|
||||
self.assertTrue(self.club.is_owned_by(self.sli))
|
||||
assert self.club.is_owned_by(self.sli)
|
||||
|
||||
|
||||
class MailingFormTest(TestCase):
|
||||
@ -564,11 +565,13 @@ class MailingFormTest(TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
cls.skia = User.objects.filter(username="skia").first()
|
||||
cls.rbatsbak = User.objects.filter(username="rbatsbak").first()
|
||||
cls.krophil = User.objects.filter(username="krophil").first()
|
||||
cls.comunity = User.objects.filter(username="comunity").first()
|
||||
cls.bdf = Club.objects.filter(unix_name=SITH_BAR_MANAGER["unix_name"]).first()
|
||||
cls.skia = User.objects.get(username="skia")
|
||||
cls.rbatsbak = User.objects.get(username="rbatsbak")
|
||||
cls.krophil = User.objects.get(username="krophil")
|
||||
cls.comunity = User.objects.get(username="comunity")
|
||||
cls.root = User.objects.get(username="root")
|
||||
cls.bdf = Club.objects.get(unix_name=SITH_BAR_MANAGER["unix_name"])
|
||||
cls.mail_url = reverse("club:mailing", kwargs={"club_id": cls.bdf.id})
|
||||
|
||||
def setUp(self):
|
||||
Membership(
|
||||
@ -580,134 +583,125 @@ class MailingFormTest(TestCase):
|
||||
|
||||
def test_mailing_list_add_no_moderation(self):
|
||||
# Test with Communication admin
|
||||
self.client.login(username="comunity", password="plop")
|
||||
self.client.post(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id}),
|
||||
self.client.force_login(self.comunity)
|
||||
response = self.client.post(
|
||||
self.mail_url,
|
||||
{"action": MailingForm.ACTION_NEW_MAILING, "mailing_email": "foyer"},
|
||||
)
|
||||
response = self.client.get(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id})
|
||||
)
|
||||
self.assertContains(response, text="Liste de diffusion foyer@utbm.fr")
|
||||
self.assertRedirects(response, self.mail_url)
|
||||
response = self.client.get(self.mail_url)
|
||||
assert response.status_code == 200
|
||||
assert "Liste de diffusion foyer@utbm.fr" in response.content.decode()
|
||||
|
||||
# Test with Root
|
||||
self.client.login(username="root", password="plop")
|
||||
self.client.force_login(self.root)
|
||||
self.client.post(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id}),
|
||||
self.mail_url,
|
||||
{"action": MailingForm.ACTION_NEW_MAILING, "mailing_email": "mde"},
|
||||
)
|
||||
response = self.client.get(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id})
|
||||
)
|
||||
self.assertContains(response, text="Liste de diffusion mde@utbm.fr")
|
||||
response = self.client.get(self.mail_url)
|
||||
assert response.status_code == 200
|
||||
assert "Liste de diffusion mde@utbm.fr" in response.content.decode()
|
||||
|
||||
def test_mailing_list_add_moderation(self):
|
||||
self.client.login(username="rbatsbak", password="plop")
|
||||
self.client.force_login(self.rbatsbak)
|
||||
self.client.post(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id}),
|
||||
self.mail_url,
|
||||
{"action": MailingForm.ACTION_NEW_MAILING, "mailing_email": "mde"},
|
||||
)
|
||||
response = self.client.get(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id})
|
||||
)
|
||||
self.assertNotContains(response, text="Liste de diffusion mde@utbm.fr")
|
||||
self.assertContains(
|
||||
response, text="<p>Listes de diffusions en attente de modération</p>"
|
||||
)
|
||||
self.assertContains(response, "<li>mde@utbm.fr")
|
||||
response = self.client.get(self.mail_url)
|
||||
assert response.status_code == 200
|
||||
content = response.content.decode()
|
||||
assert "Liste de diffusion mde@utbm.fr" not in content
|
||||
assert "<p>Listes de diffusions en attente de modération</p>" in content
|
||||
assert "<li>mde@utbm.fr" in content
|
||||
|
||||
def test_mailing_list_forbidden(self):
|
||||
# With anonymous user
|
||||
response = self.client.get(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id})
|
||||
)
|
||||
response = self.client.get(self.mail_url)
|
||||
self.assertContains(response, "", status_code=403)
|
||||
|
||||
# With user not in club
|
||||
self.client.login(username="krophil", password="plop")
|
||||
response = self.client.get(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id})
|
||||
)
|
||||
self.assertContains(response, "", status_code=403)
|
||||
self.client.force_login(self.krophil)
|
||||
response = self.client.get(self.mail_url)
|
||||
assert response.status_code == 403
|
||||
|
||||
def test_add_new_subscription_fail_not_moderated(self):
|
||||
self.client.login(username="rbatsbak", password="plop")
|
||||
self.client.force_login(self.rbatsbak)
|
||||
self.client.post(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id}),
|
||||
self.mail_url,
|
||||
{"action": MailingForm.ACTION_NEW_MAILING, "mailing_email": "mde"},
|
||||
)
|
||||
|
||||
self.client.post(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id}),
|
||||
self.mail_url,
|
||||
{
|
||||
"action": MailingForm.ACTION_NEW_SUBSCRIPTION,
|
||||
"subscription_users": self.skia.id,
|
||||
"subscription_mailing": Mailing.objects.get(email="mde").id,
|
||||
},
|
||||
)
|
||||
response = self.client.get(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id})
|
||||
)
|
||||
self.assertNotContains(response, "skia@git.an")
|
||||
response = self.client.get(self.mail_url)
|
||||
assert response.status_code == 200
|
||||
assert "skia@git.an" not in response.content.decode()
|
||||
|
||||
def test_add_new_subscription_success(self):
|
||||
# Prepare mailing list
|
||||
self.client.login(username="comunity", password="plop")
|
||||
self.client.force_login(self.comunity)
|
||||
self.client.post(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id}),
|
||||
self.mail_url,
|
||||
{"action": MailingForm.ACTION_NEW_MAILING, "mailing_email": "mde"},
|
||||
)
|
||||
|
||||
# Add single user
|
||||
self.client.post(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id}),
|
||||
self.mail_url,
|
||||
{
|
||||
"action": MailingForm.ACTION_NEW_SUBSCRIPTION,
|
||||
"subscription_users": self.skia.id,
|
||||
"subscription_mailing": Mailing.objects.get(email="mde").id,
|
||||
},
|
||||
)
|
||||
response = self.client.get(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id})
|
||||
)
|
||||
self.assertContains(response, "skia@git.an")
|
||||
response = self.client.get(self.mail_url)
|
||||
assert response.status_code == 200
|
||||
assert "skia@git.an" in response.content.decode()
|
||||
|
||||
# Add multiple users
|
||||
self.client.post(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id}),
|
||||
self.mail_url,
|
||||
{
|
||||
"action": MailingForm.ACTION_NEW_SUBSCRIPTION,
|
||||
"subscription_users": "|%s|%s|" % (self.comunity.id, self.rbatsbak.id),
|
||||
"subscription_mailing": Mailing.objects.get(email="mde").id,
|
||||
},
|
||||
)
|
||||
response = self.client.get(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id})
|
||||
)
|
||||
self.assertContains(response, "richard@git.an")
|
||||
self.assertContains(response, "comunity@git.an")
|
||||
self.assertContains(response, "skia@git.an")
|
||||
response = self.client.get(self.mail_url)
|
||||
assert response.status_code == 200
|
||||
content = response.content.decode()
|
||||
assert "richard@git.an" in content
|
||||
assert "comunity@git.an" in content
|
||||
assert "skia@git.an" in content
|
||||
|
||||
# Add arbitrary email
|
||||
self.client.post(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id}),
|
||||
self.mail_url,
|
||||
{
|
||||
"action": MailingForm.ACTION_NEW_SUBSCRIPTION,
|
||||
"subscription_email": "arbitrary@git.an",
|
||||
"subscription_mailing": Mailing.objects.get(email="mde").id,
|
||||
},
|
||||
)
|
||||
response = self.client.get(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id})
|
||||
)
|
||||
self.assertContains(response, "richard@git.an")
|
||||
self.assertContains(response, "comunity@git.an")
|
||||
self.assertContains(response, "skia@git.an")
|
||||
self.assertContains(response, "arbitrary@git.an")
|
||||
response = self.client.get(self.mail_url)
|
||||
assert response.status_code == 200
|
||||
content = response.content.decode()
|
||||
assert "richard@git.an" in content
|
||||
assert "comunity@git.an" in content
|
||||
assert "skia@git.an" in content
|
||||
assert "arbitrary@git.an" in content
|
||||
|
||||
# Add user and arbitrary email
|
||||
self.client.post(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id}),
|
||||
self.mail_url,
|
||||
{
|
||||
"action": MailingForm.ACTION_NEW_SUBSCRIPTION,
|
||||
"subscription_email": "more.arbitrary@git.an",
|
||||
@ -715,57 +709,61 @@ class MailingFormTest(TestCase):
|
||||
"subscription_mailing": Mailing.objects.get(email="mde").id,
|
||||
},
|
||||
)
|
||||
response = self.client.get(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id})
|
||||
)
|
||||
self.assertContains(response, "richard@git.an")
|
||||
self.assertContains(response, "comunity@git.an")
|
||||
self.assertContains(response, "skia@git.an")
|
||||
self.assertContains(response, "arbitrary@git.an")
|
||||
self.assertContains(response, "more.arbitrary@git.an")
|
||||
self.assertContains(response, "krophil@git.an")
|
||||
response = self.client.get(self.mail_url)
|
||||
assert response.status_code == 200
|
||||
content = response.content.decode()
|
||||
assert "richard@git.an" in content
|
||||
assert "comunity@git.an" in content
|
||||
assert "skia@git.an" in content
|
||||
assert "arbitrary@git.an" in content
|
||||
assert "more.arbitrary@git.an" in content
|
||||
assert "krophil@git.an" in content
|
||||
|
||||
def test_add_new_subscription_fail_form_errors(self):
|
||||
# Prepare mailing list
|
||||
self.client.login(username="comunity", password="plop")
|
||||
self.client.force_login(self.comunity)
|
||||
self.client.post(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id}),
|
||||
self.mail_url,
|
||||
{"action": MailingForm.ACTION_NEW_MAILING, "mailing_email": "mde"},
|
||||
)
|
||||
|
||||
# Neither email or email is specified
|
||||
response = self.client.post(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id}),
|
||||
self.mail_url,
|
||||
{
|
||||
"action": MailingForm.ACTION_NEW_SUBSCRIPTION,
|
||||
"subscription_mailing": Mailing.objects.get(email="mde").id,
|
||||
},
|
||||
)
|
||||
self.assertContains(
|
||||
response, text=_("You must specify at least an user or an email address")
|
||||
assert response.status_code
|
||||
self.assertInHTML(
|
||||
_("You must specify at least an user or an email address"),
|
||||
response.content.decode(),
|
||||
)
|
||||
|
||||
# No mailing specified
|
||||
response = self.client.post(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id}),
|
||||
self.mail_url,
|
||||
{
|
||||
"action": MailingForm.ACTION_NEW_SUBSCRIPTION,
|
||||
"subscription_users": self.krophil.id,
|
||||
},
|
||||
)
|
||||
self.assertContains(response, text=_("This field is required"))
|
||||
assert response.status_code == 200
|
||||
assert _("This field is required") in response.content.decode()
|
||||
|
||||
# One of the selected users doesn't exist
|
||||
response = self.client.post(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id}),
|
||||
self.mail_url,
|
||||
{
|
||||
"action": MailingForm.ACTION_NEW_SUBSCRIPTION,
|
||||
"subscription_users": "|789|",
|
||||
"subscription_mailing": Mailing.objects.get(email="mde").id,
|
||||
},
|
||||
)
|
||||
self.assertContains(
|
||||
response, text=html.escape(_("One of the selected users doesn't exist"))
|
||||
assert response.status_code == 200
|
||||
self.assertInHTML(
|
||||
_("One of the selected users doesn't exist"), response.content.decode()
|
||||
)
|
||||
|
||||
# An user has no email adress
|
||||
@ -773,18 +771,17 @@ class MailingFormTest(TestCase):
|
||||
self.krophil.save()
|
||||
|
||||
response = self.client.post(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id}),
|
||||
self.mail_url,
|
||||
{
|
||||
"action": MailingForm.ACTION_NEW_SUBSCRIPTION,
|
||||
"subscription_users": self.krophil.id,
|
||||
"subscription_mailing": Mailing.objects.get(email="mde").id,
|
||||
},
|
||||
)
|
||||
self.assertContains(
|
||||
response,
|
||||
text=html.escape(
|
||||
_("One of the selected users doesn't have an email address")
|
||||
),
|
||||
assert response.status_code == 200
|
||||
self.assertInHTML(
|
||||
_("One of the selected users doesn't have an email address"),
|
||||
response.content.decode(),
|
||||
)
|
||||
|
||||
self.krophil.email = "krophil@git.an"
|
||||
@ -793,7 +790,7 @@ class MailingFormTest(TestCase):
|
||||
# An user is added twice
|
||||
|
||||
self.client.post(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id}),
|
||||
self.mail_url,
|
||||
{
|
||||
"action": MailingForm.ACTION_NEW_SUBSCRIPTION,
|
||||
"subscription_users": self.krophil.id,
|
||||
@ -802,28 +799,29 @@ class MailingFormTest(TestCase):
|
||||
)
|
||||
|
||||
response = self.client.post(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id}),
|
||||
self.mail_url,
|
||||
{
|
||||
"action": MailingForm.ACTION_NEW_SUBSCRIPTION,
|
||||
"subscription_users": self.krophil.id,
|
||||
"subscription_mailing": Mailing.objects.get(email="mde").id,
|
||||
},
|
||||
)
|
||||
self.assertContains(
|
||||
response,
|
||||
text=html.escape(_("This email is already suscribed in this mailing")),
|
||||
assert response.status_code == 200
|
||||
self.assertInHTML(
|
||||
_("This email is already suscribed in this mailing"),
|
||||
response.content.decode(),
|
||||
)
|
||||
|
||||
def test_remove_subscription_success(self):
|
||||
# Prepare mailing list
|
||||
self.client.login(username="comunity", password="plop")
|
||||
self.client.force_login(self.comunity)
|
||||
self.client.post(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id}),
|
||||
self.mail_url,
|
||||
{"action": MailingForm.ACTION_NEW_MAILING, "mailing_email": "mde"},
|
||||
)
|
||||
mde = Mailing.objects.get(email="mde")
|
||||
self.client.post(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id}),
|
||||
self.mail_url,
|
||||
{
|
||||
"action": MailingForm.ACTION_NEW_SUBSCRIPTION,
|
||||
"subscription_users": "|%s|%s|%s|"
|
||||
@ -832,37 +830,36 @@ class MailingFormTest(TestCase):
|
||||
},
|
||||
)
|
||||
|
||||
response = self.client.get(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id})
|
||||
)
|
||||
response = self.client.get(self.mail_url)
|
||||
assert response.status_code == 200
|
||||
content = response.content.decode()
|
||||
|
||||
self.assertContains(response, "comunity@git.an")
|
||||
self.assertContains(response, "richard@git.an")
|
||||
self.assertContains(response, "krophil@git.an")
|
||||
assert "comunity@git.an" in content
|
||||
assert "richard@git.an" in content
|
||||
assert "krophil@git.an" in content
|
||||
|
||||
# Delete one user
|
||||
self.client.post(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id}),
|
||||
self.mail_url,
|
||||
{
|
||||
"action": MailingForm.ACTION_REMOVE_SUBSCRIPTION,
|
||||
"removal_%d" % mde.id: mde.subscriptions.get(user=self.krophil).id,
|
||||
},
|
||||
)
|
||||
response = self.client.get(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id})
|
||||
)
|
||||
response = self.client.get(self.mail_url)
|
||||
assert response.status_code == 200
|
||||
content = response.content.decode()
|
||||
|
||||
self.assertContains(response, "comunity@git.an")
|
||||
self.assertContains(response, "richard@git.an")
|
||||
self.assertNotContains(response, "krophil@git.an")
|
||||
assert "comunity@git.an" in content
|
||||
assert "richard@git.an" in content
|
||||
assert "krophil@git.an" not in content
|
||||
|
||||
# Delete multiple users
|
||||
self.client.post(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id}),
|
||||
self.mail_url,
|
||||
{
|
||||
"action": MailingForm.ACTION_REMOVE_SUBSCRIPTION,
|
||||
"removal_%d"
|
||||
% mde.id: [
|
||||
"removal_%d" % mde.id: [
|
||||
user.id
|
||||
for user in mde.subscriptions.filter(
|
||||
user__in=[self.rbatsbak, self.comunity]
|
||||
@ -870,13 +867,13 @@ class MailingFormTest(TestCase):
|
||||
],
|
||||
},
|
||||
)
|
||||
response = self.client.get(
|
||||
reverse("club:mailing", kwargs={"club_id": self.bdf.id})
|
||||
)
|
||||
response = self.client.get(self.mail_url)
|
||||
assert response.status_code == 200
|
||||
content = response.content.decode()
|
||||
|
||||
self.assertNotContains(response, "comunity@git.an")
|
||||
self.assertNotContains(response, "richard@git.an")
|
||||
self.assertNotContains(response, "krophil@git.an")
|
||||
assert "comunity@git.an" not in content
|
||||
assert "richard@git.an" not in content
|
||||
assert "krophil@git.an" not in content
|
||||
|
||||
|
||||
class ClubSellingViewTest(TestCase):
|
||||
@ -884,15 +881,17 @@ class ClubSellingViewTest(TestCase):
|
||||
Perform basics tests to ensure that the page is available
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
self.ae = Club.objects.filter(unix_name="ae").first()
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
cls.ae = Club.objects.get(unix_name="ae")
|
||||
cls.skia = User.objects.get(username="skia")
|
||||
|
||||
def test_page_not_internal_error(self):
|
||||
"""
|
||||
Test that the page does not return and internal error
|
||||
"""
|
||||
self.client.login(username="skia", password="plop")
|
||||
self.client.force_login(self.skia)
|
||||
response = self.client.get(
|
||||
reverse("club:club_sellings", kwargs={"club_id": self.ae.id})
|
||||
)
|
||||
self.assertFalse(response.status_code == 500)
|
||||
assert response.status_code == 200
|
||||
|
31
club/urls.py
31
club/urls.py
@ -1,26 +1,21 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2016,2017
|
||||
# - Skia <skia@libskia.so>
|
||||
# - Sli <antoine@bartuccio.fr>
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||
# http://ae.utbm.fr.
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License a published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
from django.urls import path
|
||||
|
@ -1,75 +1,62 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2016,2017
|
||||
# - Skia <skia@libskia.so>
|
||||
# - Sli <antoine@bartuccio.fr>
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||
# http://ae.utbm.fr.
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License a published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
import csv
|
||||
|
||||
from django.conf import settings
|
||||
from django import forms
|
||||
from django.views.generic import ListView, DetailView, TemplateView, View
|
||||
from django.views.generic.edit import DeleteView
|
||||
from django.views.generic.detail import SingleObjectMixin
|
||||
from django.views.generic.edit import UpdateView, CreateView
|
||||
from django.core.exceptions import NON_FIELD_ERRORS, PermissionDenied, ValidationError
|
||||
from django.core.paginator import InvalidPage, Paginator
|
||||
from django.db.models import Sum
|
||||
from django.http import (
|
||||
HttpResponseRedirect,
|
||||
HttpResponse,
|
||||
Http404,
|
||||
HttpResponseRedirect,
|
||||
StreamingHttpResponse,
|
||||
)
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
from django.urls import reverse, reverse_lazy
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils.translation import gettext as _t
|
||||
from django.core.exceptions import PermissionDenied, ValidationError, NON_FIELD_ERRORS
|
||||
from django.core.paginator import Paginator, InvalidPage
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
from django.db.models import Sum
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.generic import DetailView, ListView, TemplateView, View
|
||||
from django.views.generic.edit import CreateView, DeleteView, UpdateView
|
||||
|
||||
|
||||
from core.views import (
|
||||
CanCreateMixin,
|
||||
CanViewMixin,
|
||||
CanEditMixin,
|
||||
CanEditPropMixin,
|
||||
UserIsRootMixin,
|
||||
TabedViewMixin,
|
||||
PageEditViewBase,
|
||||
DetailFormView,
|
||||
from club.forms import ClubEditForm, ClubMemberForm, MailingForm, SellingsForm
|
||||
from club.models import Club, Mailing, MailingSubscription, Membership
|
||||
from com.views import (
|
||||
PosterCreateBaseView,
|
||||
PosterDeleteBaseView,
|
||||
PosterEditBaseView,
|
||||
PosterListBaseView,
|
||||
)
|
||||
from core.models import PageRev
|
||||
|
||||
from counter.models import Selling
|
||||
|
||||
from com.views import (
|
||||
PosterListBaseView,
|
||||
PosterCreateBaseView,
|
||||
PosterEditBaseView,
|
||||
PosterDeleteBaseView,
|
||||
from core.views import (
|
||||
CanCreateMixin,
|
||||
CanEditMixin,
|
||||
CanEditPropMixin,
|
||||
CanViewMixin,
|
||||
DetailFormView,
|
||||
PageEditViewBase,
|
||||
TabedViewMixin,
|
||||
UserIsRootMixin,
|
||||
)
|
||||
|
||||
from club.models import Club, Membership, Mailing, MailingSubscription
|
||||
from club.forms import MailingForm, ClubEditForm, ClubMemberForm, SellingsForm
|
||||
from counter.models import Selling
|
||||
|
||||
|
||||
class ClubTabsMixin(TabedViewMixin):
|
||||
@ -611,7 +598,7 @@ class ClubMailingView(ClubTabsMixin, CanEditMixin, DetailFormView):
|
||||
}
|
||||
return kwargs
|
||||
|
||||
def add_new_mailing(self, cleaned_data) -> ValidationError:
|
||||
def add_new_mailing(self, cleaned_data) -> ValidationError | None:
|
||||
"""
|
||||
Create a new mailing list from the form
|
||||
"""
|
||||
@ -628,7 +615,7 @@ class ClubMailingView(ClubTabsMixin, CanEditMixin, DetailFormView):
|
||||
mailing.save()
|
||||
return None
|
||||
|
||||
def add_new_subscription(self, cleaned_data) -> ValidationError:
|
||||
def add_new_subscription(self, cleaned_data) -> ValidationError | None:
|
||||
"""
|
||||
Add mailing subscriptions for each user given and/or for the specified email in form
|
||||
"""
|
||||
|
@ -1,15 +1,19 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
@ -1,17 +1,21 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
from ajax_select import make_ajax_form
|
||||
from django.contrib import admin
|
||||
|
@ -1,9 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.conf import settings
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,9 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.conf import settings
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import django.utils.timezone
|
||||
from django.conf import settings
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,44 +1,37 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2016,2017
|
||||
# - Skia <skia@libskia.so>
|
||||
# - Sli <antoine@bartuccio.fr>
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||
# http://ae.utbm.fr.
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License a published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
from django.shortcuts import render
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.mail import EmailMultiAlternatives
|
||||
from django.db import models, transaction
|
||||
from django.db.models import Q
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils import timezone
|
||||
from django.urls import reverse
|
||||
from django.conf import settings
|
||||
from django.shortcuts import render
|
||||
from django.templatetags.static import static
|
||||
from django.core.mail import EmailMultiAlternatives
|
||||
from django.core.exceptions import ValidationError
|
||||
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from core import utils
|
||||
from core.models import User, Preferences, RealGroup, Notification, SithFile
|
||||
from club.models import Club
|
||||
from core import utils
|
||||
from core.models import Notification, Preferences, RealGroup, User
|
||||
|
||||
|
||||
class Sith(models.Model):
|
||||
|
@ -39,7 +39,7 @@
|
||||
<p> <a href="{{ url('com:news_moderate', news_id=news.id) }}">{% trans %}Moderate{% endtrans %}</a></p>
|
||||
{% endif %}
|
||||
{% if user.can_edit(news) %}
|
||||
<p> <a href="{{ url('com:news_edit', news_id=news.id) }}">{% trans %}Edit (will be remoderated){% endtrans %}</a></p>
|
||||
<p> <a href="{{ url('com:news_edit', news_id=news.id) }}">{% trans %}Edit (will be moderated again){% endtrans %}</a></p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
110
com/tests.py
110
com/tests.py
@ -1,63 +1,69 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
import pytest
|
||||
from django.conf import settings
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.test import TestCase
|
||||
from django.conf import settings
|
||||
from django.urls import reverse
|
||||
from django.core.management import call_command
|
||||
from django.utils import html
|
||||
from django.utils.timezone import localtime, now
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from club.models import Club, Membership
|
||||
from com.models import Sith, News, Weekmail, WeekmailArticle, Poster
|
||||
from core.models import User, RealGroup, AnonymousUser
|
||||
from com.models import News, Poster, Sith, Weekmail, WeekmailArticle
|
||||
from core.models import AnonymousUser, RealGroup, User
|
||||
|
||||
|
||||
class ComAlertTest(TestCase):
|
||||
def test_page_is_working(self):
|
||||
self.client.login(username="comunity", password="plop")
|
||||
response = self.client.get(reverse("com:alert_edit"))
|
||||
self.assertNotEqual(response.status_code, 500)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
@pytest.fixture()
|
||||
def user_community():
|
||||
return User.objects.get(username="comunity")
|
||||
|
||||
|
||||
class ComInfoTest(TestCase):
|
||||
def test_page_is_working(self):
|
||||
self.client.login(username="comunity", password="plop")
|
||||
response = self.client.get(reverse("com:info_edit"))
|
||||
self.assertNotEqual(response.status_code, 500)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
@pytest.mark.django_db
|
||||
@pytest.mark.parametrize(
|
||||
"url",
|
||||
[
|
||||
reverse("com:alert_edit"),
|
||||
reverse("com:info_edit"),
|
||||
],
|
||||
)
|
||||
def test_com_page_is_working(client, url, user_community):
|
||||
client.force_login(user_community)
|
||||
response = client.get(url)
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
class ComTest(TestCase):
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
cls.skia = User.objects.filter(username="skia").first()
|
||||
cls.skia = User.objects.get(username="skia")
|
||||
cls.com_group = RealGroup.objects.filter(
|
||||
id=settings.SITH_GROUP_COM_ADMIN_ID
|
||||
).first()
|
||||
cls.skia.groups.set([cls.com_group])
|
||||
cls.skia.save()
|
||||
|
||||
def setUp(self):
|
||||
self.client.login(username=self.skia.username, password="plop")
|
||||
self.client.force_login(self.skia)
|
||||
|
||||
def test_alert_msg(self):
|
||||
response = self.client.post(
|
||||
self.client.post(
|
||||
reverse("com:alert_edit"),
|
||||
{
|
||||
"alert_msg": """
|
||||
@ -68,7 +74,6 @@ class ComTest(TestCase):
|
||||
},
|
||||
)
|
||||
r = self.client.get(reverse("core:index"))
|
||||
self.assertTrue(r.status_code == 200)
|
||||
self.assertContains(
|
||||
r,
|
||||
"""<div id="alert_box">
|
||||
@ -77,7 +82,7 @@ class ComTest(TestCase):
|
||||
)
|
||||
|
||||
def test_info_msg(self):
|
||||
response = self.client.post(
|
||||
self.client.post(
|
||||
reverse("com:info_edit"),
|
||||
{
|
||||
"info_msg": """
|
||||
@ -86,7 +91,6 @@ class ComTest(TestCase):
|
||||
},
|
||||
)
|
||||
r = self.client.get(reverse("core:index"))
|
||||
self.assertTrue(r.status_code == 200)
|
||||
self.assertContains(
|
||||
r,
|
||||
"""<div id="info_box">
|
||||
@ -94,7 +98,7 @@ class ComTest(TestCase):
|
||||
)
|
||||
|
||||
def test_birthday_non_subscribed_user(self):
|
||||
self.client.login(username="guy", password="plop")
|
||||
self.client.force_login(User.objects.get(username="guy"))
|
||||
response = self.client.get(reverse("core:index"))
|
||||
self.assertContains(
|
||||
response,
|
||||
@ -123,13 +127,13 @@ class SithTest(TestCase):
|
||||
sith: Sith = Sith.objects.first()
|
||||
|
||||
com_admin = User.objects.get(username="comunity")
|
||||
self.assertTrue(sith.is_owned_by(com_admin))
|
||||
assert sith.is_owned_by(com_admin)
|
||||
|
||||
anonymous = AnonymousUser()
|
||||
self.assertFalse(sith.is_owned_by(anonymous))
|
||||
assert not sith.is_owned_by(anonymous)
|
||||
|
||||
sli = User.objects.get(username="sli")
|
||||
self.assertFalse(sith.is_owned_by(sli))
|
||||
assert not sith.is_owned_by(sli)
|
||||
|
||||
|
||||
class NewsTest(TestCase):
|
||||
@ -154,10 +158,10 @@ class NewsTest(TestCase):
|
||||
or by their author but nobody else
|
||||
"""
|
||||
|
||||
self.assertTrue(self.new.is_owned_by(self.com_admin))
|
||||
self.assertTrue(self.new.is_owned_by(self.author))
|
||||
self.assertFalse(self.new.is_owned_by(self.anonymous))
|
||||
self.assertFalse(self.new.is_owned_by(self.sli))
|
||||
assert self.new.is_owned_by(self.com_admin)
|
||||
assert self.new.is_owned_by(self.author)
|
||||
assert not self.new.is_owned_by(self.anonymous)
|
||||
assert not self.new.is_owned_by(self.sli)
|
||||
|
||||
def test_news_viewer(self):
|
||||
"""
|
||||
@ -165,26 +169,26 @@ class NewsTest(TestCase):
|
||||
and not moderated news only by com admins
|
||||
"""
|
||||
# by default a news isn't moderated
|
||||
self.assertTrue(self.new.can_be_viewed_by(self.com_admin))
|
||||
self.assertFalse(self.new.can_be_viewed_by(self.sli))
|
||||
self.assertFalse(self.new.can_be_viewed_by(self.anonymous))
|
||||
self.assertFalse(self.new.can_be_viewed_by(self.author))
|
||||
assert self.new.can_be_viewed_by(self.com_admin)
|
||||
assert not self.new.can_be_viewed_by(self.sli)
|
||||
assert not self.new.can_be_viewed_by(self.anonymous)
|
||||
assert not self.new.can_be_viewed_by(self.author)
|
||||
|
||||
self.new.is_moderated = True
|
||||
self.new.save()
|
||||
self.assertTrue(self.new.can_be_viewed_by(self.com_admin))
|
||||
self.assertTrue(self.new.can_be_viewed_by(self.sli))
|
||||
self.assertTrue(self.new.can_be_viewed_by(self.anonymous))
|
||||
self.assertTrue(self.new.can_be_viewed_by(self.author))
|
||||
assert self.new.can_be_viewed_by(self.com_admin)
|
||||
assert self.new.can_be_viewed_by(self.sli)
|
||||
assert self.new.can_be_viewed_by(self.anonymous)
|
||||
assert self.new.can_be_viewed_by(self.author)
|
||||
|
||||
def test_news_editor(self):
|
||||
"""
|
||||
Test that only com admins can edit news
|
||||
"""
|
||||
self.assertTrue(self.new.can_be_edited_by(self.com_admin))
|
||||
self.assertFalse(self.new.can_be_edited_by(self.sli))
|
||||
self.assertFalse(self.new.can_be_edited_by(self.anonymous))
|
||||
self.assertFalse(self.new.can_be_edited_by(self.author))
|
||||
assert self.new.can_be_edited_by(self.com_admin)
|
||||
assert not self.new.can_be_edited_by(self.sli)
|
||||
assert not self.new.can_be_edited_by(self.anonymous)
|
||||
assert not self.new.can_be_edited_by(self.author)
|
||||
|
||||
|
||||
class WeekmailArticleTest(TestCase):
|
||||
@ -207,10 +211,10 @@ class WeekmailArticleTest(TestCase):
|
||||
"""
|
||||
Test that weekmails are owned only by com admins
|
||||
"""
|
||||
self.assertTrue(self.article.is_owned_by(self.com_admin))
|
||||
self.assertFalse(self.article.is_owned_by(self.author))
|
||||
self.assertFalse(self.article.is_owned_by(self.anonymous))
|
||||
self.assertFalse(self.article.is_owned_by(self.sli))
|
||||
assert self.article.is_owned_by(self.com_admin)
|
||||
assert not self.article.is_owned_by(self.author)
|
||||
assert not self.article.is_owned_by(self.anonymous)
|
||||
assert not self.article.is_owned_by(self.sli)
|
||||
|
||||
|
||||
class PosterTest(TestCase):
|
||||
@ -233,8 +237,8 @@ class PosterTest(TestCase):
|
||||
"""
|
||||
Test that poster are owned by com admins and board members in clubs
|
||||
"""
|
||||
self.assertTrue(self.poster.is_owned_by(self.com_admin))
|
||||
self.assertFalse(self.poster.is_owned_by(self.anonymous))
|
||||
assert self.poster.is_owned_by(self.com_admin)
|
||||
assert not self.poster.is_owned_by(self.anonymous)
|
||||
|
||||
self.assertFalse(self.poster.is_owned_by(self.susbcriber))
|
||||
self.assertTrue(self.poster.is_owned_by(self.sli))
|
||||
assert not self.poster.is_owned_by(self.susbcriber)
|
||||
assert self.poster.is_owned_by(self.sli)
|
||||
|
@ -1,17 +1,21 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
from django.urls import path
|
||||
|
76
com/views.py
76
com/views.py
@ -1,60 +1,52 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2016,2017
|
||||
# - Skia <skia@libskia.so>
|
||||
# - Sli <antoine@bartuccio.fr>
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||
# http://ae.utbm.fr.
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License a published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
#
|
||||
|
||||
from django.shortcuts import redirect, get_object_or_404
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.views.generic import ListView, DetailView, View
|
||||
from django.views.generic.edit import UpdateView, CreateView, DeleteView
|
||||
from django.views.generic.detail import SingleObjectMixin
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.urls import reverse, reverse_lazy
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils import timezone
|
||||
from django.conf import settings
|
||||
from django.db.models import Max
|
||||
from django.forms.models import modelform_factory
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django import forms
|
||||
|
||||
from datetime import timedelta
|
||||
from smtplib import SMTPRecipientsRefused
|
||||
|
||||
from com.models import Sith, News, NewsDate, Weekmail, WeekmailArticle, Screen, Poster
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import PermissionDenied, ValidationError
|
||||
from django.db.models import Max
|
||||
from django.forms.models import modelform_factory
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
from django.urls import reverse, reverse_lazy
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.generic import DetailView, ListView, View
|
||||
from django.views.generic.detail import SingleObjectMixin
|
||||
from django.views.generic.edit import CreateView, DeleteView, UpdateView
|
||||
|
||||
from club.models import Club, Mailing
|
||||
from com.models import News, NewsDate, Poster, Screen, Sith, Weekmail, WeekmailArticle
|
||||
from core.models import Notification, RealGroup, User
|
||||
from core.views import (
|
||||
CanViewMixin,
|
||||
CanCreateMixin,
|
||||
CanEditMixin,
|
||||
CanEditPropMixin,
|
||||
TabedViewMixin,
|
||||
CanCreateMixin,
|
||||
CanViewMixin,
|
||||
QuickNotifMixin,
|
||||
TabedViewMixin,
|
||||
)
|
||||
from core.views.forms import SelectDateTime, MarkdownInput
|
||||
from core.models import Notification, RealGroup, User
|
||||
from club.models import Club, Mailing
|
||||
from core.views.forms import TzAwareDateTimeField
|
||||
|
||||
from core.views.forms import MarkdownInput, TzAwareDateTimeField
|
||||
|
||||
# Sith object
|
||||
|
||||
|
14
conftest.py
Normal file
14
conftest.py
Normal file
@ -0,0 +1,14 @@
|
||||
import pytest
|
||||
from django.core.management import call_command
|
||||
from django.utils.translation import activate
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def django_db_setup(django_db_setup, django_db_blocker):
|
||||
with django_db_blocker.unblock():
|
||||
call_command("setup")
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def set_default_language():
|
||||
activate("fr")
|
@ -1,15 +1,19 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
@ -1,25 +1,29 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
from django.contrib import admin
|
||||
from ajax_select import make_ajax_form
|
||||
from core.models import User, Page, RealGroup, MetaGroup, SithFile
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth.models import Group as AuthGroup
|
||||
from haystack.admin import SearchModelAdmin
|
||||
|
||||
from core.models import MetaGroup, Page, RealGroup, SithFile, User
|
||||
|
||||
admin.site.unregister(AuthGroup)
|
||||
admin.site.register(MetaGroup)
|
||||
|
32
core/apps.py
32
core/apps.py
@ -1,25 +1,21 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2017
|
||||
# - Skia <skia@libskia.so>
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||
# http://ae.utbm.fr.
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License a published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
import sys
|
||||
@ -34,8 +30,8 @@ class SithConfig(AppConfig):
|
||||
verbose_name = "Core app of the Sith"
|
||||
|
||||
def ready(self):
|
||||
import core.signals # noqa F401
|
||||
from forum.models import Forum
|
||||
import core.signals
|
||||
|
||||
cache.clear()
|
||||
|
||||
|
@ -1,3 +1,23 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
from core.models import Page
|
||||
|
||||
|
||||
|
@ -1,28 +1,31 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
from ajax_select import LookupChannel, register
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from ajax_select import register, LookupChannel
|
||||
|
||||
from core.views.site import search_user
|
||||
from core.models import User, Group, SithFile
|
||||
from club.models import Club
|
||||
from counter.models import Product, Counter, Customer
|
||||
from accounting.models import ClubAccount, Company
|
||||
from eboutic.models import BasketItem
|
||||
from club.models import Club
|
||||
from core.models import Group, SithFile, User
|
||||
from core.views.site import search_user
|
||||
from counter.models import Counter, Customer, Product
|
||||
|
||||
|
||||
def check_token(request):
|
||||
|
@ -1,15 +1,19 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
@ -1,15 +1,19 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
@ -23,8 +23,8 @@
|
||||
#
|
||||
|
||||
import os
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.management import call_command
|
||||
|
||||
from core.models import SithFile
|
||||
|
||||
|
@ -1,30 +1,27 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2019
|
||||
# - Sli <antoine@bartuccio.fr>
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||
# http://ae.utbm.fr.
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License a published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
|
||||
import os
|
||||
|
||||
from django.core.management.commands import compilemessages
|
||||
|
||||
|
||||
|
@ -1,32 +1,29 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2017
|
||||
# - Sli <antoine@bartuccio.fr>
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||
# http://ae.utbm.fr.
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License a published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
import os
|
||||
|
||||
import sass
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.conf import settings
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
@ -1,33 +1,28 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2019
|
||||
# - Sli <antoine@bartuccio.fr>
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||
# http://ae.utbm.fr.
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License a published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
import os
|
||||
import sys
|
||||
import signal
|
||||
|
||||
from http.server import test, CGIHTTPRequestHandler
|
||||
import sys
|
||||
from http.server import CGIHTTPRequestHandler, test
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.utils import autoreload
|
||||
|
68
core/management/commands/install_xapian.py
Normal file
68
core/management/commands/install_xapian.py
Normal file
@ -0,0 +1,68 @@
|
||||
# -*- coding:utf-8 -*
|
||||
#
|
||||
# Copyright 2024 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
#
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
import tomli
|
||||
from django.core.management.base import BaseCommand, CommandParser
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Install xapian"
|
||||
|
||||
def add_arguments(self, parser: CommandParser):
|
||||
parser.add_argument(
|
||||
"-f",
|
||||
"--force",
|
||||
action="store_true",
|
||||
help="Force installation even if already installed",
|
||||
)
|
||||
|
||||
def _current_version(self) -> str | None:
|
||||
try:
|
||||
import xapian
|
||||
except ImportError:
|
||||
return None
|
||||
return xapian.version_string()
|
||||
|
||||
def _desired_version(self) -> str:
|
||||
with open(
|
||||
Path(__file__).parent.parent.parent.parent / "pyproject.toml", "rb"
|
||||
) as f:
|
||||
pyproject = tomli.load(f)
|
||||
return pyproject["tool"]["xapian"]["version"]
|
||||
|
||||
def handle(self, force: bool, *args, **options):
|
||||
if not os.environ.get("VIRTUAL_ENV", None):
|
||||
print("No virtual environment detected, this command can't be used")
|
||||
return
|
||||
|
||||
desired = self._desired_version()
|
||||
if desired == self._current_version():
|
||||
if not force:
|
||||
print(
|
||||
f"Version {desired} is already installed, use --force to re-install"
|
||||
)
|
||||
return
|
||||
print(f"Version {desired} is already installed, re-installing")
|
||||
print(f"Installing xapian version {desired} at {os.environ['VIRTUAL_ENV']}")
|
||||
subprocess.run(
|
||||
[str(Path(__file__).parent / "install_xapian.sh"), desired],
|
||||
env=dict(os.environ),
|
||||
).check_returncode()
|
||||
print("Installation success")
|
47
core/management/commands/install_xapian.sh
Executable file
47
core/management/commands/install_xapian.sh
Executable file
@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
# Originates from https://gist.github.com/jorgecarleitao/ab6246c86c936b9c55fd
|
||||
# first argument of the script is Xapian version (e.g. 1.2.19)
|
||||
VERSION=$1
|
||||
|
||||
# Cleanup env vars for auto discovery mechanism
|
||||
export CPATH=
|
||||
export LIBRARY_PATH=
|
||||
export CFLAGS=
|
||||
export LDFLAGS=
|
||||
export CCFLAGS=
|
||||
export CXXFLAGS=
|
||||
export CPPFLAGS=
|
||||
|
||||
# prepare
|
||||
rm -rf "$VIRTUAL_ENV/packages"
|
||||
mkdir -p "$VIRTUAL_ENV/packages" && cd "$VIRTUAL_ENV/packages" || exit 1
|
||||
|
||||
CORE=xapian-core-$VERSION
|
||||
BINDINGS=xapian-bindings-$VERSION
|
||||
|
||||
# download
|
||||
echo "Downloading source..."
|
||||
curl -O "https://oligarchy.co.uk/xapian/$VERSION/${CORE}.tar.xz"
|
||||
curl -O "https://oligarchy.co.uk/xapian/$VERSION/${BINDINGS}.tar.xz"
|
||||
|
||||
# extract
|
||||
echo "Extracting source..."
|
||||
tar xf "${CORE}.tar.xz"
|
||||
tar xf "${BINDINGS}.tar.xz"
|
||||
|
||||
# install
|
||||
echo "Installing Xapian-core..."
|
||||
cd "$VIRTUAL_ENV/packages/${CORE}" || exit 1
|
||||
./configure --prefix="$VIRTUAL_ENV" && make && make install
|
||||
|
||||
PYTHON_FLAG=--with-python3
|
||||
|
||||
echo "Installing Xapian-bindings..."
|
||||
cd "$VIRTUAL_ENV/packages/${BINDINGS}" || exit 1
|
||||
./configure --prefix="$VIRTUAL_ENV" $PYTHON_FLAG XAPIAN_CONFIG="$VIRTUAL_ENV/bin/xapian-config" && make && make install
|
||||
|
||||
# clean
|
||||
rm -rf "$VIRTUAL_ENV/packages"
|
||||
|
||||
# test
|
||||
python -c "import xapian"
|
@ -1,28 +1,25 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2017
|
||||
# - Skia <skia@libskia.so>
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||
# http://ae.utbm.fr.
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License a published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
import os
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from core.markdown import markdown
|
||||
|
@ -24,38 +24,37 @@
|
||||
|
||||
import os
|
||||
from datetime import date, datetime, timedelta
|
||||
from io import StringIO, BytesIO
|
||||
from io import BytesIO, StringIO
|
||||
from pathlib import Path
|
||||
|
||||
from django.contrib.auth.models import Permission
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.management import call_command
|
||||
from django.conf import settings
|
||||
from django.db import connection
|
||||
from django.contrib.auth.models import Permission
|
||||
from django.contrib.sites.models import Site
|
||||
from django.core.management import call_command
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.db import connection
|
||||
from django.utils import timezone
|
||||
|
||||
from PIL import Image
|
||||
|
||||
from core.models import Group, User, Page, PageRev, SithFile
|
||||
from accounting.models import (
|
||||
GeneralJournal,
|
||||
AccountingType,
|
||||
BankAccount,
|
||||
ClubAccount,
|
||||
Operation,
|
||||
AccountingType,
|
||||
SimplifiedAccountingType,
|
||||
Company,
|
||||
GeneralJournal,
|
||||
Operation,
|
||||
SimplifiedAccountingType,
|
||||
)
|
||||
from core.utils import resize_image
|
||||
from club.models import Club, Membership
|
||||
from subscription.models import Subscription
|
||||
from counter.models import Customer, ProductType, Product, Counter, Selling, StudentCard
|
||||
from com.models import Sith, Weekmail, News, NewsDate
|
||||
from election.models import Election, Role, Candidature, ElectionList
|
||||
from com.models import News, NewsDate, Sith, Weekmail
|
||||
from core.models import Group, Page, PageRev, SithFile, User
|
||||
from core.utils import resize_image
|
||||
from counter.models import Counter, Customer, Product, ProductType, Selling, StudentCard
|
||||
from election.models import Candidature, Election, ElectionList, Role
|
||||
from forum.models import Forum, ForumTopic
|
||||
from pedagogy.models import UV
|
||||
from sas.models import Album, Picture, PeoplePictureRelation
|
||||
from sas.models import Album, PeoplePictureRelation, Picture
|
||||
from subscription.models import Subscription
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
@ -23,8 +23,8 @@
|
||||
#
|
||||
|
||||
import os
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.management import call_command
|
||||
|
||||
from core.models import SithFile
|
||||
|
||||
|
@ -1,22 +1,27 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
import os
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from django.core.management import call_command
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
@ -1,23 +1,28 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
import os
|
||||
import re
|
||||
from mistune import Renderer, InlineGrammar, InlineLexer, Markdown, escape, escape_link
|
||||
|
||||
from django.urls import reverse
|
||||
from mistune import InlineGrammar, InlineLexer, Markdown, Renderer, escape, escape_link
|
||||
|
||||
|
||||
class SithRenderer(Renderer):
|
||||
|
@ -1,27 +1,32 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# You can find the source code of the website at https://github.com/ae-utbm/sith3
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
import importlib
|
||||
import threading
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils.functional import SimpleLazyObject
|
||||
from django.contrib.auth import get_user
|
||||
from django.contrib.auth.middleware import (
|
||||
AuthenticationMiddleware as DjangoAuthenticationMiddleware,
|
||||
)
|
||||
from django.utils.functional import SimpleLazyObject
|
||||
|
||||
module, klass = settings.AUTH_ANONYMOUS_MODEL.rsplit(".", 1)
|
||||
AnonymousUser = getattr(importlib.import_module(module), klass)
|
||||
|
@ -1,14 +1,14 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.contrib.auth.models
|
||||
import django.db.models.deletion
|
||||
import django.core.validators
|
||||
import core.models
|
||||
import django.db.models.deletion
|
||||
import phonenumber_field.modelfields
|
||||
from django.conf import settings
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
import core.models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,8 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.core.validators
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,8 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,9 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.conf import settings
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,8 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
import core.models
|
||||
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.utils.timezone
|
||||
from django.db import migrations, models
|
||||
|
||||
import core.models
|
||||
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.conf import settings
|
||||
import django.utils.timezone
|
||||
import django.db.models.deletion
|
||||
import django.utils.timezone
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,9 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.conf import settings
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,9 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.conf import settings
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,8 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.core.validators
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,9 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.conf import settings
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,8 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.core.validators
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.conf import settings
|
||||
import django.utils.timezone
|
||||
import django.db.models.deletion
|
||||
import django.utils.timezone
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,9 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import core.models
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
import core.models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,8 +1,8 @@
|
||||
# Generated by Django 2.2.6 on 2019-11-14 15:10
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -1,58 +1,56 @@
|
||||
# -*- coding:utf-8 -*
|
||||
## -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2016,2017,2018
|
||||
# - Skia <skia@libskia.so>
|
||||
# - Sli <antoine@bartuccio.fr>
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||
# http://ae.utbm.fr.
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License a published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
import importlib
|
||||
from typing import Union, Optional, List
|
||||
import os
|
||||
import unicodedata
|
||||
from datetime import date, timedelta
|
||||
from typing import List, Optional, Union
|
||||
|
||||
from django.core.cache import cache
|
||||
from django.core.mail import send_mail
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import (
|
||||
AbstractBaseUser,
|
||||
UserManager,
|
||||
Group as AuthGroup,
|
||||
GroupManager as AuthGroupManager,
|
||||
)
|
||||
from django.contrib.auth.models import (
|
||||
AnonymousUser as AuthAnonymousUser,
|
||||
)
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils import timezone
|
||||
from django.core import validators
|
||||
from django.core.exceptions import ValidationError, PermissionDenied
|
||||
from django.urls import reverse
|
||||
from django.conf import settings
|
||||
from django.db import models, transaction
|
||||
from django.contrib.auth.models import (
|
||||
Group as AuthGroup,
|
||||
)
|
||||
from django.contrib.auth.models import (
|
||||
GroupManager as AuthGroupManager,
|
||||
)
|
||||
from django.contrib.staticfiles.storage import staticfiles_storage
|
||||
from django.utils.html import escape
|
||||
from django.core import validators
|
||||
from django.core.cache import cache
|
||||
from django.core.exceptions import PermissionDenied, ValidationError
|
||||
from django.core.mail import send_mail
|
||||
from django.db import models, transaction
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from django.utils.functional import cached_property
|
||||
|
||||
import os
|
||||
from core import utils
|
||||
|
||||
from django.utils.html import escape
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from phonenumber_field.modelfields import PhoneNumberField
|
||||
|
||||
from datetime import timedelta, date
|
||||
|
||||
import unicodedata
|
||||
from core import utils
|
||||
|
||||
|
||||
class RealGroupManager(AuthGroupManager):
|
||||
@ -698,9 +696,11 @@ class User(AbstractBaseUser):
|
||||
<em>%s</em>
|
||||
</a>
|
||||
""" % (
|
||||
self.profile_pict.get_download_url()
|
||||
if self.profile_pict
|
||||
else staticfiles_storage.url("core/img/unknown.jpg"),
|
||||
(
|
||||
self.profile_pict.get_download_url()
|
||||
if self.profile_pict
|
||||
else staticfiles_storage.url("core/img/unknown.jpg")
|
||||
),
|
||||
_("Profile"),
|
||||
escape(self.get_display_name()),
|
||||
)
|
||||
|
@ -1,31 +1,27 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2016,2017
|
||||
# - Sli <antoine@bartuccio.fr>
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||
# http://ae.utbm.fr.
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License a published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
"""
|
||||
This page is useful for custom migration tricks.
|
||||
Sometimes, when you need to have a migration hack and you think it can be
|
||||
useful again, put it there, we never know if we might need the hack again.
|
||||
This page is useful for custom migration tricks.
|
||||
Sometimes, when you need to have a migration hack and you think it can be
|
||||
useful again, put it there, we never know if we might need the hack again.
|
||||
"""
|
||||
|
||||
from django.db import connection, migrations
|
||||
|
@ -1,30 +1,27 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2016,2017
|
||||
# - Sli <antoine@bartuccio.fr>
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||
# http://ae.utbm.fr.
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License a published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
import os
|
||||
from collections import OrderedDict
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.staticfiles.finders import FileSystemFinder
|
||||
from django.core.files.storage import FileSystemStorage
|
||||
|
@ -1,35 +1,33 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2017
|
||||
# - Sli <antoine@bartuccio.fr>
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||
# http://ae.utbm.fr.
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License a published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
import os
|
||||
import sass
|
||||
from urllib.parse import urljoin
|
||||
from django.utils.encoding import force_bytes, iri_to_uri
|
||||
|
||||
import sass
|
||||
from django.conf import settings
|
||||
from django.core.files.base import ContentFile
|
||||
from django.templatetags.static import static
|
||||
from django.conf import settings
|
||||
from django.utils.encoding import force_bytes, iri_to_uri
|
||||
|
||||
from core.scss.storage import ScssFileStorage, find_file
|
||||
|
||||
|
||||
|
@ -1,26 +1,22 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2017
|
||||
# - Sli <antoine@bartuccio.fr>
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||
# http://ae.utbm.fr.
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License a published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
from django.conf import settings
|
||||
|
@ -1,30 +1,24 @@
|
||||
# -*- coding:utf-8 -*
|
||||
# -*- coding:utf-8 -*-
|
||||
#
|
||||
# Copyright 2016,2017
|
||||
# - Skia <skia@libskia.so>
|
||||
# - Sli <antoine@bartuccio.fr>
|
||||
# Copyright 2023 © AE UTBM
|
||||
# ae@utbm.fr / ae.info@utbm.fr
|
||||
# All contributors are listed in the CONTRIBUTORS file.
|
||||
#
|
||||
# Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM,
|
||||
# http://ae.utbm.fr.
|
||||
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
||||
# https://ae.utbm.fr.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the GNU General Public License a published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# this program; if not, write to the Free Sofware Foundation, Inc., 59 Temple
|
||||
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
||||
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
||||
#
|
||||
|
||||
from django.db import models
|
||||
|
||||
from haystack import indexes, signals
|
||||
|
||||
from core.models import User
|
||||
|
@ -8,10 +8,10 @@ from core.models import User
|
||||
@receiver(m2m_changed, sender=User.groups.through, dispatch_uid="user_groups_changed")
|
||||
def user_groups_changed(sender, instance: User, **kwargs):
|
||||
"""
|
||||
Clear the cached clubs of the user
|
||||
Clear the cached groups of the user
|
||||
"""
|
||||
# As a m2m relationship doesn't live within the model
|
||||
# but rather on an intermediary table, there is no
|
||||
# model method to override, meaning we must use
|
||||
# a signal to invalidate the cache when a user is removed from a club
|
||||
cache.delete(f"user_{instance.id}_groups")
|
||||
# a signal to invalidate the cache when a user is removed from a group
|
||||
cache.delete(f"user_{instance.pk}_groups")
|
||||
|
@ -203,11 +203,7 @@
|
||||
<ul class="content">
|
||||
<li><a href="{{ url('core:page', page_name='ae') }}">{% trans %}AE{% endtrans %}</a></li>
|
||||
<li><a href="{{ url('core:page', page_name='clubs') }}">{% trans %}AE's clubs{% endtrans %}</a></li>
|
||||
<li><a href="{{ url('core:page', page_name='bdf') }}">{% trans %}BdF{% endtrans %}</a></li>
|
||||
<li><a href="{{ url('core:page', page_name='bds') }}">{% trans %}BDS{% endtrans %}</a></li>
|
||||
<li><a href="{{ url('core:page', page_name='cetu') }}">{% trans %}CETU{% endtrans %}</a></li>
|
||||
<li><a href="{{ url('core:page', page_name='clubs/doceo') }}">{% trans %}Doceo{% endtrans %}</a></li>
|
||||
<li><a href="{{ url('core:page', page_name='positions') }}">{% trans %}Positions{% endtrans %}</a></li>
|
||||
<li><a href="{{ url('core:page', page_name='utbm-associations') }}">{% trans %}Others UTBM's Associations{% endtrans %}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="menu">
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
{% if user_registered %}
|
||||
{% trans user_name=user_registered.get_display_name() %}Welcome {{ user_name }}!{% endtrans %}<br>
|
||||
{% trans %}You successfully registred and you will soon receive a confirmation mail.{% endtrans %}<br>
|
||||
{% trans %}You successfully registered and you will soon receive a confirmation mail.{% endtrans %}<br>
|
||||
{% trans username=user_registered.username %}Your username is {{ username }}.{% endtrans %}<br>
|
||||
|
||||
{% else %}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user