1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-10-18 11:16:40 +02:00

Compare commits

..

9 Commits

Author SHA1 Message Date
quark
d2cc1b902d allows mask for Oauth2 2025-10-17 17:45:41 +02:00
ehouarn
4c40566513 Merge branch 'small_features' into 'main'
Small features

See merge request bde/nk20!355
2025-10-16 20:25:02 +02:00
Ehouarn
7c45b59298 Fixed treasury test 2025-10-16 20:05:27 +02:00
ehouarn
418268db27 Merge branch 'update_invoice_template' into 'main'
Replace Diolistos_bg.jpg

See merge request bde/nk20!354
2025-10-12 18:49:43 +02:00
ehouarn
73045586a3 Replace Diolistos_bg.jpg 2025-10-12 18:26:39 +02:00
quark
22d668a75c membership date end 2025-10-02 19:11:26 +02:00
quark
5dfa12fad2 update django_polymorphic (3.1 to 3.2) 2025-10-02 18:58:59 +02:00
ehouarn
d4cb464169 Merge branch 'small_features' into 'main'
Export activity guests

See merge request bde/nk20!353
2025-09-28 21:34:21 +02:00
ehouarn
cb3b34f874 Merge branch 'small_features' into 'main'
Small features

See merge request bde/nk20!352
2025-09-27 13:39:34 +02:00
8 changed files with 17 additions and 8 deletions

View File

@@ -417,7 +417,7 @@ class Membership(models.Model):
A membership is valid if today is between the start and the end date.
"""
if self.date_end is not None:
return self.date_start.toordinal() <= datetime.datetime.now().toordinal() < self.date_end.toordinal()
return self.date_start.toordinal() <= datetime.datetime.now().toordinal() <= self.date_end.toordinal()
else:
return self.date_start.toordinal() <= datetime.datetime.now().toordinal()

View File

@@ -228,7 +228,7 @@ function consume (source, source_alias, dest, quantity, amount, reason, type, ca
addMsg(interpolate(gettext('Warning, the transaction from the note %s succeed, ' +
'but the emitter note %s is negative.'), [source_alias, source_alias]), 'warning', 30000)
}
if (source.membership && source.membership.date_end < new Date().toISOString()) {
if (source.membership && source.membership.date_end <= new Date().toISOString()) {
addMsg(interpolate(gettext('Warning, the emitter note %s is no more a BDE member.'), [source_alias]),
'danger', 30000)
}

View File

@@ -310,10 +310,10 @@ $('#btn_transfer').click(function () {
destination: dest.note.id,
destination_alias: dest.name
}).done(function () {
if (source.note.membership && source.note.membership.date_end < new Date().toISOString()) {
if (source.note.membership && source.note.membership.date_end <= new Date().toISOString()) {
addMsg(interpolate(gettext('Warning, the emitter note %s is no more a BDE member.'), [source.name]), 'danger', 30000)
}
if (dest.note.membership && dest.note.membership.date_end < new Date().toISOString()) {
if (dest.note.membership && dest.note.membership.date_end <= new Date().toISOString()) {
addMsg(interpolate(gettext('Warning, the destination note %s is no more a BDE member.'), [dest.name]), 'danger', 30000)
}
@@ -414,7 +414,7 @@ $('#btn_transfer').click(function () {
bank: $('#bank').val()
}).done(function () {
addMsg(gettext('Credit/debit succeed!'), 'success', 10000)
if (user_note.membership && user_note.membership.date_end < new Date().toISOString()) { addMsg(gettext('Warning, the emitter note %s is no more a BDE member.'), 'danger', 10000) }
if (user_note.membership && user_note.membership.date_end <= new Date().toISOString()) { addMsg(gettext('Warning, the emitter note %s is no more a BDE member.'), 'danger', 10000) }
reset()
}).fail(function (err) {
const errObj = JSON.parse(err.responseText)

View File

@@ -39,7 +39,15 @@ class PermissionBackend(ModelBackend):
def permission_filter(membership_obj):
query = Q(pk=-1)
if 'mask' in request.GET:
try:
rank = int(request.GET['mask'])
except:
rank = 42
query &= Q(mask__rank__lte=rank)
for scope in request.auth.scope.split(' '):
if scope == "openid":
continue
permission_id, club_id = scope.split('_')
if int(club_id) == membership_obj.club_id:
query |= Q(pk=permission_id)

View File

@@ -10,6 +10,7 @@ from note_kfet.middlewares import get_current_request
from .backends import PermissionBackend
from .models import Permission
from django.utils.translation import gettext_lazy as _
class PermissionScopes(BaseScopes):
"""
@@ -32,7 +33,7 @@ class PermissionScopes(BaseScopes):
scopes = {f"{p.id}_{club.id}": f"{p.description} (club {club.name})"
for p in Permission.objects.all() for club in Club.objects.all()}
scopes['openid'] = "OpenID Connect"
scopes['openid'] = _("OpenID Connect (username and email)")
return scopes
def get_available_scopes(self, application=None, request=None, *args, **kwargs):

Binary file not shown.

Before

Width:  |  Height:  |  Size: 284 KiB

After

Width:  |  Height:  |  Size: 104 KiB

View File

@@ -359,7 +359,7 @@ class TestSogeCredits(TestCase):
))
self.assertRedirects(response, reverse("treasury:manage_soge_credit", args=(soge_credit.pk,)), 302, 200)
soge_credit.refresh_from_db()
self.assertTrue(soge_credit.valid)
self.assertTrue(soge_credit.valid_legacy)
self.user.note.refresh_from_db()
self.assertEqual(
Transaction.objects.filter(Q(source=self.user.note) | Q(destination=self.user.note)).count(), 3)

View File

@@ -12,7 +12,7 @@ django-filter~=25.1
django-mailer~=2.3.2
django-oauth-toolkit~=3.0.1
django-phonenumber-field~=8.1.0
django-polymorphic~=3.1.0
django-polymorphic~=4.1.0
djangorestframework~=3.16.0
django-rest-polymorphic~=0.1.10
django-tables2~=2.7.5