mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-06-24 19:20:29 +02:00
Compare commits
30 Commits
765625218a
...
migration-
Author | SHA1 | Date | |
---|---|---|---|
bb9f58e497 | |||
201d6b114a | |||
19e77df299 | |||
5fd6ec5668 | |||
10a01c5bc2 | |||
989905ea64 | |||
0218d43a17 | |||
5d30b0e819 | |||
ec759dd3c0 | |||
2eb965291d | |||
7f182ee2ee | |||
3132aa4c38 | |||
c7eb774859 | |||
32f8d285b3 | |||
050256ea13 | |||
7afd15b1cc | |||
258361f116 | |||
a307530579 | |||
5de930bf40 | |||
f7ebe0e99b | |||
73de6e2176 | |||
201611b105 | |||
40c239e9da | |||
2aaab2b454 | |||
fc088dec86 | |||
2d60f1fd7b | |||
7b48b09329 | |||
ffac940511 | |||
50f98fd5ad | |||
402e19d1ce |
@ -7,23 +7,8 @@ stages:
|
||||
variables:
|
||||
GIT_SUBMODULE_STRATEGY: recursive
|
||||
|
||||
# Debian Bullseye
|
||||
py39-django42:
|
||||
stage: test
|
||||
image: debian:bullseye
|
||||
before_script:
|
||||
- >
|
||||
apt-get update &&
|
||||
apt-get install --no-install-recommends -y
|
||||
python3-django python3-django-crispy-forms
|
||||
python3-django-extensions python3-django-filters python3-django-polymorphic
|
||||
python3-djangorestframework python3-django-oauth-toolkit python3-psycopg2 python3-pil
|
||||
python3-babel python3-lockfile python3-pip python3-phonenumbers python3-memcache
|
||||
python3-bs4 python3-setuptools tox texlive-xetex
|
||||
script: tox -e py39-django42
|
||||
|
||||
# Ubuntu 22.04
|
||||
py310-django42:
|
||||
py310-django50:
|
||||
stage: test
|
||||
image: ubuntu:22.04
|
||||
before_script:
|
||||
@ -37,10 +22,10 @@ py310-django42:
|
||||
python3-djangorestframework python3-django-oauth-toolkit python3-psycopg2 python3-pil
|
||||
python3-babel python3-lockfile python3-pip python3-phonenumbers python3-memcache
|
||||
python3-bs4 python3-setuptools tox texlive-xetex
|
||||
script: tox -e py310-django42
|
||||
script: tox -e py310-django50
|
||||
|
||||
# Debian Bookworm
|
||||
py311-django42:
|
||||
py311-django50:
|
||||
stage: test
|
||||
image: debian:bookworm
|
||||
before_script:
|
||||
@ -52,13 +37,11 @@ py311-django42:
|
||||
python3-djangorestframework python3-django-oauth-toolkit python3-psycopg2 python3-pil
|
||||
python3-babel python3-lockfile python3-pip python3-phonenumbers python3-memcache
|
||||
python3-bs4 python3-setuptools tox texlive-xetex
|
||||
script: tox -e py311-django42
|
||||
|
||||
|
||||
script: tox -e py311-django50
|
||||
|
||||
linters:
|
||||
stage: quality-assurance
|
||||
image: debian:bookworm
|
||||
image: debian:bullseye
|
||||
before_script:
|
||||
- apt-get update && apt-get install -y tox
|
||||
script: tox -e linters
|
||||
|
@ -1,10 +1,11 @@
|
||||
# Copyright (C) 2018-2024 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from bootstrap_datepicker_plus.widgets import DateTimePickerInput
|
||||
|
||||
from datetime import timedelta
|
||||
from random import shuffle
|
||||
|
||||
from bootstrap_datepicker_plus.widgets import DateTimePickerInput
|
||||
from django import forms
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.utils import timezone
|
||||
|
18
apps/activity/migrations/0003_auto_20240323_1422.py
Normal file
18
apps/activity/migrations/0003_auto_20240323_1422.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 2.2.28 on 2024-03-23 13:22
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('activity', '0002_auto_20200904_2341'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='activity',
|
||||
name='description',
|
||||
field=models.TextField(blank=True, default='', verbose_name='description'),
|
||||
),
|
||||
]
|
@ -66,6 +66,8 @@ class Activity(models.Model):
|
||||
|
||||
description = models.TextField(
|
||||
verbose_name=_('description'),
|
||||
blank=True,
|
||||
default="",
|
||||
)
|
||||
|
||||
location = models.CharField(
|
||||
|
@ -17,4 +17,27 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
{% block extrajavascript %}
|
||||
<script>
|
||||
var date_end = document.getElementById("id_date_end");
|
||||
var date_start = document.getElementById("id_date_start");
|
||||
|
||||
function update_date_end (){
|
||||
if(date_end.value=="" || date_end.value<date_start.value){
|
||||
date_end.value = date_start.value;
|
||||
};
|
||||
};
|
||||
|
||||
function update_date_start (){
|
||||
if(date_start.value=="" || date_end.value<date_start.value){
|
||||
date_start.value = date_end.value;
|
||||
};
|
||||
};
|
||||
|
||||
date_start.addEventListener('focusout', update_date_end);
|
||||
date_end.addEventListener('focusout', update_date_start);
|
||||
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
@ -76,6 +76,7 @@ class ActivityListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView
|
||||
context['upcoming'] = ActivityTable(
|
||||
data=upcoming_activities.filter(PermissionBackend.filter_queryset(self.request, Activity, "view")),
|
||||
prefix='upcoming-',
|
||||
order_by='date_start',
|
||||
)
|
||||
|
||||
started_activities = self.get_queryset().filter(open=True, valid=True).distinct().all()
|
||||
|
@ -2,8 +2,7 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from django.conf import settings
|
||||
from django.conf.urls import include
|
||||
from django.urls import re_path
|
||||
from django.urls import include, re_path
|
||||
from rest_framework import routers
|
||||
|
||||
from .views import UserInformationView
|
||||
|
@ -4,6 +4,7 @@
|
||||
import io
|
||||
|
||||
from bootstrap_datepicker_plus.widgets import DatePickerInput
|
||||
from PIL import Image, ImageSequence
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.forms import AuthenticationForm
|
||||
@ -15,7 +16,6 @@ from django.utils.translation import gettext_lazy as _
|
||||
from note.models import NoteSpecial, Alias
|
||||
from note_kfet.inputs import Autocomplete, AmountInput
|
||||
from permission.models import PermissionMask, Role
|
||||
from PIL import Image, ImageSequence
|
||||
|
||||
from .models import Profile, Club, Membership
|
||||
|
||||
|
@ -44,7 +44,7 @@ class TemplateLoggedInTests(TestCase):
|
||||
self.assertRedirects(response, settings.LOGIN_REDIRECT_URL, 302, 302)
|
||||
|
||||
def test_logout(self):
|
||||
response = self.client.get(reverse("logout"))
|
||||
response = self.client.post(reverse("logout"))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_admin_index(self):
|
||||
|
@ -13,7 +13,7 @@ def register_note_urls(router, path):
|
||||
router.register(path + '/note', NotePolymorphicViewSet)
|
||||
router.register(path + '/alias', AliasViewSet)
|
||||
router.register(path + '/trust', TrustViewSet)
|
||||
router.register(path + '/consumer', ConsumerViewSet)
|
||||
router.register(path + '/consumer', ConsumerViewSet, basename="consumer")
|
||||
|
||||
router.register(path + '/transaction/category', TemplateCategoryViewSet)
|
||||
router.register(path + '/transaction/transaction', TransactionViewSet)
|
||||
|
@ -179,19 +179,10 @@ class ConsumerViewSet(ReadOnlyProtectedModelViewSet):
|
||||
# We match first an alias if it is matched without normalization,
|
||||
# then if the normalized pattern matches a normalized alias.
|
||||
queryset = queryset.filter(
|
||||
**{f'name{suffix}': alias_prefix + alias}
|
||||
).union(
|
||||
queryset.filter(
|
||||
Q(**{f'normalized_name{suffix}': alias_prefix + Alias.normalize(alias)})
|
||||
& ~Q(**{f'name{suffix}': alias_prefix + alias})
|
||||
),
|
||||
all=True).union(
|
||||
queryset.filter(
|
||||
Q(**{f'normalized_name{suffix}': alias_prefix + alias.lower()})
|
||||
& ~Q(**{f'normalized_name{suffix}': alias_prefix + Alias.normalize(alias)})
|
||||
& ~Q(**{f'name{suffix}': alias_prefix + alias})
|
||||
),
|
||||
all=True)
|
||||
Q(**{f'name{suffix}': alias_prefix + alias})
|
||||
| Q(**{f'normalized_name{suffix}': alias_prefix + Alias.normalize(alias)})
|
||||
| Q(**{f'normalized_name{suffix}': alias_prefix + alias.lower()})
|
||||
)
|
||||
|
||||
queryset = queryset if settings.DATABASES[queryset.db]["ENGINE"] == 'django.db.backends.postgresql' \
|
||||
else queryset.order_by("name")
|
||||
|
@ -1,5 +1,6 @@
|
||||
# Copyright (C) 2018-2024 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from bootstrap_datepicker_plus.widgets import DateTimePickerInput
|
||||
|
@ -18,6 +18,7 @@ def create_special_notes(apps, schema_editor):
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
('note', '0001_initial'),
|
||||
('logs', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
|
@ -0,0 +1,25 @@
|
||||
# Generated by Django 5.0.7 on 2024-07-11 09:24
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('contenttypes', '0002_remove_content_type_name'),
|
||||
('note', '0006_trust'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='note',
|
||||
name='polymorphic_ctype',
|
||||
field=models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_%(app_label)s.%(class)s_set+', to='contenttypes.contenttype'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='transaction',
|
||||
name='polymorphic_ctype',
|
||||
field=models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_%(app_label)s.%(class)s_set+', to='contenttypes.contenttype'),
|
||||
),
|
||||
]
|
@ -9,7 +9,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
name="{{ widget.name }}"
|
||||
{# Other attributes are loaded #}
|
||||
{% for name, value in widget.attrs.items %}
|
||||
{% if value is not False %}{{ name }}{% if value is not True %}="{{ value|stringformat:'s' }}"{% endif %}{% endif %}
|
||||
{% if value != False %}{{ name }}{% if value != True %}="{{ value|stringformat:'s' }}"{% endif %}{% endif %}
|
||||
{% endfor %}>
|
||||
<div class="input-group-append">
|
||||
<span class="input-group-text">€</span>
|
||||
|
@ -3228,7 +3228,8 @@
|
||||
"name": "Pr\u00e9sident\u00b7e de club",
|
||||
"permissions": [
|
||||
62,
|
||||
142
|
||||
142,
|
||||
135
|
||||
]
|
||||
}
|
||||
},
|
||||
|
@ -44,8 +44,6 @@ class PermissionOAuth2Validator(OAuth2Validator):
|
||||
subset of permissions.
|
||||
"""
|
||||
|
||||
oidc_claim_scope = None # fix breaking change of django-oauth-toolkit 2.0.0
|
||||
|
||||
valid_scopes = set()
|
||||
|
||||
for t in Permission.PERMISSION_TYPES:
|
||||
|
@ -5,7 +5,7 @@ from django import forms
|
||||
from django.contrib.auth.forms import UserCreationForm
|
||||
from django.contrib.auth.models import User
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from member.models import Club
|
||||
# from member.models import Club
|
||||
from note.models import NoteSpecial, Alias
|
||||
from note_kfet.inputs import AmountInput
|
||||
|
||||
@ -116,11 +116,11 @@ class ValidationForm(forms.Form):
|
||||
initial=True,
|
||||
)
|
||||
|
||||
# If the bda exists
|
||||
if Club.objects.filter(name__iexact="bda").exists():
|
||||
# The user can join the bda club at the inscription
|
||||
join_bda = forms.BooleanField(
|
||||
label=_("Join BDA Club"),
|
||||
required=False,
|
||||
initial=True,
|
||||
)
|
||||
# If the bda exists
|
||||
# if Club.objects.filter(name__iexact="bda").exists():
|
||||
# The user can join the bda club at the inscription
|
||||
# join_bda = forms.BooleanField(
|
||||
# label=_("Join BDA Club"),
|
||||
# required=False,
|
||||
# initial=True,
|
||||
# )
|
||||
|
23
apps/treasury/migrations/0008_auto_20240322_0045.py
Normal file
23
apps/treasury/migrations/0008_auto_20240322_0045.py
Normal file
@ -0,0 +1,23 @@
|
||||
# Generated by Django 2.2.28 on 2024-03-21 23:45
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('treasury', '0007_auto_20240311_1549'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='invoice',
|
||||
name='payment_date',
|
||||
field=models.CharField(default='', max_length=255, verbose_name='Payment date'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='invoice',
|
||||
name='quotation',
|
||||
field=models.BooleanField(default=False, verbose_name='Quotation'),
|
||||
),
|
||||
]
|
@ -0,0 +1,19 @@
|
||||
# Generated by Django 5.0.7 on 2024-07-11 09:24
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('note', '0007_alter_note_polymorphic_ctype_and_more'),
|
||||
('treasury', '0008_auto_20240322_0045'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='sogecredit',
|
||||
name='transactions',
|
||||
field=models.ManyToManyField(blank=True, related_name='+', to='note.membershiptransaction', verbose_name='membership transactions'),
|
||||
),
|
||||
]
|
@ -41,6 +41,10 @@ class Invoice(models.Model):
|
||||
),
|
||||
verbose_name=_("BDE"),
|
||||
)
|
||||
quotation = models.BooleanField(
|
||||
default=False,
|
||||
verbose_name=_("Quotation"),
|
||||
)
|
||||
|
||||
object = models.CharField(
|
||||
max_length=255,
|
||||
@ -65,6 +69,12 @@ class Invoice(models.Model):
|
||||
verbose_name=_("Date"),
|
||||
)
|
||||
|
||||
payment_date = models.CharField(
|
||||
default="",
|
||||
max_length=255,
|
||||
verbose_name=_("Payment date"),
|
||||
)
|
||||
|
||||
acquitted = models.BooleanField(
|
||||
verbose_name=_("Acquitted"),
|
||||
default=False,
|
||||
|
@ -76,8 +76,11 @@
|
||||
|
||||
\def\FactureNum {{"{"}}{{ obj.id }}} % Numéro de facture
|
||||
\def\FactureAcquittee {% if obj.acquitted %} {oui} {% else %} {non} {% endif %} % Facture acquittée : oui/non
|
||||
\def\Devis {% if obj.quotation %} {oui} {% else %} {non} {% endif %}
|
||||
% Devis : oui/non
|
||||
\def\FactureLieu {{"{"}}{{ obj.place|escape_tex }}} % Lieu de l'édition de la facture
|
||||
\def\FactureDate {{"{"}}{{ obj.date }}} % Date de l'édition de la facture
|
||||
\def\FacturePaymentDate {{"{"}}{{ obj.payment_date|escape_tex }}} % Date de paiement de la facture
|
||||
\def\FactureObjet {{"{"}}{{ obj.object|escape_tex }} } % Objet du document
|
||||
% Description de la facture
|
||||
\def\FactureDescr {{"{"}}{{ obj.description|escape_tex }}}
|
||||
@ -118,10 +121,12 @@
|
||||
% Nom et adresse de la société
|
||||
\MonNom \\
|
||||
\MonAdresseRue \\
|
||||
\MonAdresseVille
|
||||
|
||||
\MonAdresseVille \\
|
||||
\ifthenelse{\equal{\Devis}{oui}}{
|
||||
Devis n°\FactureNum
|
||||
}{
|
||||
Facture n°\FactureNum
|
||||
|
||||
}
|
||||
|
||||
{\addtolength{\leftskip}{10.5cm} %in ERT
|
||||
\ClientNom \\
|
||||
@ -139,6 +144,7 @@ Facture n°\FactureNum
|
||||
|
||||
\textnormal{\FactureDescr}
|
||||
|
||||
|
||||
~\\
|
||||
|
||||
\begin{center}
|
||||
@ -154,6 +160,11 @@ Facture n°\FactureNum
|
||||
\ifthenelse{\equal{\FactureAcquittee}{oui}}{
|
||||
Facture acquittée.
|
||||
}{
|
||||
Echéance de paiement : \FacturePaymentDate
|
||||
|
||||
Conditions d'escompte : Aucune
|
||||
|
||||
Taux de pénalité en cas de non paiement ou retard de paiement : 0 \%
|
||||
|
||||
À régler par chèque ou par virement bancaire :
|
||||
|
||||
@ -176,5 +187,6 @@ Facture n°\FactureNum
|
||||
TVA non applicable, article 293 B du CGI.
|
||||
\end{center}
|
||||
|
||||
|
||||
\end{document}
|
||||
{% endlanguage %}
|
||||
|
@ -69,9 +69,11 @@ class TestInvoices(TestCase):
|
||||
response = self.client.post(reverse("treasury:invoice_create"), data={
|
||||
"id": 42,
|
||||
"object": "Same object",
|
||||
"quotation": True,
|
||||
"description": "Longer description",
|
||||
"name": "Me and others",
|
||||
"address": "Alwways earth",
|
||||
"payment_date": "Maybe someday...",
|
||||
"acquitted": True,
|
||||
"products-0-designation": "Designation",
|
||||
"products-0-quantity": 1,
|
||||
@ -97,8 +99,10 @@ class TestInvoices(TestCase):
|
||||
"object": "Same object",
|
||||
"description": "Longer description",
|
||||
"name": "Me and others",
|
||||
"quotation": False,
|
||||
"address": "Always earth",
|
||||
"acquitted": True,
|
||||
"payment_date": "Never",
|
||||
"locked": True,
|
||||
"products-0-designation": "Designation",
|
||||
"products-0-quantity": 1,
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -32,12 +32,6 @@ if "oauth2_provider" in settings.INSTALLED_APPS:
|
||||
admin_site.register(AccessToken, AccessTokenAdmin)
|
||||
admin_site.register(RefreshToken, RefreshTokenAdmin)
|
||||
|
||||
if "django_htcpcp_tea" in settings.INSTALLED_APPS:
|
||||
from django_htcpcp_tea.admin import *
|
||||
from django_htcpcp_tea.models import *
|
||||
admin_site.register(Pot, PotAdmin)
|
||||
admin_site.register(TeaType, TeaTypeAdmin)
|
||||
admin_site.register(Addition, AdditionAdmin)
|
||||
|
||||
if "mailer" in settings.INSTALLED_APPS:
|
||||
from mailer.admin import *
|
||||
@ -50,9 +44,3 @@ if "rest_framework" in settings.INSTALLED_APPS:
|
||||
from rest_framework.authtoken.admin import *
|
||||
from rest_framework.authtoken.models import *
|
||||
admin_site.register(Token, TokenAdmin)
|
||||
|
||||
if "cas_server" in settings.INSTALLED_APPS:
|
||||
from cas_server.admin import *
|
||||
from cas_server.models import *
|
||||
admin_site.register(ServicePattern, ServicePatternAdmin)
|
||||
admin_site.register(FederatedIendityProvider, FederatedIendityProviderAdmin)
|
||||
|
@ -4,7 +4,7 @@
|
||||
"pk": 1,
|
||||
"fields": {
|
||||
"domain": "note.crans.org",
|
||||
"name": "La Note Kfet \ud83c\udf7b"
|
||||
"name": "La Note Kfet 🍪"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -68,3 +68,264 @@ class ColorWidget(Widget):
|
||||
def value_from_datadict(self, data, files, name):
|
||||
val = super().value_from_datadict(data, files, name)
|
||||
return int(val[1:], 16)
|
||||
|
||||
|
||||
"""
|
||||
The remaining of this file comes from the project `django-bootstrap-datepicker-plus` available on Github:
|
||||
https://github.com/monim67/django-bootstrap-datepicker-plus
|
||||
This is distributed under Apache License 2.0.
|
||||
|
||||
This adds datetime pickers with bootstrap.
|
||||
"""
|
||||
|
||||
"""Contains Base Date-Picker input class for widgets of this package."""
|
||||
|
||||
|
||||
class DatePickerDictionary:
|
||||
"""Keeps track of all date-picker input classes."""
|
||||
|
||||
_i = 0
|
||||
items = dict()
|
||||
|
||||
@classmethod
|
||||
def generate_id(cls):
|
||||
"""Return a unique ID for each date-picker input class."""
|
||||
cls._i += 1
|
||||
return 'dp_%s' % cls._i
|
||||
|
||||
|
||||
class BasePickerInput(DateTimeBaseInput):
|
||||
"""Base Date-Picker input class for widgets of this package."""
|
||||
|
||||
template_name = 'bootstrap_datepicker_plus/date-picker.html'
|
||||
picker_type = 'DATE'
|
||||
format = '%Y-%m-%d'
|
||||
config = {}
|
||||
_default_config = {
|
||||
'id': None,
|
||||
'picker_type': None,
|
||||
'linked_to': None,
|
||||
'options': {} # final merged options
|
||||
}
|
||||
options = {} # options extended by user
|
||||
options_param = {} # options passed as parameter
|
||||
_default_options = {
|
||||
'showClose': True,
|
||||
'showClear': True,
|
||||
'showTodayButton': True,
|
||||
"locale": "fr",
|
||||
}
|
||||
|
||||
# source: https://github.com/tutorcruncher/django-bootstrap3-datetimepicker
|
||||
# file: /blob/31fbb09/bootstrap3_datetime/widgets.py#L33
|
||||
format_map = (
|
||||
('DDD', r'%j'),
|
||||
('DD', r'%d'),
|
||||
('MMMM', r'%B'),
|
||||
('MMM', r'%b'),
|
||||
('MM', r'%m'),
|
||||
('YYYY', r'%Y'),
|
||||
('YY', r'%y'),
|
||||
('HH', r'%H'),
|
||||
('hh', r'%I'),
|
||||
('mm', r'%M'),
|
||||
('ss', r'%S'),
|
||||
('a', r'%p'),
|
||||
('ZZ', r'%z'),
|
||||
)
|
||||
|
||||
class Media:
|
||||
"""JS/CSS resources needed to render the date-picker calendar."""
|
||||
|
||||
js = (
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/'
|
||||
'moment-with-locales.min.js',
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/'
|
||||
'4.17.47/js/bootstrap-datetimepicker.min.js',
|
||||
'bootstrap_datepicker_plus/js/datepicker-widget.js'
|
||||
)
|
||||
css = {'all': (
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/'
|
||||
'4.17.47/css/bootstrap-datetimepicker.css',
|
||||
'bootstrap_datepicker_plus/css/datepicker-widget.css'
|
||||
), }
|
||||
|
||||
@classmethod
|
||||
def format_py2js(cls, datetime_format):
|
||||
"""Convert python datetime format to moment datetime format."""
|
||||
for js_format, py_format in cls.format_map:
|
||||
datetime_format = datetime_format.replace(py_format, js_format)
|
||||
return datetime_format
|
||||
|
||||
@classmethod
|
||||
def format_js2py(cls, datetime_format):
|
||||
"""Convert moment datetime format to python datetime format."""
|
||||
for js_format, py_format in cls.format_map:
|
||||
datetime_format = datetime_format.replace(js_format, py_format)
|
||||
return datetime_format
|
||||
|
||||
def __init__(self, attrs=None, format=None, options=None):
|
||||
"""Initialize the Date-picker widget."""
|
||||
self.format_param = format
|
||||
self.options_param = options if options else {}
|
||||
self.config = self._default_config.copy()
|
||||
self.config['id'] = DatePickerDictionary.generate_id()
|
||||
self.config['picker_type'] = self.picker_type
|
||||
self.config['options'] = self._calculate_options()
|
||||
attrs = attrs if attrs else {}
|
||||
if 'class' not in attrs:
|
||||
attrs['class'] = 'form-control'
|
||||
super().__init__(attrs, self._calculate_format())
|
||||
|
||||
def _calculate_options(self):
|
||||
"""Calculate and Return the options."""
|
||||
_options = self._default_options.copy()
|
||||
_options.update(self.options)
|
||||
if self.options_param:
|
||||
_options.update(self.options_param)
|
||||
return _options
|
||||
|
||||
def _calculate_format(self):
|
||||
"""Calculate and Return the datetime format."""
|
||||
_format = self.format_param if self.format_param else self.format
|
||||
if self.config['options'].get('format'):
|
||||
_format = self.format_js2py(self.config['options'].get('format'))
|
||||
else:
|
||||
self.config['options']['format'] = self.format_py2js(_format)
|
||||
return _format
|
||||
|
||||
def get_context(self, name, value, attrs):
|
||||
"""Return widget context dictionary."""
|
||||
context = super().get_context(
|
||||
name, value, attrs)
|
||||
context['widget']['attrs']['dp_config'] = json_dumps(self.config)
|
||||
return context
|
||||
|
||||
def start_of(self, event_id):
|
||||
"""
|
||||
Set Date-Picker as the start-date of a date-range.
|
||||
|
||||
Args:
|
||||
- event_id (string): User-defined unique id for linking two fields
|
||||
"""
|
||||
DatePickerDictionary.items[str(event_id)] = self
|
||||
return self
|
||||
|
||||
def end_of(self, event_id, import_options=True):
|
||||
"""
|
||||
Set Date-Picker as the end-date of a date-range.
|
||||
|
||||
Args:
|
||||
- event_id (string): User-defined unique id for linking two fields
|
||||
- import_options (bool): inherit options from start-date input,
|
||||
default: TRUE
|
||||
"""
|
||||
event_id = str(event_id)
|
||||
if event_id in DatePickerDictionary.items:
|
||||
linked_picker = DatePickerDictionary.items[event_id]
|
||||
self.config['linked_to'] = linked_picker.config['id']
|
||||
if import_options:
|
||||
backup_moment_format = self.config['options']['format']
|
||||
self.config['options'].update(linked_picker.config['options'])
|
||||
self.config['options'].update(self.options_param)
|
||||
if self.format_param or 'format' in self.options_param:
|
||||
self.config['options']['format'] = backup_moment_format
|
||||
else:
|
||||
self.format = linked_picker.format
|
||||
# Setting useCurrent is necessary, see following issue
|
||||
# https://github.com/Eonasdan/bootstrap-datetimepicker/issues/1075
|
||||
self.config['options']['useCurrent'] = False
|
||||
self._link_to(linked_picker)
|
||||
else:
|
||||
raise KeyError(
|
||||
'start-date not specified for event_id "%s"' % event_id)
|
||||
return self
|
||||
|
||||
def _link_to(self, linked_picker):
|
||||
"""
|
||||
Executed when two date-inputs are linked together.
|
||||
|
||||
This method for sub-classes to override to customize the linking.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class DatePickerInput(BasePickerInput):
|
||||
"""
|
||||
Widget to display a Date-Picker Calendar on a DateField property.
|
||||
|
||||
Args:
|
||||
- attrs (dict): HTML attributes of rendered HTML input
|
||||
- format (string): Python DateTime format eg. "%Y-%m-%d"
|
||||
- options (dict): Options to customize the widget, see README
|
||||
"""
|
||||
|
||||
picker_type = 'DATE'
|
||||
format = '%Y-%m-%d'
|
||||
format_key = 'DATE_INPUT_FORMATS'
|
||||
|
||||
|
||||
class TimePickerInput(BasePickerInput):
|
||||
"""
|
||||
Widget to display a Time-Picker Calendar on a TimeField property.
|
||||
|
||||
Args:
|
||||
- attrs (dict): HTML attributes of rendered HTML input
|
||||
- format (string): Python DateTime format eg. "%Y-%m-%d"
|
||||
- options (dict): Options to customize the widget, see README
|
||||
"""
|
||||
|
||||
picker_type = 'TIME'
|
||||
format = '%H:%M'
|
||||
format_key = 'TIME_INPUT_FORMATS'
|
||||
template_name = 'bootstrap_datepicker_plus/time_picker.html'
|
||||
|
||||
|
||||
class DateTimePickerInput(BasePickerInput):
|
||||
"""
|
||||
Widget to display a DateTime-Picker Calendar on a DateTimeField property.
|
||||
|
||||
Args:
|
||||
- attrs (dict): HTML attributes of rendered HTML input
|
||||
- format (string): Python DateTime format eg. "%Y-%m-%d"
|
||||
- options (dict): Options to customize the widget, see README
|
||||
"""
|
||||
|
||||
picker_type = 'DATETIME'
|
||||
format = '%Y-%m-%d %H:%M'
|
||||
format_key = 'DATETIME_INPUT_FORMATS'
|
||||
|
||||
|
||||
class MonthPickerInput(BasePickerInput):
|
||||
"""
|
||||
Widget to display a Month-Picker Calendar on a DateField property.
|
||||
|
||||
Args:
|
||||
- attrs (dict): HTML attributes of rendered HTML input
|
||||
- format (string): Python DateTime format eg. "%Y-%m-%d"
|
||||
- options (dict): Options to customize the widget, see README
|
||||
"""
|
||||
|
||||
picker_type = 'MONTH'
|
||||
format = '01/%m/%Y'
|
||||
format_key = 'DATE_INPUT_FORMATS'
|
||||
|
||||
|
||||
class YearPickerInput(BasePickerInput):
|
||||
"""
|
||||
Widget to display a Year-Picker Calendar on a DateField property.
|
||||
|
||||
Args:
|
||||
- attrs (dict): HTML attributes of rendered HTML input
|
||||
- format (string): Python DateTime format eg. "%Y-%m-%d"
|
||||
- options (dict): Options to customize the widget, see README
|
||||
"""
|
||||
|
||||
picker_type = 'YEAR'
|
||||
format = '01/01/%Y'
|
||||
format_key = 'DATE_INPUT_FORMATS'
|
||||
|
||||
def _link_to(self, linked_picker):
|
||||
"""Customize the options when linked with other date-time input"""
|
||||
yformat = self.config['options']['format'].replace('-01-01', '-12-31')
|
||||
self.config['options']['format'] = yformat
|
||||
|
@ -40,9 +40,8 @@ INSTALLED_APPS = [
|
||||
# External apps
|
||||
'bootstrap_datepicker_plus',
|
||||
'colorfield',
|
||||
'crispy_bootstrap4',
|
||||
'crispy_forms',
|
||||
# 'django_htcpcp_tea',
|
||||
'crispy_bootstrap4',
|
||||
'django_tables2',
|
||||
'mailer',
|
||||
'phonenumber_field',
|
||||
@ -96,9 +95,6 @@ MIDDLEWARE = [
|
||||
'note_kfet.middlewares.TurbolinksMiddleware',
|
||||
'note_kfet.middlewares.ClacksMiddleware',
|
||||
]
|
||||
if "django_htcpcp_tea" in INSTALLED_APPS:
|
||||
MIDDLEWARE.append('django_htcpcp_tea.middleware.HTCPCPTeaMiddleware')
|
||||
|
||||
|
||||
ROOT_URLCONF = 'note_kfet.urls'
|
||||
|
||||
@ -266,9 +262,6 @@ OAUTH2_PROVIDER = {
|
||||
'REFRESH_TOKEN_EXPIRE_SECONDS': timedelta(days=14),
|
||||
}
|
||||
|
||||
# PKCE (fix a breaking change of django-oauth-toolkit 2.0.0)
|
||||
PKCE_REQUIRED = False
|
||||
|
||||
# Take control on how widget templates are sourced
|
||||
# See https://docs.djangoproject.com/en/2.2/ref/forms/renderers/#templatessetting
|
||||
FORM_RENDERER = 'django.forms.renderers.TemplatesSetting'
|
||||
@ -280,7 +273,6 @@ LOGIN_REDIRECT_URL = '/'
|
||||
SESSION_COOKIE_AGE = 60 * 60 * 3
|
||||
|
||||
# Use Crispy Bootstrap4 theme
|
||||
CRISPY_ALLOWED_TEMPLATE_PACKS = 'bootstrap4'
|
||||
CRISPY_TEMPLATE_PACK = 'bootstrap4'
|
||||
|
||||
# Use Django Table2 Bootstrap4 theme
|
||||
|
@ -8,7 +8,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
{% if widget.value != None and widget.value != "" %}value="{{ widget.value }}"{% endif %}
|
||||
name="{{ widget.name }}_name" autocomplete="off"
|
||||
{% for name, value in widget.attrs.items %}
|
||||
{% if value is not False %}{{ name }}{% if value is not True %}="{{ value|stringformat:'s' }}"{% endif %}{% endif %}
|
||||
{% if value != False %}{{ name }}{% if value != True %}="{{ value|stringformat:'s' }}"{% endif %}{% endif %}
|
||||
{% endfor %}
|
||||
aria-describedby="{{widget.attrs.id}}_tooltip">
|
||||
{% if widget.resetable %}
|
||||
|
@ -126,9 +126,12 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
<a class="dropdown-item" href="{% url 'member:user_detail' pk=request.user.pk %}">
|
||||
<i class="fa fa-user"></i> {% trans "My account" %}
|
||||
</a>
|
||||
<a class="dropdown-item" href="{% url 'logout' %}">
|
||||
<form method="post" action="{% url 'logout' %}">
|
||||
{% csrf_token %}
|
||||
<button class="dropdown-item" type="submit">
|
||||
<i class="fa fa-sign-out"></i> {% trans "Log out" %}
|
||||
</a>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</li>
|
||||
{% else %}
|
||||
@ -194,6 +197,8 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
class="text-muted">{% trans "Contact us" %}</a> —
|
||||
<a href="mailto:{{ "SUPPORT_EMAIL" | getenv }}"
|
||||
class="text-muted">{% trans "Technical Support" %}</a> —
|
||||
<a href="https://perso.crans.org/club-bde/charte_informatique.pdf"
|
||||
class="text-muted">{% trans "Charte Info (FR)" %}</a> —
|
||||
<a href="https://note.crans.org/doc/faq/"
|
||||
class="text-muted">{% trans "FAQ (FR)" %}</a> —
|
||||
</span>
|
||||
|
@ -43,22 +43,12 @@ if "oauth2_provider" in settings.INSTALLED_APPS:
|
||||
path('o/', include('oauth2_provider.urls', namespace='oauth2_provider'))
|
||||
)
|
||||
|
||||
if "cas_server" in settings.INSTALLED_APPS:
|
||||
urlpatterns.append(
|
||||
path('cas/', include('cas_server.urls', namespace='cas_server'))
|
||||
)
|
||||
|
||||
if "debug_toolbar" in settings.INSTALLED_APPS:
|
||||
import debug_toolbar
|
||||
urlpatterns = [
|
||||
path('__debug__/', include(debug_toolbar.urls)),
|
||||
] + urlpatterns
|
||||
|
||||
if "django_htcpcp_tea" in settings.INSTALLED_APPS:
|
||||
# Make coffee
|
||||
urlpatterns.append(
|
||||
path('coffee/', include('django_htcpcp_tea.urls'))
|
||||
)
|
||||
|
||||
handler400 = bad_request
|
||||
handler403 = permission_denied
|
||||
|
@ -1,20 +1,17 @@
|
||||
beautifulsoup4~=4.12.3
|
||||
crispy-bootstrap4~=2023.1
|
||||
Django~=4.2.9
|
||||
crispy-bootstrap4~=2024.1
|
||||
Django~=5.0.7
|
||||
django-bootstrap-datepicker-plus~=5.0.5
|
||||
#django-cas-server~=2.0.0
|
||||
django-colorfield~=0.11.0
|
||||
django-crispy-forms~=2.1.0
|
||||
django-extensions>=3.2.3
|
||||
django-filter~=23.5
|
||||
#django-htcpcp-tea~=0.8.1
|
||||
django-mailer~=2.3.1
|
||||
django-oauth-toolkit~=2.3.0
|
||||
django-phonenumber-field~=7.3.0
|
||||
django-crispy-forms~=2.2
|
||||
django-extensions~=3.2.3
|
||||
django-filter~=24.2
|
||||
django-mailer~=2.3.2
|
||||
django-oauth-toolkit~=2.4.0
|
||||
django-phonenumber-field~=8.0.0
|
||||
django-polymorphic~=3.1.0
|
||||
djangorestframework~=3.14.0
|
||||
django-rest-polymorphic~=0.1.10
|
||||
django-tables2~=2.7.0
|
||||
python-memcached~=1.62
|
||||
phonenumbers~=8.13.28
|
||||
Pillow>=10.2.0
|
||||
djangorestframework~=3.15.2
|
||||
phonenumbers~=8.13.40
|
||||
Pillow>=5.4.1
|
||||
|
Reference in New Issue
Block a user