diff --git a/.gitignore b/.gitignore index f9082403..2372bf46 100644 --- a/.gitignore +++ b/.gitignore @@ -36,8 +36,11 @@ coverage # Local data secrets.py +.env +map.json *.log media/ + # Virtualenv env/ venv/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 291ed490..152da589 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: python:3.6 +image: python:3.8 stages: - test @@ -17,8 +17,13 @@ py37-django22: stage: test script: tox -e py37-django22 +py38-django22: + image: python:3.8 + stage: test + script: tox -e py38-django22 + linters: - image: python:3.6 + image: python:3.8 stage: quality-assurance script: tox -e linters diff --git a/ansible/roles/2-nk20/tasks/main.yml b/ansible/roles/2-nk20/tasks/main.yml index 0c6d0213..2aca0698 100644 --- a/ansible/roles/2-nk20/tasks/main.yml +++ b/ansible/roles/2-nk20/tasks/main.yml @@ -11,11 +11,15 @@ git: repo: https://gitlab.crans.org/bde/nk20.git dest: /var/www/note_kfet - version: beta-soon + version: master force: true - name: Use default env vars (should be updated!) - command: cp /var/www/note_kfet/.env_example /var/www/note_kfet/.env + template: + src: "env_example" + dest: "/var/www/note_kfet/.env" + mode: 0644 + force: false - name: Update permissions for note_kfet dir file: diff --git a/ansible/roles/2-nk20/templates/env_example b/ansible/roles/2-nk20/templates/env_example new file mode 120000 index 00000000..d48f3549 --- /dev/null +++ b/ansible/roles/2-nk20/templates/env_example @@ -0,0 +1 @@ +../../../../.env_example \ No newline at end of file diff --git a/ansible/roles/4-nginx/tasks/main.yml b/ansible/roles/4-nginx/tasks/main.yml index 427fe1df..32fa651a 100644 --- a/ansible/roles/4-nginx/tasks/main.yml +++ b/ansible/roles/4-nginx/tasks/main.yml @@ -15,6 +15,11 @@ group: www-data state: link +- name: Disable default Nginx site + file: + dest: /etc/nginx/sites-enabled/default + state: absent + - name: Copy conf of UWSGI file: src: /var/www/note_kfet/uwsgi_note.ini diff --git a/ansible/roles/4-nginx/templates/nginx_note.conf b/ansible/roles/4-nginx/templates/nginx_note.conf new file mode 100644 index 00000000..9be2d980 --- /dev/null +++ b/ansible/roles/4-nginx/templates/nginx_note.conf @@ -0,0 +1,63 @@ +# the upstream component nginx needs to connect to +upstream note{ + server unix:///var/www/note_kfet/note_kfet.sock; # file socket +} + +# Redirect HTTP to nk20 HTTPS +server { + listen 80 default_server; + listen [::]:80 default_server; + + location / { + return 301 https://nk20-beta.crans.org$request_uri; + } +} + +# Redirect all HTTPS to nk20 HTTPS +server { + listen 443 ssl default_server; + listen [::]:443 ssl default_server; + + location / { + return 301 https://nk20-beta.crans.org$request_uri; + } + + ssl_certificate /etc/letsencrypt/live/nk20-beta.crans.org/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/nk20-beta.crans.org/privkey.pem; + include /etc/letsencrypt/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; +} + +# configuration of the server +server { + listen 443 ssl; + listen [::]:443 ssl; + + # the port your site will be served on + # the domain name it will serve for + server_name nk20-beta.crans.org; # substitute your machine's IP address or FQDN + charset utf-8; + + # max upload size + client_max_body_size 75M; # adjust to taste + + # Django media + location /media { + alias /var/www/note_kfet/media; # your Django project's media files - amend as required + } + + location /static { + alias /var/www/note_kfet/static; # your Django project's static files - amend as required + } + + # Finally, send all non-media requests to the Django server. + location / { + uwsgi_pass note; + include /var/www/note_kfet/uwsgi_params; # the uwsgi_params file you installed + } + + ssl_certificate /etc/letsencrypt/live/nk20-beta.crans.org/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/nk20-beta.crans.org/privkey.pem; + include /etc/letsencrypt/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; +} diff --git a/apps/activity/models.py b/apps/activity/models.py index cab229c4..2c014ca5 100644 --- a/apps/activity/models.py +++ b/apps/activity/models.py @@ -163,7 +163,7 @@ class Entry(models.Model): amount=self.activity.activity_type.guest_entry_fee, reason="Invitation " + self.activity.name + " " + self.guest.first_name + " " + self.guest.last_name, valid=True, - guest=self.guest, + entry=self, ).save() return ret @@ -240,8 +240,8 @@ class Guest(models.Model): class GuestTransaction(Transaction): - guest = models.OneToOneField( - Guest, + entry = models.OneToOneField( + Entry, on_delete=models.PROTECT, ) diff --git a/apps/activity/views.py b/apps/activity/views.py index df3f00ea..cac7f183 100644 --- a/apps/activity/views.py +++ b/apps/activity/views.py @@ -23,6 +23,7 @@ from .tables import ActivityTable, GuestTable, EntryTable class ActivityCreateView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView): model = Activity form_class = ActivityForm + extra_context = {"title": _("Create new activity")} def form_valid(self, form): form.instance.creater = self.request.user @@ -37,12 +38,14 @@ class ActivityListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView model = Activity table_class = ActivityTable ordering = ('-date_start',) + extra_context = {"title": _("Activities")} + + def get_queryset(self): + return super().get_queryset().distinct() def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - context['title'] = _("Activities") - upcoming_activities = Activity.objects.filter(date_end__gt=datetime.now()) context['upcoming'] = ActivityTable( data=upcoming_activities.filter(PermissionBackend.filter_queryset(self.request.user, Activity, "view")), @@ -55,6 +58,7 @@ class ActivityListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView class ActivityDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): model = Activity context_object_name = "activity" + extra_context = {"title": _("Activity detail")} def get_context_data(self, **kwargs): context = super().get_context_data() @@ -71,6 +75,7 @@ class ActivityDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): class ActivityUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView): model = Activity form_class = ActivityForm + extra_context = {"title": _("Update activity")} def get_success_url(self, **kwargs): return reverse_lazy('activity:activity_detail', kwargs={"pk": self.kwargs["pk"]}) @@ -81,6 +86,12 @@ class ActivityInviteView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView): form_class = GuestForm template_name = "activity/activity_invite.html" + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + activity = context["form"].activity + context["title"] = _('Invite guest to the activity "{}"').format(activity.name) + return context + def get_form(self, form_class=None): form = super().get_form(form_class) form.activity = Activity.objects.filter(PermissionBackend.filter_queryset(self.request.user, Activity, "view"))\ diff --git a/apps/api/viewsets.py b/apps/api/viewsets.py index f7532beb..6e0cb6b8 100644 --- a/apps/api/viewsets.py +++ b/apps/api/viewsets.py @@ -14,9 +14,11 @@ class ReadProtectedModelViewSet(viewsets.ModelViewSet): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - model = ContentType.objects.get_for_model(self.serializer_class.Meta.model).model_class() + self.model = ContentType.objects.get_for_model(self.serializer_class.Meta.model).model_class() + + def get_queryset(self): user = get_current_authenticated_user() - self.queryset = model.objects.filter(PermissionBackend.filter_queryset(user, model, "view")) + return self.model.objects.filter(PermissionBackend.filter_queryset(user, self.model, "view")) class ReadOnlyProtectedModelViewSet(viewsets.ReadOnlyModelViewSet): @@ -26,6 +28,8 @@ class ReadOnlyProtectedModelViewSet(viewsets.ReadOnlyModelViewSet): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - model = ContentType.objects.get_for_model(self.serializer_class.Meta.model).model_class() + self.model = ContentType.objects.get_for_model(self.serializer_class.Meta.model).model_class() + + def get_queryset(self): user = get_current_authenticated_user() - self.queryset = model.objects.filter(PermissionBackend.filter_queryset(user, model, "view")) + return self.model.objects.filter(PermissionBackend.filter_queryset(user, self.model, "view")) diff --git a/apps/member/admin.py b/apps/member/admin.py index c7c3ead3..bd29557b 100644 --- a/apps/member/admin.py +++ b/apps/member/admin.py @@ -4,9 +4,12 @@ from django.contrib import admin from django.contrib.auth.admin import UserAdmin from django.contrib.auth.models import User +from django.utils.translation import gettext_lazy as _ +from note.templatetags.pretty_money import pretty_money +from note_kfet.admin import admin_site from .forms import ProfileForm -from .models import Club, Membership, Profile, Role +from .models import Club, Membership, Profile class ProfileInline(admin.StackedInline): @@ -17,6 +20,7 @@ class ProfileInline(admin.StackedInline): can_delete = False +@admin.register(User, site=admin_site) class CustomUserAdmin(UserAdmin): inlines = (ProfileInline,) list_display = ('username', 'email', 'first_name', 'last_name', 'is_staff') @@ -32,11 +36,33 @@ class CustomUserAdmin(UserAdmin): return super().get_inline_instances(request, obj) -# Update Django User with profile -admin.site.unregister(User) -admin.site.register(User, CustomUserAdmin) +@admin.register(Club, site=admin_site) +class ClubAdmin(admin.ModelAdmin): + list_display = ('name', 'parent_club', 'email', 'require_memberships', 'pretty_fee_paid', + 'pretty_fee_unpaid', 'membership_start', 'membership_end',) + ordering = ('name',) + search_fields = ('name', 'email',) -# Add other models -admin.site.register(Club) -admin.site.register(Membership) -admin.site.register(Role) + def pretty_fee_paid(self, obj): + return pretty_money(obj.membership_fee_paid) + + def pretty_fee_unpaid(self, obj): + return pretty_money(obj.membership_fee_unpaid) + + pretty_fee_paid.short_description = _("membership fee (paid students)") + pretty_fee_unpaid.short_description = _("membership fee (unpaid students)") + + +@admin.register(Membership, site=admin_site) +class MembershipAdmin(admin.ModelAdmin): + list_display = ('user', 'club', 'date_start', 'date_end', 'view_roles', 'pretty_fee',) + ordering = ('-date_start', 'club') + + def view_roles(self, obj): + return ", ".join(role.name for role in obj.roles.all()) + + def pretty_fee(self, obj): + return pretty_money(obj.fee) + + view_roles.short_description = _("roles") + pretty_fee.short_description = _("fee") diff --git a/apps/member/api/serializers.py b/apps/member/api/serializers.py index a956a46b..19b2ff67 100644 --- a/apps/member/api/serializers.py +++ b/apps/member/api/serializers.py @@ -3,7 +3,7 @@ from rest_framework import serializers -from ..models import Profile, Club, Role, Membership +from ..models import Profile, Club, Membership class ProfileSerializer(serializers.ModelSerializer): @@ -29,17 +29,6 @@ class ClubSerializer(serializers.ModelSerializer): fields = '__all__' -class RoleSerializer(serializers.ModelSerializer): - """ - REST API Serializer for Roles. - The djangorestframework plugin will analyse the model `Role` and parse all fields in the API. - """ - - class Meta: - model = Role - fields = '__all__' - - class MembershipSerializer(serializers.ModelSerializer): """ REST API Serializer for Memberships. diff --git a/apps/member/api/urls.py b/apps/member/api/urls.py index 15bb83ca..5fa54472 100644 --- a/apps/member/api/urls.py +++ b/apps/member/api/urls.py @@ -1,7 +1,7 @@ # Copyright (C) 2018-2020 by BDE ENS Paris-Saclay # SPDX-License-Identifier: GPL-3.0-or-later -from .views import ProfileViewSet, ClubViewSet, RoleViewSet, MembershipViewSet +from .views import ProfileViewSet, ClubViewSet, MembershipViewSet def register_members_urls(router, path): @@ -10,5 +10,4 @@ def register_members_urls(router, path): """ router.register(path + '/profile', ProfileViewSet) router.register(path + '/club', ClubViewSet) - router.register(path + '/role', RoleViewSet) router.register(path + '/membership', MembershipViewSet) diff --git a/apps/member/api/views.py b/apps/member/api/views.py index 57c216a1..3dc07fe1 100644 --- a/apps/member/api/views.py +++ b/apps/member/api/views.py @@ -4,8 +4,8 @@ from rest_framework.filters import SearchFilter from api.viewsets import ReadProtectedModelViewSet -from .serializers import ProfileSerializer, ClubSerializer, RoleSerializer, MembershipSerializer -from ..models import Profile, Club, Role, Membership +from .serializers import ProfileSerializer, ClubSerializer, MembershipSerializer +from ..models import Profile, Club, Membership class ProfileViewSet(ReadProtectedModelViewSet): @@ -30,18 +30,6 @@ class ClubViewSet(ReadProtectedModelViewSet): search_fields = ['$name', ] -class RoleViewSet(ReadProtectedModelViewSet): - """ - REST API View set. - The djangorestframework plugin will get all `Role` objects, serialize it to JSON with the given serializer, - then render it on /api/members/role/ - """ - queryset = Role.objects.all() - serializer_class = RoleSerializer - filter_backends = [SearchFilter] - search_fields = ['$name', ] - - class MembershipViewSet(ReadProtectedModelViewSet): """ REST API View set. diff --git a/apps/member/forms.py b/apps/member/forms.py index e546d652..50fa9c47 100644 --- a/apps/member/forms.py +++ b/apps/member/forms.py @@ -5,11 +5,11 @@ from django import forms from django.contrib.auth.forms import AuthenticationForm from django.contrib.auth.models import User from django.utils.translation import gettext_lazy as _ -from note.models import NoteSpecial +from note.models import NoteSpecial, Alias from note_kfet.inputs import Autocomplete, AmountInput, DatePickerInput -from permission.models import PermissionMask +from permission.models import PermissionMask, Role -from .models import Profile, Club, Membership, Role +from .models import Profile, Club, Membership class CustomAuthenticationForm(AuthenticationForm): @@ -20,6 +20,18 @@ class CustomAuthenticationForm(AuthenticationForm): ) +class UserForm(forms.ModelForm): + def _get_validation_exclusions(self): + # Django usernames can only contain letters, numbers, @, ., +, - and _. + # We want to allow users to have uncommon and unpractical usernames: + # That is their problem, and we have normalized aliases for us. + return super()._get_validation_exclusions() + ["username"] + + class Meta: + model = User + fields = ('first_name', 'last_name', 'username', 'email',) + + class ProfileForm(forms.ModelForm): """ A form for the extras field provided by the :model:`member.Profile` model. @@ -38,6 +50,15 @@ class ProfileForm(forms.ModelForm): class ClubForm(forms.ModelForm): + def clean(self): + cleaned_data = super().clean() + + if not self.instance.pk: # Creating a club + if Alias.objects.filter(normalized_name=Alias.normalize(self.cleaned_data["name"])).exists(): + self.add_error('name', _("An alias with a similar name already exists.")) + + return cleaned_data + class Meta: model = Club fields = '__all__' @@ -56,8 +77,6 @@ class ClubForm(forms.ModelForm): class MembershipForm(forms.ModelForm): - roles = forms.ModelMultipleChoiceField(queryset=Role.objects.filter(weirole=None).all()) - soge = forms.BooleanField( label=_("Inscription paid by Société Générale"), required=False, @@ -96,7 +115,7 @@ class MembershipForm(forms.ModelForm): class Meta: model = Membership - fields = ('user', 'roles', 'date_start') + fields = ('user', 'date_start') # Le champ d'utilisateur est remplacé par un champ d'auto-complétion. # Quand des lettres sont tapées, une requête est envoyée sur l'API d'auto-complétion # et récupère les noms d'utilisateur valides @@ -112,3 +131,28 @@ class MembershipForm(forms.ModelForm): ), 'date_start': DatePickerInput(), } + + +class MembershipRolesForm(forms.ModelForm): + user = forms.ModelChoiceField( + queryset=User.objects, + label=_("User"), + disabled=True, + widget=Autocomplete( + User, + attrs={ + 'api_url': '/api/user/', + 'name_field': 'username', + 'placeholder': 'Nom ...', + }, + ), + ) + + roles = forms.ModelMultipleChoiceField( + queryset=Role.objects.filter(weirole=None).all(), + label=_("Roles"), + ) + + class Meta: + model = Membership + fields = ('user', 'roles') diff --git a/apps/member/hashers.py b/apps/member/hashers.py index 0c5d010b..f7e4342f 100644 --- a/apps/member/hashers.py +++ b/apps/member/hashers.py @@ -3,8 +3,10 @@ import hashlib +from django.conf import settings from django.contrib.auth.hashers import PBKDF2PasswordHasher from django.utils.crypto import constant_time_compare +from note_kfet.middlewares import get_current_authenticated_user, get_current_session class CustomNK15Hasher(PBKDF2PasswordHasher): @@ -20,8 +22,37 @@ class CustomNK15Hasher(PBKDF2PasswordHasher): """ algorithm = "custom_nk15" + def must_update(self, encoded): + if settings.DEBUG: + current_user = get_current_authenticated_user() + if current_user is not None and current_user.is_superuser: + return False + return True + def verify(self, password, encoded): + if settings.DEBUG: + current_user = get_current_authenticated_user() + if current_user is not None and current_user.is_superuser\ + and get_current_session().get("permission_mask", -1) >= 42: + return True + if '|' in encoded: salt, db_hashed_pass = encoded.split('$')[2].split('|') return constant_time_compare(hashlib.sha256((salt + password).encode("utf-8")).hexdigest(), db_hashed_pass) return super().verify(password, encoded) + + +class DebugSuperuserBackdoor(PBKDF2PasswordHasher): + """ + In debug mode and during the beta, superusers can login into other accounts for tests. + """ + def must_update(self, encoded): + return False + + def verify(self, password, encoded): + if settings.DEBUG: + current_user = get_current_authenticated_user() + if current_user is not None and current_user.is_superuser\ + and get_current_session().get("permission_mask", -1) >= 42: + return True + return super().verify(password, encoded) diff --git a/apps/member/models.py b/apps/member/models.py index 17b8f044..efd8bf8c 100644 --- a/apps/member/models.py +++ b/apps/member/models.py @@ -131,7 +131,7 @@ class Profile(models.Model): return reverse('user_detail', args=(self.pk,)) def send_email_validation_link(self): - subject = "Activate your Note Kfet account" + subject = _("Activate your Note Kfet account") message = loader.render_to_string('registration/mails/email_validation_email.html', { 'user': self.user, @@ -247,24 +247,6 @@ class Club(models.Model): return reverse_lazy('member:club_detail', args=(self.pk,)) -class Role(models.Model): - """ - Role that an :model:`auth.User` can have in a :model:`member.Club` - """ - name = models.CharField( - verbose_name=_('name'), - max_length=255, - unique=True, - ) - - class Meta: - verbose_name = _('role') - verbose_name_plural = _('roles') - - def __str__(self): - return str(self.name) - - class Membership(models.Model): """ Register the membership of a user to a club, including roles and membership duration. @@ -284,7 +266,7 @@ class Membership(models.Model): ) roles = models.ManyToManyField( - Role, + "permission.Role", verbose_name=_("roles"), ) @@ -302,6 +284,7 @@ class Membership(models.Model): verbose_name=_('fee'), ) + @property def valid(self): """ A membership is valid if today is between the start and the end date. @@ -319,6 +302,14 @@ class Membership(models.Model): if not Membership.objects.filter(user=self.user, club=self.club.parent_club).exists(): raise ValidationError(_('User is not a member of the parent club') + ' ' + self.club.parent_club.name) + if self.pk: + for role in self.roles.all(): + club = role.for_club + if club is not None: + if club.pk != self.club_id: + raise ValidationError(_('The role {role} does not apply to the club {club}.') + .format(role=role.name, club=club.name)) + created = not self.pk if created: if Membership.objects.filter( diff --git a/apps/member/tables.py b/apps/member/tables.py index 0fa01545..1247da00 100644 --- a/apps/member/tables.py +++ b/apps/member/tables.py @@ -131,3 +131,31 @@ class MembershipTable(tables.Table): template_name = 'django_tables2/bootstrap4.html' fields = ('user', 'club', 'date_start', 'date_end', 'roles', 'fee', ) model = Membership + + +class ClubManagerTable(tables.Table): + """ + List managers of a club. + """ + + def render_user(self, value): + # If the user has the right, link the displayed user with the page of its detail. + s = value.username + if PermissionBackend.check_perm(get_current_authenticated_user(), "auth.view_user", value): + s = format_html("{name}", + url=reverse_lazy('member:user_detail', kwargs={"pk": value.pk}), name=s) + + return s + + def render_roles(self, record): + roles = record.roles.all() + return ", ".join(str(role) for role in roles) + + class Meta: + attrs = { + 'class': 'table table-condensed table-striped table-hover', + 'style': 'table-layout: fixed;' + } + template_name = 'django_tables2/bootstrap4.html' + fields = ('user', 'user.first_name', 'user.last_name', 'roles', ) + model = Membership diff --git a/apps/member/urls.py b/apps/member/urls.py index 4be4ceae..359a8846 100644 --- a/apps/member/urls.py +++ b/apps/member/urls.py @@ -16,6 +16,7 @@ urlpatterns = [ path('club//update/', views.ClubUpdateView.as_view(), name="club_update"), path('club//update_pic/', views.ClubPictureUpdateView.as_view(), name="club_update_pic"), path('club//aliases/', views.ClubAliasView.as_view(), name="club_alias"), + path('club//members/', views.ClubMembersListView.as_view(), name="club_members"), path('user/', views.UserListView.as_view(), name="user_list"), path('user//', views.UserDetailView.as_view(), name="user_detail"), diff --git a/apps/member/views.py b/apps/member/views.py index c52522e2..30fbb139 100644 --- a/apps/member/views.py +++ b/apps/member/views.py @@ -6,12 +6,14 @@ from datetime import datetime, timedelta from PIL import Image from django.conf import settings +from django.contrib.auth import logout from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.auth.models import User from django.contrib.auth.views import LoginView from django.db.models import Q from django.shortcuts import redirect from django.urls import reverse_lazy +from django.utils import timezone from django.utils.translation import gettext_lazy as _ from django.views.generic import CreateView, DetailView, UpdateView, TemplateView from django.views.generic.edit import FormMixin @@ -21,12 +23,14 @@ from note.forms import ImageForm from note.models import Alias, NoteUser from note.models.transactions import Transaction, SpecialTransaction from note.tables import HistoryTable, AliasTable +from note_kfet.middlewares import _set_current_user_and_ip from permission.backends import PermissionBackend +from permission.models import Role from permission.views import ProtectQuerysetMixin -from .forms import ProfileForm, ClubForm, MembershipForm, CustomAuthenticationForm -from .models import Club, Membership, Role -from .tables import ClubTable, UserTable, MembershipTable +from .forms import ProfileForm, ClubForm, MembershipForm, CustomAuthenticationForm, UserForm, MembershipRolesForm +from .models import Club, Membership +from .tables import ClubTable, UserTable, MembershipTable, ClubManagerTable class CustomLoginView(LoginView): @@ -36,6 +40,8 @@ class CustomLoginView(LoginView): form_class = CustomAuthenticationForm def form_valid(self, form): + logout(self.request) + _set_current_user_and_ip(form.get_user(), self.request.session, None) self.request.session['permission_mask'] = form.cleaned_data['permission_mask'].rank return super().form_valid(form) @@ -45,9 +51,11 @@ class UserUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView): Update the user information. """ model = User - fields = ['first_name', 'last_name', 'username', 'email'] + form_class = UserForm template_name = 'member/profile_update.html' context_object_name = 'user_object' + extra_context = {"title": _("Update Profile")} + profile_form = ProfileForm def get_context_data(self, **kwargs): @@ -62,7 +70,6 @@ class UserUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView): form.fields['email'].help_text = _("This address must be valid.") context['profile_form'] = self.profile_form(instance=context['user_object'].profile) - context['title'] = _("Update Profile") return context def form_valid(self, form): @@ -101,6 +108,7 @@ class UserUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView): if olduser.email != user.email: # If the user changed her/his email, then it is unvalidated and a confirmation link is sent. user.profile.email_confirmed = False + user.profile.save() user.profile.send_email_validation_link() return super().form_valid(form) @@ -117,6 +125,7 @@ class UserDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): model = User context_object_name = "user_object" template_name = "member/profile_detail.html" + extra_context = {"title": _("Profile detail")} def get_queryset(self, **kwargs): """ @@ -129,7 +138,7 @@ class UserDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): user = context['user_object'] history_list = \ Transaction.objects.all().filter(Q(source=user.note) | Q(destination=user.note))\ - .order_by("-created_at", "-id")\ + .order_by("-created_at")\ .filter(PermissionBackend.filter_queryset(self.request.user, Transaction, "view")) history_table = HistoryTable(history_list, prefix='transaction-') history_table.paginate(per_page=20, page=self.request.GET.get("transaction-page", 1)) @@ -150,12 +159,13 @@ class UserListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView): model = User table_class = UserTable template_name = 'member/user_list.html' + extra_context = {"title": _("Search user")} def get_queryset(self, **kwargs): """ Filter the user list with the given pattern. """ - qs = super().get_queryset().filter(profile__registration_valid=True) + qs = super().get_queryset().distinct().filter(profile__registration_valid=True) if "search" in self.request.GET: pattern = self.request.GET["search"] @@ -175,13 +185,6 @@ class UserListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView): return qs[:20] - def get_context_data(self, **kwargs): - context = super().get_context_data(**kwargs) - - context["title"] = _("Search user") - - return context - class ProfileAliasView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): """ @@ -190,6 +193,7 @@ class ProfileAliasView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): model = User template_name = 'member/profile_alias.html' context_object_name = 'user_object' + extra_context = {"title": _("Note aliases")} def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) @@ -203,6 +207,7 @@ class PictureUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, FormMixin, Det Update profile picture of the user note. """ form_class = ImageForm + extra_context = {"title": _("Update note picture")} def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) @@ -260,6 +265,7 @@ class ManageAuthTokens(LoginRequiredMixin, TemplateView): """ model = Token template_name = "member/manage_auth_tokens.html" + extra_context = {"title": _("Manage auth token")} def get(self, request, *args, **kwargs): if 'regenerate' in request.GET and Token.objects.filter(user=request.user).exists(): @@ -287,6 +293,7 @@ class ClubCreateView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView): model = Club form_class = ClubForm success_url = reverse_lazy('member:club_list') + extra_context = {"title": _("Create new club")} def form_valid(self, form): return super().form_valid(form) @@ -298,12 +305,13 @@ class ClubListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView): """ model = Club table_class = ClubTable + extra_context = {"title": _("Search club")} def get_queryset(self, **kwargs): """ Filter the user list with the given pattern. """ - qs = super().get_queryset().filter() + qs = super().get_queryset().distinct() if "search" in self.request.GET: pattern = self.request.GET["search"] @@ -322,6 +330,7 @@ class ClubDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): """ model = Club context_object_name = "club" + extra_context = {"title": _("Club detail")} def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) @@ -330,9 +339,13 @@ class ClubDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): if PermissionBackend.check_perm(self.request.user, "member.change_club_membership_start", club): club.update_membership_dates() + managers = Membership.objects.filter(club=self.object, roles__name="Bureau de club")\ + .order_by('user__last_name').all() + context["managers"] = ClubManagerTable(data=managers, prefix="managers-") + club_transactions = Transaction.objects.all().filter(Q(source=club.note) | Q(destination=club.note))\ .filter(PermissionBackend.filter_queryset(self.request.user, Transaction, "view"))\ - .order_by('-created_at', '-id') + .order_by('-created_at') history_table = HistoryTable(club_transactions, prefix="history-") history_table.paginate(per_page=20, page=self.request.GET.get('history-page', 1)) context['history_list'] = history_table @@ -342,7 +355,7 @@ class ClubDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): ).filter(PermissionBackend.filter_queryset(self.request.user, Membership, "view")) membership_table = MembershipTable(data=club_member, prefix="membership-") - membership_table.paginate(per_page=20, page=self.request.GET.get('membership-page', 1)) + membership_table.paginate(per_page=5, page=self.request.GET.get('membership-page', 1)) context['member_list'] = membership_table # Check if the user has the right to create a membership, to display the button. @@ -366,6 +379,7 @@ class ClubAliasView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): model = Club template_name = 'member/club_alias.html' context_object_name = 'club' + extra_context = {"title": _("Note aliases")} def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) @@ -382,6 +396,7 @@ class ClubUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView): context_object_name = "club" form_class = ClubForm template_name = "member/club_form.html" + extra_context = {"title": _("Update club")} def get_queryset(self, **kwargs): qs = super().get_queryset(**kwargs) @@ -415,6 +430,7 @@ class ClubAddMemberView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView): model = Membership form_class = MembershipForm template_name = 'member/add_members.html' + extra_context = {"title": _("Add new member to the club")} def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) @@ -425,7 +441,6 @@ class ClubAddMemberView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView): club = Club.objects.filter(PermissionBackend.filter_queryset(self.request.user, Club, "view"))\ .get(pk=self.kwargs["club_pk"], weiclub=None) form.fields['credit_amount'].initial = club.membership_fee_paid - form.fields['roles'].initial = Role.objects.filter(name="Membre de club").all() # If the concerned club is the BDE, then we add the option that Société générale pays the membership. if club.name != "BDE": @@ -444,7 +459,6 @@ class ClubAddMemberView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView): user = old_membership.user form.fields['user'].initial = user form.fields['user'].disabled = True - form.fields['roles'].initial = old_membership.roles.all() form.fields['date_start'].initial = old_membership.date_end + timedelta(days=1) form.fields['credit_amount'].initial = club.membership_fee_paid if user.profile.paid \ else club.membership_fee_unpaid @@ -560,7 +574,7 @@ class ClubAddMemberView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView): form.add_error('bank', _("This field is required.")) return self.form_invalid(form) - SpecialTransaction.objects.create( + transaction = SpecialTransaction( source=credit_type, destination=user.note, quantity=1, @@ -571,9 +585,16 @@ class ClubAddMemberView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView): bank=bank, valid=True, ) + transaction._force_save = True + transaction.save() ret = super().form_valid(form) + member_role = Role.objects.filter(name="Membre de club").all() + form.instance.roles.set(member_role) + form.instance._force_save = True + form.instance.save() + # If Société générale pays, then we assume that this is the BDE membership, and we auto-renew the # Kfet membership. if soge: @@ -595,6 +616,7 @@ class ClubAddMemberView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView): date_start=old_membership.get().date_end + timedelta(days=1) if old_membership.exists() else form.instance.date_start, ) + membership._force_save = True membership._soge = True membership.save() membership.refresh_from_db() @@ -615,8 +637,9 @@ class ClubManageRolesView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView): Manage the roles of a user in a club """ model = Membership - form_class = MembershipForm + form_class = MembershipRolesForm template_name = 'member/add_members.html' + extra_context = {"title": _("Manage roles of an user in the club")} def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) @@ -626,15 +649,61 @@ class ClubManageRolesView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView): def get_form(self, form_class=None): form = super().get_form(form_class) - # We don't create a full membership, we only update one field - form.fields['user'].disabled = True - del form.fields['date_start'] - del form.fields['credit_type'] - del form.fields['credit_amount'] - del form.fields['last_name'] - del form.fields['first_name'] - del form.fields['bank'] + + club = self.object.club + form.fields['roles'].queryset = Role.objects.filter(Q(weirole__isnull=not hasattr(club, 'weiclub')) + & (Q(for_club__isnull=True) | Q(for_club=club))).all() + return form def get_success_url(self): - return reverse_lazy('member:club_detail', kwargs={'pk': self.object.club.id}) + return reverse_lazy('member:user_detail', kwargs={'pk': self.object.user.id}) + + +class ClubMembersListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView): + model = Membership + table_class = MembershipTable + template_name = "member/club_members.html" + extra_context = {"title": _("Members of the club")} + + def get_queryset(self, **kwargs): + qs = super().get_queryset().filter(club_id=self.kwargs["pk"]) + + if 'search' in self.request.GET: + pattern = self.request.GET['search'] + qs = qs.filter( + Q(user__first_name__iregex='^' + pattern) + | Q(user__last_name__iregex='^' + pattern) + | Q(user__note__alias__normalized_name__iregex='^' + Alias.normalize(pattern)) + ) + + only_active = "only_active" not in self.request.GET or self.request.GET["only_active"] != '0' + + if only_active: + qs = qs.filter(date_start__lte=timezone.now().today(), date_end__gte=timezone.now().today()) + + if "roles" in self.request.GET: + if not self.request.GET["roles"]: + return qs.none() + roles_str = self.request.GET["roles"].replace(' ', '').split(',') + roles_int = map(int, roles_str) + qs = qs.filter(roles__in=roles_int) + + qs = qs.order_by('-date_start', 'user__username') + + return qs.distinct() + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + club = Club.objects.filter( + PermissionBackend.filter_queryset(self.request.user, Club, "view") + ).get(pk=self.kwargs["pk"]) + context["club"] = club + + applicable_roles = Role.objects.filter(Q(weirole__isnull=not hasattr(club, 'weiclub')) + & (Q(for_club__isnull=True) | Q(for_club=club))).all() + context["applicable_roles"] = applicable_roles + + context["only_active"] = "only_active" not in self.request.GET or self.request.GET["only_active"] != '0' + + return context diff --git a/apps/note/admin.py b/apps/note/admin.py index dc6470d2..433ef2dc 100644 --- a/apps/note/admin.py +++ b/apps/note/admin.py @@ -5,10 +5,12 @@ from django.contrib import admin from django.utils.translation import gettext_lazy as _ from polymorphic.admin import PolymorphicChildModelAdmin, \ PolymorphicChildModelFilter, PolymorphicParentModelAdmin +from note_kfet.admin import admin_site from .models.notes import Alias, Note, NoteClub, NoteSpecial, NoteUser from .models.transactions import Transaction, TemplateCategory, TransactionTemplate, \ RecurrentTransaction, MembershipTransaction, SpecialTransaction +from .templatetags.pretty_money import pretty_money class AliasInlines(admin.TabularInline): @@ -19,7 +21,7 @@ class AliasInlines(admin.TabularInline): model = Alias -@admin.register(Note) +@admin.register(Note, site=admin_site) class NoteAdmin(PolymorphicParentModelAdmin): """ Parent regrouping all note types as children @@ -36,13 +38,12 @@ class NoteAdmin(PolymorphicParentModelAdmin): # Organize notes by registration date date_hierarchy = 'created_at' - ordering = ['-created_at'] # Search by aliases search_fields = ['alias__name'] -@admin.register(NoteClub) +@admin.register(NoteClub, site=admin_site) class NoteClubAdmin(PolymorphicChildModelAdmin): """ Child for a club note, see NoteAdmin @@ -66,15 +67,27 @@ class NoteClubAdmin(PolymorphicChildModelAdmin): return False -@admin.register(NoteSpecial) +@admin.register(NoteSpecial, site=admin_site) class NoteSpecialAdmin(PolymorphicChildModelAdmin): """ Child for a special note, see NoteAdmin """ readonly_fields = ('balance',) + def has_add_permission(self, request): + """ + A club note should not be manually added + """ + return False -@admin.register(NoteUser) + def has_delete_permission(self, request, obj=None): + """ + A club note should not be manually removed + """ + return False + + +@admin.register(NoteUser, site=admin_site) class NoteUserAdmin(PolymorphicChildModelAdmin): """ Child for an user note, see NoteAdmin @@ -97,16 +110,16 @@ class NoteUserAdmin(PolymorphicChildModelAdmin): return False -@admin.register(Transaction) +@admin.register(Transaction, site=admin_site) class TransactionAdmin(PolymorphicParentModelAdmin): """ Admin customisation for Transaction """ - child_models = (RecurrentTransaction, MembershipTransaction, SpecialTransaction) + child_models = (Transaction, RecurrentTransaction, MembershipTransaction, SpecialTransaction) list_display = ('created_at', 'poly_source', 'poly_destination', 'quantity', 'amount', 'valid') list_filter = ('valid',) - autocomplete_fields = ( + readonly_fields = ( 'source', 'destination', ) @@ -138,27 +151,35 @@ class TransactionAdmin(PolymorphicParentModelAdmin): return [] -@admin.register(MembershipTransaction) +@admin.register(MembershipTransaction, site=admin_site) class MembershipTransactionAdmin(PolymorphicChildModelAdmin): """ Admin customisation for MembershipTransaction """ -@admin.register(SpecialTransaction) +@admin.register(RecurrentTransaction, site=admin_site) +class RecurrentTransactionAdmin(PolymorphicChildModelAdmin): + """ + Admin customisation for RecurrentTransaction + """ + + +@admin.register(SpecialTransaction, site=admin_site) class SpecialTransactionAdmin(PolymorphicChildModelAdmin): """ Admin customisation for SpecialTransaction """ -@admin.register(TransactionTemplate) +@admin.register(TransactionTemplate, site=admin_site) class TransactionTemplateAdmin(admin.ModelAdmin): """ Admin customisation for TransactionTemplate """ - list_display = ('name', 'poly_destination', 'amount', 'category', 'display',) - list_filter = ('category', 'display') + list_display = ('name', 'poly_destination', 'pretty_amount', 'category', 'display', 'highlighted',) + list_filter = ('category', 'display', 'highlighted',) + search_fields = ('name', 'destination__club__name', 'amount',) autocomplete_fields = ('destination',) def poly_destination(self, obj): @@ -169,11 +190,15 @@ class TransactionTemplateAdmin(admin.ModelAdmin): poly_destination.short_description = _('destination') + def pretty_amount(self, obj): + return pretty_money(obj.amount) -@admin.register(TemplateCategory) + pretty_amount.short_description = _("amount") + + +@admin.register(TemplateCategory, site=admin_site) class TemplateCategoryAdmin(admin.ModelAdmin): """ Admin customisation for TransactionTemplate """ list_display = ('name',) - list_filter = ('name',) diff --git a/apps/note/api/serializers.py b/apps/note/api/serializers.py index c61ccd42..bcf0bdf5 100644 --- a/apps/note/api/serializers.py +++ b/apps/note/api/serializers.py @@ -118,9 +118,8 @@ class ConsumerSerializer(serializers.ModelSerializer): """ # If the user has no right to see the note, then we only display the note identifier if PermissionBackend.check_perm(get_current_authenticated_user(), "note.view_note", obj.note): - print(obj.pk) return NotePolymorphicSerializer().to_representation(obj.note) - return dict(id=obj.id) + return dict(id=obj.note.id, name=str(obj.note)) def get_email_confirmed(self, obj): if isinstance(obj.note, NoteUser): diff --git a/apps/note/api/views.py b/apps/note/api/views.py index d5ad8129..a365c343 100644 --- a/apps/note/api/views.py +++ b/apps/note/api/views.py @@ -109,7 +109,8 @@ class ConsumerViewSet(ReadOnlyProtectedModelViewSet): queryset = queryset.filter( Q(name__regex="^" + alias) | Q(normalized_name__regex="^" + Alias.normalize(alias)) - | Q(normalized_name__regex="^" + alias.lower())) + | Q(normalized_name__regex="^" + alias.lower()))\ + .order_by('name').prefetch_related('note') return queryset diff --git a/apps/note/models/transactions.py b/apps/note/models/transactions.py index a8fb3c22..f504d8e1 100644 --- a/apps/note/models/transactions.py +++ b/apps/note/models/transactions.py @@ -62,6 +62,7 @@ class TransactionTemplate(models.Model): category = models.ForeignKey( TemplateCategory, on_delete=models.PROTECT, + related_name='templates', verbose_name=_('type'), max_length=31, ) @@ -71,6 +72,11 @@ class TransactionTemplate(models.Model): verbose_name=_("display"), ) + highlighted = models.BooleanField( + default=False, + verbose_name=_("highlighted"), + ) + description = models.CharField( verbose_name=_('description'), max_length=255, @@ -202,7 +208,9 @@ class Transaction(PolymorphicModel): super().save(*args, **kwargs) # Save notes + self.source._force_save = True self.source.save() + self.destination._force_save = True self.destination.save() def delete(self, **kwargs): diff --git a/apps/note/tables.py b/apps/note/tables.py index a1385abc..0048a0a5 100644 --- a/apps/note/tables.py +++ b/apps/note/tables.py @@ -8,6 +8,8 @@ from django.db.models import F from django.utils.html import format_html from django_tables2.utils import A from django.utils.translation import gettext_lazy as _ +from note_kfet.middlewares import get_current_authenticated_user +from permission.backends import PermissionBackend from .models.notes import Alias from .models.transactions import Transaction, TransactionTemplate @@ -52,14 +54,26 @@ class HistoryTable(tables.Table): attrs={ "td": { "id": lambda record: "validate_" + str(record.id), - "class": lambda record: str(record.valid).lower() + ' validate', + "class": lambda record: + str(record.valid).lower() + + (' validate' if PermissionBackend.check_perm(get_current_authenticated_user(), + "note.change_transaction_invalidity_reason", + record) else ''), "data-toggle": "tooltip", - "title": lambda record: _("Click to invalidate") if record.valid else _("Click to validate"), - "onclick": lambda record: 'de_validate(' + str(record.id) + ', ' + str(record.valid).lower() + ')', + "title": lambda record: (_("Click to invalidate") if record.valid else _("Click to validate")) + if PermissionBackend.check_perm(get_current_authenticated_user(), + "note.change_transaction_invalidity_reason", record) else None, + "onclick": lambda record: 'de_validate(' + str(record.id) + ', ' + str(record.valid).lower() + ')' + if PermissionBackend.check_perm(get_current_authenticated_user(), + "note.change_transaction_invalidity_reason", record) else None, "onmouseover": lambda record: '$("#invalidity_reason_' + str(record.id) + '").show();$("#invalidity_reason_' - + str(record.id) + '").focus();', - "onmouseout": lambda record: '$("#invalidity_reason_' + str(record.id) + '").hide()', + + str(record.id) + '").focus();' + if PermissionBackend.check_perm(get_current_authenticated_user(), + "note.change_transaction_invalidity_reason", record) else None, + "onmouseout": lambda record: '$("#invalidity_reason_' + str(record.id) + '").hide()' + if PermissionBackend.check_perm(get_current_authenticated_user(), + "note.change_transaction_invalidity_reason", record) else None, } } ) @@ -88,6 +102,10 @@ class HistoryTable(tables.Table): When the validation status is hovered, an input field is displayed to let the user specify an invalidity reason """ val = "✔" if value else "✖" + if not PermissionBackend\ + .check_perm(get_current_authenticated_user(), "note.change_transaction_invalidity_reason", record): + return val + val += " timezone.now().date() or membership.date_end < timezone.now().date(): + continue + perm.membership = membership + perms.append(perm) + return perms @staticmethod def permissions(user, model, type): @@ -67,22 +58,13 @@ class PermissionBackend(ModelBackend): :param type: The type of the permissions: view, change, add or delete :return: A generator of the requested permissions """ - clubs = {} - memberships = {} for permission in PermissionBackend.get_raw_permissions(user, type): - if not isinstance(model.model_class()(), permission.model.model_class()) or not permission.club: + if not isinstance(model.model_class()(), permission.model.model_class()) or not permission.membership: continue - if permission.club not in clubs: - clubs[permission.club] = club = Club.objects.get(pk=permission.club) - else: - club = clubs[permission.club] - - if permission.membership not in memberships: - memberships[permission.membership] = membership = Membership.objects.get(pk=permission.membership) - else: - membership = memberships[permission.membership] + membership = permission.membership + club = membership.club permission = permission.about( user=user, @@ -113,12 +95,11 @@ class PermissionBackend(ModelBackend): :param field: The field of the model to test, if concerned :return: A query that corresponds to the filter to give to a queryset """ - if user is None or isinstance(user, AnonymousUser): # Anonymous users can't do anything return Q(pk=-1) - if user.is_superuser and get_current_session().get("permission_mask", 42) >= 42: + if user.is_superuser and get_current_session().get("permission_mask", -1) >= 42: # Superusers have all rights return Q() @@ -154,7 +135,7 @@ class PermissionBackend(ModelBackend): if sess is not None and sess.session_key is None: return False - if user_obj.is_superuser and get_current_session().get("permission_mask", 42) >= 42: + if user_obj.is_superuser and sess.get("permission_mask", -1) >= 42: return True if obj is None: @@ -163,6 +144,7 @@ class PermissionBackend(ModelBackend): perm = perm.split('.')[-1].split('_', 2) perm_type = perm[0] perm_field = perm[2] if len(perm) == 3 else None + ct = ContentType.objects.get_for_model(obj) if any(permission.applies(obj, perm_type, perm_field) for permission in PermissionBackend.permissions(user_obj, ct, perm_type)): diff --git a/apps/permission/decorators.py b/apps/permission/decorators.py index f144935a..8963cb0b 100644 --- a/apps/permission/decorators.py +++ b/apps/permission/decorators.py @@ -4,6 +4,7 @@ from functools import lru_cache from time import time +from django.conf import settings from django.contrib.sessions.models import Session from note_kfet.middlewares import get_current_session @@ -32,6 +33,10 @@ def memoize(f): sess_funs = new_sess_funs def func(*args, **kwargs): + if settings.DEBUG: + # Don't memoize in DEBUG mode + return f(*args, **kwargs) + nonlocal last_collect if time() - last_collect > 60: diff --git a/apps/permission/fixtures/initial.json b/apps/permission/fixtures/initial.json index 25509b56..5a3001da 100644 --- a/apps/permission/fixtures/initial.json +++ b/apps/permission/fixtures/initial.json @@ -1,165 +1,4 @@ [ - { - "model": "member.role", - "pk": 1, - "fields": { - "name": "Adh\u00e9rent BDE" - } - }, - { - "model": "member.role", - "pk": 2, - "fields": { - "name": "Adh\u00e9rent Kfet" - } - }, - { - "model": "member.role", - "pk": 3, - "fields": { - "name": "Membre de club" - } - }, - { - "model": "member.role", - "pk": 4, - "fields": { - "name": "Bureau de club" - } - }, - { - "model": "member.role", - "pk": 5, - "fields": { - "name": "Pr\u00e9sident\u00b7e de club" - } - }, - { - "model": "member.role", - "pk": 6, - "fields": { - "name": "Tr\u00e9sorier\u00b7\u00e8re de club" - } - }, - { - "model": "member.role", - "pk": 7, - "fields": { - "name": "Pr\u00e9sident\u00b7e BDE" - } - }, - { - "model": "member.role", - "pk": 8, - "fields": { - "name": "Tr\u00e9sorier\u00b7\u00e8re BDE" - } - }, - { - "model": "member.role", - "pk": 9, - "fields": { - "name": "Respo info" - } - }, - { - "model": "member.role", - "pk": 10, - "fields": { - "name": "GC Kfet" - } - }, - { - "model": "member.role", - "pk": 11, - "fields": { - "name": "Res[pot]" - } - }, - { - "model": "member.role", - "pk": 12, - "fields": { - "name": "GC WEI" - } - }, - { - "model": "member.role", - "pk": 13, - "fields": { - "name": "Chef de bus" - } - }, - { - "model": "member.role", - "pk": 14, - "fields": { - "name": "Chef d'\u00e9quipe" - } - }, - { - "model": "member.role", - "pk": 15, - "fields": { - "name": "\u00c9lectron libre" - } - }, - { - "model": "member.role", - "pk": 16, - "fields": { - "name": "\u00c9lectron libre (avec perm)" - } - }, - { - "model": "member.role", - "pk": 17, - "fields": { - "name": "1A" - } - }, - { - "model": "member.role", - "pk": 18, - "fields": { - "name": "Adhérent WEI" - } - }, - { - "model": "wei.weirole", - "pk": 12, - "fields": {} - }, - { - "model": "wei.weirole", - "pk": 13, - "fields": {} - }, - { - "model": "wei.weirole", - "pk": 14, - "fields": {} - }, - { - "model": "wei.weirole", - "pk": 15, - "fields": {} - }, - { - "model": "wei.weirole", - "pk": 16, - "fields": {} - }, - { - "model": "wei.weirole", - "pk": 17, - "fields": {} - }, - { - "model": "wei.weirole", - "pk": 18, - "fields": {} - }, { "model": "permission.permissionmask", "pk": 1, @@ -197,7 +36,7 @@ "mask": 1, "field": "", "permanent": true, - "description": "View our User object" + "description": "Voir son compte utilisateur" } }, { @@ -213,7 +52,7 @@ "mask": 1, "field": "", "permanent": true, - "description": "View our profile" + "description": "Voir son profil" } }, { @@ -229,7 +68,7 @@ "mask": 1, "field": "", "permanent": true, - "description": "View our own note" + "description": "Vioir sa propre note d'utilisateur" } }, { @@ -245,7 +84,7 @@ "mask": 1, "field": "", "permanent": true, - "description": "View our API token" + "description": "Voir son jeton d'authentification à l'API" } }, { @@ -261,7 +100,7 @@ "mask": 1, "field": "", "permanent": true, - "description": "View our own transactions" + "description": "Voir ses propres transactions" } }, { @@ -272,12 +111,12 @@ "note", "alias" ], - "query": "[\"AND\", [\"OR\", {\"note__in\": [\"NoteUser\", \"objects\", [\"filter\", {\"user__memberships__club__name\": \"Kfet\"}], [\"all\"]]}, {\"note__in\": [\"NoteClub\", \"objects\", [\"all\"]]}], {\"note__is_active\": true}]", + "query": "[\"AND\", [\"OR\", {\"note__noteuser__user__memberships__club__name\": \"Kfet\", \"note__noteuser__user__memberships__date_start__lte\": [\"today\"], \"note__noteuser__user__memberships__date_end__gte\": [\"today\"]}, {\"note__noteclub__isnull\": false}], {\"note__is_active\": true}]", "type": "view", "mask": 1, "field": "", "permanent": true, - "description": "View aliases of clubs and members of Kfet club" + "description": "Voir les aliases des notes des clubs et des adhérents du club Kfet" } }, { @@ -292,8 +131,8 @@ "type": "change", "mask": 1, "field": "last_login", - "permanent": false, - "description": "Change myself's last login" + "permanent": true, + "description": "Modifier sa propre date de dernière connexion" } }, { @@ -309,7 +148,7 @@ "mask": 1, "field": "username", "permanent": true, - "description": "Change myself's username" + "description": "Changer son propre pseudo" } }, { @@ -325,7 +164,7 @@ "mask": 1, "field": "first_name", "permanent": true, - "description": "Change myself's first name" + "description": "Changer son propre prénom" } }, { @@ -341,7 +180,7 @@ "mask": 1, "field": "last_name", "permanent": true, - "description": "Change myself's last name" + "description": "Changer son propre nom de famille" } }, { @@ -357,7 +196,7 @@ "mask": 1, "field": "email", "permanent": true, - "description": "Change myself's email" + "description": "Changer sa propre adresse e-mail" } }, { @@ -372,8 +211,8 @@ "type": "delete", "mask": 1, "field": "", - "permanent": false, - "description": "Delete API Token" + "permanent": true, + "description": "Supprimer son jeton d'authentification à l'API" } }, { @@ -389,7 +228,7 @@ "mask": 1, "field": "", "permanent": true, - "description": "Create API Token" + "description": "Créer un jeton d'authentification à l'API" } }, { @@ -405,7 +244,7 @@ "mask": 1, "field": "", "permanent": false, - "description": "Remove alias" + "description": "Supprimer un alias à sa note" } }, { @@ -421,7 +260,7 @@ "mask": 1, "field": "", "permanent": false, - "description": "Add alias" + "description": "Ajouter un alias à sa note" } }, { @@ -437,7 +276,7 @@ "mask": 1, "field": "display_image", "permanent": false, - "description": "Change myself's display image" + "description": "Changer l'image de sa note" } }, { @@ -453,23 +292,7 @@ "mask": 1, "field": "", "permanent": false, - "description": "Transfer from myself's note" - } - }, - { - "model": "permission.permission", - "pk": 18, - "fields": { - "model": [ - "note", - "note" - ], - "query": "{}", - "type": "change", - "mask": 1, - "field": "balance", - "permanent": false, - "description": "Update a note balance with a transaction" + "description": "Transférer de l'argent depuis sa propre note en restant positif" } }, { @@ -480,12 +303,12 @@ "note", "note" ], - "query": "[\"OR\", {\"pk\": [\"club\", \"note\", \"pk\"]}, {\"pk__in\": [\"NoteUser\", \"objects\", [\"filter\", {\"user__memberships__club\": [\"club\"]}], [\"all\"]]}]", + "query": "[\"OR\", {\"pk\": [\"club\", \"note\", \"pk\"]}, {\"noteuser__user__memberships__club\": [\"club\"], \"noteuser__user__memberships__date_start__lte\": [\"today\"], \"noteuser__user__memberships__date_end__gte\": [\"today\"]}]", "type": "view", "mask": 2, "field": "", "permanent": false, - "description": "View notes of club members" + "description": "Voir les notes des membres du club" } }, { @@ -501,7 +324,7 @@ "mask": 2, "field": "", "permanent": false, - "description": "Create transactions with a club" + "description": "Créer une transaction de ou vers la note d'un club" } }, { @@ -517,7 +340,7 @@ "mask": 2, "field": "", "permanent": false, - "description": "Create transactions from buttons with a club" + "description": "Créer une transaction en appuyant sur un bouton lié à un club" } }, { @@ -530,10 +353,10 @@ ], "query": "{\"pk\": [\"club\", \"pk\"]}", "type": "view", - "mask": 1, + "mask": 3, "field": "", "permanent": false, - "description": "View club infos" + "description": "Voir les informations d'un club" } }, { @@ -549,7 +372,7 @@ "mask": 1, "field": "valid", "permanent": false, - "description": "Update validation status of a transaction" + "description": "Mettre à jour le statut de validation d'une transaction" } }, { @@ -565,7 +388,7 @@ "mask": 2, "field": "", "permanent": false, - "description": "View all transactions" + "description": "Voir toutes les transactions" } }, { @@ -581,7 +404,7 @@ "mask": 2, "field": "", "permanent": false, - "description": "Display credit/debit interface" + "description": "Afficher l'interface crédit/retrait" } }, { @@ -597,7 +420,7 @@ "mask": 2, "field": "", "permanent": false, - "description": "Create credit/debit transaction" + "description": "Créer un crédit ou un retrait quelconque" } }, { @@ -613,7 +436,7 @@ "mask": 2, "field": "", "permanent": false, - "description": "View button categories" + "description": "Voir toutes les catégories de boutons" } }, { @@ -629,7 +452,7 @@ "mask": 3, "field": "", "permanent": false, - "description": "Change button category" + "description": "Changer une catégorie de boutons" } }, { @@ -645,7 +468,7 @@ "mask": 3, "field": "", "permanent": false, - "description": "Add button category" + "description": "Créer une catégorie de boutons" } }, { @@ -661,7 +484,7 @@ "mask": 2, "field": "", "permanent": false, - "description": "View buttons" + "description": "Voir tous les boutons" } }, { @@ -677,7 +500,7 @@ "mask": 3, "field": "", "permanent": false, - "description": "Add buttons" + "description": "Ajouter un bouton" } }, { @@ -693,7 +516,7 @@ "mask": 3, "field": "", "permanent": false, - "description": "Update buttons" + "description": "Modifier un bouton" } }, { @@ -709,7 +532,7 @@ "mask": 2, "field": "", "permanent": false, - "description": "Create any transaction" + "description": "Créer n'importe quelle transaction" } }, { @@ -725,7 +548,7 @@ "mask": 1, "field": "", "permanent": false, - "description": "View valid activites" + "description": "Voir toutes les activités valides" } }, { @@ -741,7 +564,7 @@ "mask": 1, "field": "", "permanent": false, - "description": "Change our activities" + "description": "Modifier les activités non validées dont on est l'auteur" } }, { @@ -757,7 +580,7 @@ "mask": 1, "field": "", "permanent": false, - "description": "Add activities" + "description": "Proposer des activités" } }, { @@ -773,7 +596,7 @@ "mask": 2, "field": "valid", "permanent": false, - "description": "Validate activities" + "description": "Valider des activités" } }, { @@ -789,7 +612,7 @@ "mask": 2, "field": "open", "permanent": false, - "description": "Open activities" + "description": "Ouvrir des activités" } }, { @@ -805,7 +628,7 @@ "mask": 1, "field": "", "permanent": false, - "description": "Invite people to activities" + "description": "Inviter des personnes à des activités" } }, { @@ -821,7 +644,7 @@ "mask": 1, "field": "", "permanent": false, - "description": "View invited people" + "description": "Voir les personnes qu'on a invitées" } }, { @@ -837,7 +660,7 @@ "mask": 2, "field": "", "permanent": false, - "description": "View all activities" + "description": "Voir toutes les activités" } }, { @@ -853,7 +676,7 @@ "mask": 2, "field": "", "permanent": false, - "description": "View all invited people" + "description": "Voir toutes les personnes invitées" } }, { @@ -864,12 +687,12 @@ "activity", "entry" ], - "query": "{}", + "query": "{\"activity__open\": true}", "type": "add", "mask": 2, "field": "", "permanent": false, - "description": "Manage entries" + "description": "Gérer les entrées d'une activité ouverte" } }, { @@ -885,7 +708,7 @@ "mask": 2, "field": "", "permanent": false, - "description": "Add invitation transactions" + "description": "Créer une transaction d'invitation" } }, { @@ -901,7 +724,7 @@ "mask": 1, "field": "", "permanent": false, - "description": "View invitation transactions" + "description": "Voir toutes les transactions d'invitation" } }, { @@ -917,7 +740,7 @@ "mask": 2, "field": "valid", "permanent": false, - "description": "Validate invitation transactions" + "description": "Valider les transactions d'invitation" } }, { @@ -933,7 +756,7 @@ "mask": 1, "field": "", "permanent": false, - "description": "Update club" + "description": "Modifier un club" } }, { @@ -949,7 +772,7 @@ "mask": 1, "field": "", "permanent": true, - "description": "View our memberships" + "description": "Voir mes adhésions" } }, { @@ -962,10 +785,10 @@ ], "query": "{\"club\": [\"club\"]}", "type": "view", - "mask": 1, + "mask": 3, "field": "", "permanent": false, - "description": "View club's memberships" + "description": "Voir les adhérents du club" } }, { @@ -981,7 +804,7 @@ "mask": 2, "field": "", "permanent": false, - "description": "Add a membership to a club" + "description": "Ajouter un membre à un club" } }, { @@ -994,10 +817,10 @@ ], "query": "{\"club\": [\"club\"]}", "type": "change", - "mask": 2, + "mask": 3, "field": "roles", "permanent": false, - "description": "Update user roles" + "description": "Modifier les rôles d'un adhérent d'un club" } }, { @@ -1013,7 +836,7 @@ "mask": 1, "field": "", "permanent": false, - "description": "Change own profile" + "description": "Modifier son profil" } }, { @@ -1026,10 +849,10 @@ ], "query": "{}", "type": "change", - "mask": 2, + "mask": 3, "field": "", "permanent": false, - "description": "Change any profile" + "description": "Modifier n'importe quel profil" } }, { @@ -1042,10 +865,10 @@ ], "query": "{}", "type": "change", - "mask": 2, + "mask": 3, "field": "", "permanent": false, - "description": "Change any user" + "description": "Modifier n'import quel utilisateur" } }, { @@ -1061,7 +884,7 @@ "mask": 1, "field": "", "permanent": false, - "description": "Add user" + "description": "Ajouter un utilisateur" } }, { @@ -1077,7 +900,7 @@ "mask": 1, "field": "", "permanent": false, - "description": "Add profile" + "description": "Ajouter un profil" } }, { @@ -1090,10 +913,10 @@ ], "query": "{\"profile__registration_valid\": false}", "type": "delete", - "mask": 2, + "mask": 3, "field": "", "permanent": false, - "description": "Delete pre-registered user" + "description": "Supprimer une pré-inscription" } }, { @@ -1106,10 +929,10 @@ ], "query": "{\"registration_valid\": false}", "type": "delete", - "mask": 2, + "mask": 3, "field": "", "permanent": false, - "description": "Delete pre-registered user profile" + "description": "Supprimer le profil d'une pré-inscription" } }, { @@ -1125,7 +948,7 @@ "mask": 2, "field": "", "permanent": false, - "description": "New club button" + "description": "Voir les boutons d'un club" } }, { @@ -1138,10 +961,10 @@ ], "query": "{\"destination\": [\"club\", \"note\"]}", "type": "add", - "mask": 2, + "mask": 3, "field": "", "permanent": false, - "description": "Create club button" + "description": "Créer un bouton d'un club" } }, { @@ -1157,7 +980,7 @@ "mask": 2, "field": "", "permanent": false, - "description": "Update club button" + "description": "Modifier le bouton d'un club" } }, { @@ -1173,7 +996,7 @@ "mask": 1, "field": "", "permanent": false, - "description": "View transactions of a club" + "description": "Voir les transactions d'un club" } }, { @@ -1189,7 +1012,7 @@ "mask": 3, "field": "", "permanent": false, - "description": "View invoices" + "description": "Voir les factures" } }, { @@ -1205,7 +1028,7 @@ "mask": 3, "field": "", "permanent": false, - "description": "Add invoice" + "description": "Ajouter une facture" } }, { @@ -1221,7 +1044,7 @@ "mask": 3, "field": "", "permanent": false, - "description": "Change invoice" + "description": "Modifier une facture" } }, { @@ -1237,7 +1060,7 @@ "mask": 3, "field": "", "permanent": false, - "description": "View products" + "description": "Voir les produits" } }, { @@ -1253,7 +1076,7 @@ "mask": 3, "field": "", "permanent": false, - "description": "Add products" + "description": "Ajouter des produits" } }, { @@ -1269,7 +1092,7 @@ "mask": 3, "field": "", "permanent": false, - "description": "Change product" + "description": "Modifier un produit" } }, { @@ -1285,7 +1108,7 @@ "mask": 3, "field": "", "permanent": false, - "description": "Delete product" + "description": "Supprimer un produit" } }, { @@ -1301,7 +1124,7 @@ "mask": 1, "field": "", "permanent": false, - "description": "Add Soci\u00e9t\u00e9 g\u00e9n\u00e9rale credit" + "description": "Ajouter un crédit de la Soci\u00e9t\u00e9 g\u00e9n\u00e9rale" } }, { @@ -1317,7 +1140,7 @@ "mask": 3, "field": "", "permanent": false, - "description": "View all Soci\u00e9t\u00e9 g\u00e9n\u00e9rale credits" + "description": "Voir tous les crédits de la Soci\u00e9t\u00e9 g\u00e9n\u00e9rale" } }, { @@ -1333,7 +1156,7 @@ "mask": 1, "field": "", "permanent": false, - "description": "Update Soci\u00e9t\u00e9 g\u00e9n\u00e9rale credit" + "description": "Modifier un crédit de la Soci\u00e9t\u00e9 g\u00e9n\u00e9rale" } }, { @@ -1349,7 +1172,7 @@ "mask": 3, "field": "", "permanent": false, - "description": "Delete Soci\u00e9t\u00e9 g\u00e9n\u00e9rale credit" + "description": "Supprimer un crédit de la Soci\u00e9t\u00e9 g\u00e9n\u00e9rale" } }, { @@ -1365,7 +1188,7 @@ "mask": 3, "field": "", "permanent": false, - "description": "Create a WEI" + "description": "Créer un WEI" } }, { @@ -1381,7 +1204,7 @@ "mask": 3, "field": "", "permanent": false, - "description": "Update all WEI" + "description": "Modifier tous les WEI" } }, { @@ -1397,7 +1220,7 @@ "mask": 3, "field": "", "permanent": false, - "description": "Update this WEI" + "description": "Modifier ce WEI" } }, { @@ -1413,7 +1236,7 @@ "mask": 1, "field": "", "permanent": true, - "description": "View my WEI" + "description": "Voir mon WEI" } }, { @@ -1429,7 +1252,7 @@ "mask": 1, "field": "", "permanent": false, - "description": "View last WEI" + "description": "Voir le dernier WEI" } }, { @@ -1445,55 +1268,7 @@ "mask": 1, "field": "", "permanent": false, - "description": "View WEI Roles" - } - }, - { - "model": "permission.permission", - "pk": 80, - "fields": { - "model": [ - "wei", - "weirole" - ], - "query": "{}", - "type": "add", - "mask": 3, - "field": "", - "permanent": false, - "description": "Add WEI Role" - } - }, - { - "model": "permission.permission", - "pk": 81, - "fields": { - "model": [ - "wei", - "weirole" - ], - "query": "{}", - "type": "change", - "mask": 3, - "field": "", - "permanent": false, - "description": "Change WEI Role" - } - }, - { - "model": "permission.permission", - "pk": 82, - "fields": { - "model": [ - "wei", - "weirole" - ], - "query": "{}", - "type": "delete", - "mask": 3, - "field": "", - "permanent": false, - "description": "Delete WEI Role" + "description": "Voir les rôles pour le WEI" } }, { @@ -1509,7 +1284,7 @@ "mask": 1, "field": "", "permanent": false, - "description": "Register myself to the last WEI" + "description": "M'inscrire au dernier WEI" } }, { @@ -1525,7 +1300,7 @@ "mask": 1, "field": "", "permanent": false, - "description": "Register first year members to the last WEI" + "description": "Inscrire un 1A au WEI" } }, { @@ -1541,7 +1316,7 @@ "mask": 1, "field": "", "permanent": false, - "description": "Register anyone to this WEI" + "description": "Inscrire n'importe qui au WEI" } }, { @@ -1557,7 +1332,7 @@ "mask": 1, "field": "", "permanent": false, - "description": "Delete WEI registration" + "description": "Supprimer une inscription WEI" } }, { @@ -1573,7 +1348,7 @@ "mask": 1, "field": "", "permanent": false, - "description": "View my own WEI registration" + "description": "Voir ma propre inscription WEI" } }, { @@ -1589,7 +1364,7 @@ "mask": 1, "field": "", "permanent": true, - "description": "View all WEI Registrations" + "description": "Voir toutes les inscriptions WEI" } }, { @@ -1605,7 +1380,7 @@ "mask": 1, "field": "soge_credit", "permanent": false, - "description": "Update the soge credit field of any WEI Registration" + "description": "Indiquer si une inscription WEI est payée par la Société générale" } }, { @@ -1621,7 +1396,7 @@ "mask": 1, "field": "soge_credit", "permanent": false, - "description": "Update the soge credit field of my own WEI Registration" + "description": "Indiquer si mon inscription WEI est payée par la Société générale tant qu'elle n'est pas validée" } }, { @@ -1637,7 +1412,7 @@ "mask": 1, "field": "caution_check", "permanent": false, - "description": "Update the caution check field of any WEI Registration" + "description": "Dire si un chèque de caution est donné pour une inscription WEI" } }, { @@ -1653,7 +1428,7 @@ "mask": 1, "field": "birth_date", "permanent": false, - "description": "Update the birth date of any WEI Registration" + "description": "Modifier la date de naissance d'une inscription WEI" } }, { @@ -1669,7 +1444,7 @@ "mask": 1, "field": "birth_date", "permanent": false, - "description": "Update the birth date of my own WEI Registration" + "description": "Modifier la date de naissance de ma propre inscription WEI" } }, { @@ -1685,7 +1460,7 @@ "mask": 1, "field": "gender", "permanent": false, - "description": "Update the gender of any WEI Registration" + "description": "Modifier le genre de toute inscription WEI" } }, { @@ -1701,7 +1476,7 @@ "mask": 1, "field": "gender", "permanent": false, - "description": "Update the gender of my own WEI Registration" + "description": "Modifier le genre de ma propre inscription WEI" } }, { @@ -1717,7 +1492,7 @@ "mask": 1, "field": "health_issues", "permanent": false, - "description": "Update the health issues of any WEI Registration" + "description": "Modifier les problèmes de santé de toutes les inscriptions WEI" } }, { @@ -1733,7 +1508,7 @@ "mask": 1, "field": "health_issues", "permanent": false, - "description": "Update the health issues of my own WEI Registration" + "description": "Modifier mes problèmes de santé de mon inscription WEI" } }, { @@ -1749,7 +1524,7 @@ "mask": 1, "field": "emergency_contact_name", "permanent": false, - "description": "Update the emergency contact name of any WEI Registration" + "description": "Modifier le nom du contact en cas d'urgence de toute inscription WEI" } }, { @@ -1765,7 +1540,7 @@ "mask": 1, "field": "emergency_contact_name", "permanent": false, - "description": "Update the emergency contact name of my own WEI Registration" + "description": "Modifier le nom du contact en cas d'urgence de mon inscription WEI" } }, { @@ -1781,7 +1556,7 @@ "mask": 1, "field": "emergency_contact_phone", "permanent": false, - "description": "Update the emergency contact phone of any WEI Registration" + "description": "Modifier le téléphone du contact en cas d'urgence de toute inscription WEI" } }, { @@ -1797,7 +1572,7 @@ "mask": 1, "field": "emergency_contact_phone", "permanent": false, - "description": "Update the emergency contact phone of my own WEI Registration" + "description": "Modifier le nom du contact en cas d'urgence de mon inscription WEI" } }, { @@ -1813,7 +1588,7 @@ "mask": 1, "field": "information_json", "permanent": false, - "description": "Update information of any WEI registration" + "description": "Modifier les informations (sondage 1A, ...) d'une inscription WEI" } }, { @@ -1829,7 +1604,7 @@ "mask": 3, "field": "", "permanent": false, - "description": "Add a bus for the current WEI" + "description": "Ajouter un bus au WEI" } }, { @@ -1845,7 +1620,7 @@ "mask": 3, "field": "name", "permanent": false, - "description": "Update the name of a bus for the last WEI" + "description": "Modifier le nom d'un bus d'un WEI" } }, { @@ -1861,7 +1636,7 @@ "mask": 3, "field": "description", "permanent": false, - "description": "Update the description of a bus for the last WEI" + "description": "Modifier la description d'un bus d'un WEI" } }, { @@ -1877,7 +1652,7 @@ "mask": 3, "field": "", "permanent": false, - "description": "Create a bus team for the last WEI" + "description": "Créer une équipe WEI" } }, { @@ -1893,7 +1668,7 @@ "mask": 3, "field": "", "permanent": false, - "description": "Update a bus team for the last WEI" + "description": "Modifier une équipe WEI" } }, { @@ -1904,12 +1679,12 @@ "wei", "bus" ], - "query": "[\"AND\", {\"wei\": [\"club\"]}, [\"OR\", [\"NOT\", [\"membership\", \"registration\", \"first_year\"]], {\"wei__date_end__lte\": [\"today\"]}]]", + "query": "[\"AND\", {\"wei\": [\"club\"]}, [\"OR\", [\"NOT\", [\"membership\", \"weimembership\", \"registration\", \"first_year\"]], {\"wei__date_end__lte\": [\"today\"]}]]", "type": "view", "mask": 1, "field": "", "permanent": true, - "description": "View buses of the last WEI" + "description": "Voir tous les bus WEI si on est en 2A+ ou que le WEI est terminé" } }, { @@ -1920,12 +1695,12 @@ "wei", "busteam" ], - "query": "[\"AND\", {\"bus__wei\": [\"club\"]}, [\"OR\", [\"NOT\", [\"membership\", \"registration\", \"first_year\"]], {\"bus__wei__date_end__lte\": [\"today\"]}]]", + "query": "[\"AND\", {\"bus__wei\": [\"club\"]}, [\"OR\", [\"NOT\", [\"membership\", \"weimembership\", \"registration\", \"first_year\"]], {\"bus__wei__date_end__lte\": [\"today\"]}]]", "type": "view", "mask": 1, "field": "", "permanent": true, - "description": "View bus teams of the last WEI" + "description": "Voir toutes les équipes WEI si on est en 2A+ ou que le WEI est terminé" } }, { @@ -1941,7 +1716,7 @@ "mask": 3, "field": "", "permanent": false, - "description": "Create a WEI membership for the last WEI" + "description": "Créer une adhésion WEI pour le dernier WEI" } }, { @@ -1957,7 +1732,7 @@ "mask": 1, "field": "bus", "permanent": false, - "description": "Update the bus of a WEI membership" + "description": "Modifier le bus d'une adhésion WEI" } }, { @@ -1973,7 +1748,7 @@ "mask": 1, "field": "team", "permanent": false, - "description": "Update the team of a WEI membership" + "description": "Modifier l'équipe d'une adhésion WEI" } }, { @@ -1989,7 +1764,7 @@ "mask": 1, "field": "", "permanent": true, - "description": "View all WEI Memberships for the last WEI" + "description": "Voir toutes les adhésions au WEI" } }, { @@ -2000,12 +1775,12 @@ "wei", "weimembership" ], - "query": "[\"AND\", {\"user\": [\"user\"], \"club\": [\"club\"]}, [\"OR\", {\"registration__first_year\": false, \"club__weiclub__date_end__lte\": [\"today\"]}]]", + "query": "[\"AND\", {\"user\": [\"user\"], \"club\": [\"club\"]}, [\"OR\", {\"registration__first_year\": false}, {\"club__weiclub__date_end__lte\": [\"today\"]}]]", "type": "view", "mask": 1, "field": "", "permanent": true, - "description": "View my own WEI membership if I am an old member or if the WEI is past" + "description": "Voir mes adhésions WEI passées" } }, { @@ -2021,7 +1796,7 @@ "mask": 1, "field": "", "permanent": true, - "description": "View the members of the bus" + "description": "Voir les membres du bus" } }, { @@ -2037,7 +1812,7 @@ "mask": 1, "field": "", "permanent": true, - "description": "View the members of the team" + "description": "Voir les membres de l'équipe" } }, { @@ -2053,7 +1828,7 @@ "mask": 1, "field": "name", "permanent": false, - "description": "Update the name of my bus" + "description": "Modifier le nom du bus" } }, { @@ -2069,7 +1844,7 @@ "mask": 1, "field": "description", "permanent": false, - "description": "Update the description of my bus" + "description": "Modifier la description du bus" } }, { @@ -2085,7 +1860,7 @@ "mask": 1, "field": "", "permanent": false, - "description": "Add a team to my bus" + "description": "Ajouter une équipe à mon bus" } }, { @@ -2101,7 +1876,7 @@ "mask": 1, "field": "name", "permanent": false, - "description": "Update the name of a team of my bus" + "description": "Modifier le nom d'une équipe de mon bus" } }, { @@ -2117,7 +1892,7 @@ "mask": 1, "field": "color", "permanent": false, - "description": "Update the color of a team of my bus" + "description": "Modifier la couleur d'une équipe de mon bus" } }, { @@ -2133,7 +1908,7 @@ "mask": 1, "field": "description", "permanent": false, - "description": "Update the description of a team of my bus" + "description": "Modifier la description d'une équipe de mon bus" } }, { @@ -2149,7 +1924,7 @@ "mask": 1, "field": "name", "permanent": false, - "description": "Update the name of my team" + "description": "Modifier le nom de mon équipe" } }, { @@ -2165,7 +1940,7 @@ "mask": 1, "field": "color", "permanent": false, - "description": "Update the color of my team" + "description": "Modifier la couleur de mon équipe" } }, { @@ -2181,7 +1956,7 @@ "mask": 1, "field": "description", "permanent": false, - "description": "Update the description of my team" + "description": "Modifier la description de mon équipe" } }, { @@ -2197,7 +1972,7 @@ "mask": 1, "field": "", "permanent": true, - "description": "View my past activities" + "description": "Voir mes activitées passées, même après la fin de l'adhésion BDE" } }, { @@ -2210,17 +1985,274 @@ ], "query": "[\"AND\", [\"OR\", {\"source\": [\"club\", \"note\"]}, {\"destination\": [\"club\", \"note\"]}], [\"OR\", {\"amount__lte\": {\"F\": [\"ADD\", [\"F\", \"source__balance\"], 5000]}}, {\"valid\": true}]]", "type": "change", - "mask": 1, + "mask": 2, "field": "valid", "permanent": false, - "description": "Update validation status of a club transaction if possible" + "description": "Modifier le statut de validation d'une transaction de club si c'est possible" } }, { - "model": "permission.rolepermissions", + "model": "permission.permission", + "pk": 128, + "fields": { + "model": [ + "wei", + "weiregistration" + ], + "query": "{\"wei\": [\"club\"], \"wei__membership_end__gte\": [\"today\"]}", + "type": "change", + "mask": 1, + "field": "clothing_cut", + "permanent": false, + "description": "Modifier la coupe de vêtements d'une inscription WEI" + } + }, + { + "model": "permission.permission", + "pk": 129, + "fields": { + "model": [ + "wei", + "weiregistration" + ], + "query": "[\"AND\", {\"user\": [\"user\"], \"wei__membership_start__lte\": [\"today\"], \"wei__membership_end__gte\": [\"today\"]}, [\"OR\", {\"wei\": [\"club\"]}, {\"wei__year\": [\"today\", \"year\"], \"membership\": null}]]", + "type": "change", + "mask": 1, + "field": "clothing_cut", + "permanent": false, + "description": "Modifier ma coupe de vêtements de mon inscription WEI" + } + }, + { + "model": "permission.permission", + "pk": 130, + "fields": { + "model": [ + "wei", + "weiregistration" + ], + "query": "{\"wei\": [\"club\"], \"wei__membership_end__gte\": [\"today\"]}", + "type": "change", + "mask": 1, + "field": "clothing_size", + "permanent": false, + "description": "Modifier la taille de vêtements d'une inscription WEI" + } + }, + { + "model": "permission.permission", + "pk": 131, + "fields": { + "model": [ + "wei", + "weiregistration" + ], + "query": "[\"AND\", {\"user\": [\"user\"], \"wei__membership_start__lte\": [\"today\"], \"wei__membership_end__gte\": [\"today\"]}, [\"OR\", {\"wei\": [\"club\"]}, {\"wei__year\": [\"today\", \"year\"], \"membership\": null}]]", + "type": "change", + "mask": 1, + "field": "clothing_size", + "permanent": false, + "description": "Modifier la taille de vêtements de mon inscription WEI" + } + }, + { + "model": "permission.permission", + "pk": 132, + "fields": { + "model": [ + "note", + "recurrenttransaction" + ], + "query": "{}", + "type": "add", + "mask": 2, + "field": "", + "permanent": false, + "description": "Créer une transaction depuis un bouton" + } + }, + { + "model": "permission.permission", + "pk": 133, + "fields": { + "model": [ + "note", + "transaction" + ], + "query": "[\"AND\", [\"OR\", {\"source\": [\"club\", \"note\"]}, {\"destination\": [\"club\", \"note\"]}], [\"OR\", {\"amount__lte\": {\"F\": [\"ADD\", [\"F\", \"source__balance\"], 5000]}}, {\"valid\": true}]]", + "type": "change", + "mask": 1, + "field": "invalidity_reason", + "permanent": false, + "description": "Modifier la raison d'invalidité d'une transaction de club" + } + }, + { + "model": "permission.permission", + "pk": 134, + "fields": { + "model": [ + "note", + "transaction" + ], + "query": "{}", + "type": "change", + "mask": 1, + "field": "invalidity_reason", + "permanent": false, + "description": "Modifier la raison d'invalidité d'une transaction" + } + }, + { + "model": "permission.permission", + "pk": 135, + "fields": { + "model": [ + "auth", + "user" + ], + "query": "{}", + "type": "view", + "mask": 3, + "field": "", + "permanent": false, + "description": "Voir n'importe quel utilisateur" + } + }, + { + "model": "permission.permission", + "pk": 136, + "fields": { + "model": [ + "member", + "profile" + ], + "query": "{}", + "type": "view", + "mask": 3, + "field": "", + "permanent": false, + "description": "Voir n'importe quel profil" + } + }, + { + "model": "permission.permission", + "pk": 137, + "fields": { + "model": [ + "member", + "club" + ], + "query": "{}", + "type": "view", + "mask": 3, + "field": "", + "permanent": false, + "description": "Voir n'importe quel club" + } + }, + { + "model": "permission.permission", + "pk": 138, + "fields": { + "model": [ + "member", + "club" + ], + "query": "{}", + "type": "change", + "mask": 3, + "field": "", + "permanent": false, + "description": "Modifier n'importe quel club" + } + }, + { + "model": "permission.permission", + "pk": 139, + "fields": { + "model": [ + "note", + "noteclub" + ], + "query": "{}", + "type": "add", + "mask": 3, + "field": "", + "permanent": false, + "description": "Créer une note de club" + } + }, + { + "model": "permission.permission", + "pk": 140, + "fields": { + "model": [ + "member", + "club" + ], + "query": "{}", + "type": "add", + "mask": 3, + "field": "", + "permanent": false, + "description": "Créer un club" + } + }, + { + "model": "permission.permission", + "pk": 141, + "fields": { + "model": [ + "auth", + "user" + ], + "query": "{\"memberships__club\": [\"club\"], \"memberships__date__start__lte\": [\"today\"], \"memberships__date__end__gte\": [\"today\"]}", + "type": "view", + "mask": 3, + "field": "", + "permanent": false, + "description": "Voir les membres de mon club" + } + }, + { + "model": "permission.permission", + "pk": 142, + "fields": { + "model": [ + "note", + "noteclub" + ], + "query": "{\"club\": [\"club\"]}", + "type": "view", + "mask": 2, + "field": "", + "permanent": false, + "description": "Voir la note de mon club" + } + }, + { + "model": "permission.permission", + "pk": 143, + "fields": { + "model": [ + "note", + "noteuser" + ], + "query": "{}", + "type": "add", + "mask": 1, + "field": "", + "permanent": false, + "description": "Créer une note d'utilisateur" + } + }, + { + "model": "permission.role", "pk": 1, "fields": { - "role": 1, + "for_club": 1, + "name": "Adh\u00e9rent BDE", "permissions": [ 1, 2, @@ -2241,10 +2273,11 @@ } }, { - "model": "permission.rolepermissions", + "model": "permission.role", "pk": 2, "fields": { - "role": 2, + "for_club": 2, + "name": "Adh\u00e9rent Kfet", "permissions": [ 34, 35, @@ -2253,48 +2286,68 @@ 39, 40, 70, - 108, - 109, 14, 15, 16, 17, - 18, 78, 79, - 83 + 83, + 90, + 93, + 95, + 97, + 99, + 101, + 108, + 109 ] } }, { - "model": "permission.rolepermissions", + "model": "permission.role", + "pk": 3, + "fields": { + "for_club": null, + "name": "Membre de club", + "permissions": [] + } + }, + { + "model": "permission.role", "pk": 4, "fields": { - "role": 4, + "for_club": null, + "name": "Bureau de club", "permissions": [ 22, 47, - 49 + 49, + 50, + 140 ] } }, { - "model": "permission.rolepermissions", + "model": "permission.role", "pk": 5, "fields": { - "role": 5, + "for_club": null, + "name": "Pr\u00e9sident\u00b7e de club", "permissions": [ 50, - 51, - 62 + 62, + 141, + 142 ] } }, { - "model": "permission.rolepermissions", + "model": "permission.role", "pk": 6, "fields": { - "role": 6, + "for_club": null, + "name": "Tr\u00e9sorier\u00b7\u00e8re de club", "permissions": [ 59, 19, @@ -2304,15 +2357,19 @@ 60, 61, 62, - 127 + 127, + 133, + 141, + 142 ] } }, { - "model": "permission.rolepermissions", + "model": "permission.role", "pk": 7, "fields": { - "role": 7, + "for_club": 1, + "name": "Pr\u00e9sident\u00b7e BDE", "permissions": [ 24, 25, @@ -2323,10 +2380,11 @@ } }, { - "model": "permission.rolepermissions", + "model": "permission.role", "pk": 8, "fields": { - "role": 8, + "for_club": 1, + "name": "Tr\u00e9sorier\u00b7\u00e8re BDE", "permissions": [ 23, 24, @@ -2354,15 +2412,24 @@ 69, 71, 72, - 73 + 73, + 132, + 134, + 135, + 136, + 137, + 138, + 139, + 143 ] } }, { - "model": "permission.rolepermissions", + "model": "permission.role", "pk": 9, "fields": { - "role": 9, + "for_club": 1, + "name": "Respo info", "permissions": [ 1, 2, @@ -2381,7 +2448,6 @@ 15, 16, 17, - 18, 19, 20, 21, @@ -2443,9 +2509,6 @@ 77, 78, 79, - 80, - 81, - 82, 83, 84, 85, @@ -2489,15 +2552,33 @@ 123, 124, 125, - 126 + 126, + 127, + 128, + 129, + 130, + 131, + 132, + 133, + 134, + 135, + 136, + 137, + 138, + 139, + 140, + 141, + 142, + 143 ] } }, { - "model": "permission.rolepermissions", + "model": "permission.role", "pk": 10, "fields": { - "role": 10, + "for_club": 2, + "name": "GC Kfet", "permissions": [ 32, 33, @@ -2516,15 +2597,17 @@ 28, 29, 30, - 31 + 31, + 143 ] } }, { - "model": "permission.rolepermissions", + "model": "permission.role", "pk": 11, "fields": { - "role": 11, + "for_club": 2, + "name": "Res[pot]", "permissions": [ 37, 38, @@ -2538,15 +2621,13 @@ } }, { - "model": "permission.rolepermissions", + "model": "permission.role", "pk": 12, "fields": { - "role": 12, + "for_club": null, + "name": "GC WEI", "permissions": [ 76, - 80, - 81, - 82, 85, 86, 88, @@ -2566,16 +2647,20 @@ 110, 111, 112, - 113 + 113, + 130, + 131 ] } }, { - "model": "permission.rolepermissions", + "model": "permission.role", "pk": 13, "fields": { - "role": 13, + "for_club": null, + "name": "Chef de bus", "permissions": [ + 84, 117, 118, 120, @@ -2586,11 +2671,13 @@ } }, { - "model": "permission.rolepermissions", + "model": "permission.role", "pk": 14, "fields": { - "role": 14, + "for_club": null, + "name": "Chef d'\u00e9quipe", "permissions": [ + 84, 116, 123, 124, @@ -2599,24 +2686,92 @@ } }, { - "model": "permission.rolepermissions", + "model": "permission.role", + "pk": 15, + "fields": { + "for_club": null, + "name": "\u00c9lectron libre", + "permissions": [ + 84 + ] + } + }, + { + "model": "permission.role", "pk": 16, "fields": { - "role": 18, + "for_club": null, + "name": "\u00c9lectron libre (avec perm)", "permissions": [ + 84 + ] + } + }, + { + "model": "permission.role", + "pk": 17, + "fields": { + "for_club": null, + "name": "1A", + "permissions": [] + } + }, + { + "model": "permission.role", + "pk": 18, + "fields": { + "for_club": null, + "name": "Adhérent WEI", + "permissions": [ + 77, + 87, + 90, + 93, + 95, 97, 99, 101, 108, - 77, 109, 114, - 84, - 87, - 90, - 93, - 95 + 128, + 130 ] } + }, + { + "model": "wei.weirole", + "pk": 12, + "fields": {} + }, + { + "model": "wei.weirole", + "pk": 13, + "fields": {} + }, + { + "model": "wei.weirole", + "pk": 14, + "fields": {} + }, + { + "model": "wei.weirole", + "pk": 15, + "fields": {} + }, + { + "model": "wei.weirole", + "pk": 16, + "fields": {} + }, + { + "model": "wei.weirole", + "pk": 17, + "fields": {} + }, + { + "model": "wei.weirole", + "pk": 18, + "fields": {} } ] diff --git a/apps/permission/models.py b/apps/permission/models.py index ed4a90d0..d2ac2195 100644 --- a/apps/permission/models.py +++ b/apps/permission/models.py @@ -4,13 +4,13 @@ import functools import json import operator +from time import sleep from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ValidationError from django.db import models from django.db.models import F, Q, Model from django.utils.translation import gettext_lazy as _ -from member.models import Role class InstancedPermission: @@ -45,7 +45,17 @@ class InstancedPermission: else: oldpk = obj.pk # Ensure previous models are deleted - self.model.model_class().objects.filter(pk=obj.pk).annotate(_force_delete=F("pk")).delete() + count = 0 + while count < 1000: + if self.model.model_class().objects.filter(pk=obj.pk).exists(): + # If the object exists, that means that one permission is currently checked. + # We wait before the other permission, at most 1 second. + sleep(1) + continue + break + for o in self.model.model_class().objects.filter(pk=obj.pk).all(): + o._force_delete = True + Model.delete(o) # Force insertion, no data verification, no trigger obj._force_save = True Model.save(obj, force_insert=True) @@ -114,10 +124,10 @@ class PermissionMask(models.Model): class Permission(models.Model): PERMISSION_TYPES = [ - ('add', 'add'), - ('view', 'view'), - ('change', 'change'), - ('delete', 'delete') + ('add', _('add')), + ('view', _('view')), + ('change', _('change')), + ('delete', _('delete')) ] model = models.ForeignKey( @@ -239,6 +249,9 @@ class Permission(models.Model): field = Permission.compute_param(value[i], **kwargs) continue + if not hasattr(field, value[i][0]): + return False + field = getattr(field, value[i][0]) params = [] call_kwargs = {} @@ -252,6 +265,9 @@ class Permission(models.Model): params.append(param) field = field(*params, **call_kwargs) else: + if not hasattr(field, value[i]): + return False + field = getattr(field, value[i]) return field @@ -276,7 +292,7 @@ class Permission(models.Model): elif query[0] == 'NOT': return ~Permission._about(query[1], **kwargs) else: - return Q(pk=F("pk")) + return Q(pk=F("pk")) if Permission.compute_param(query, **kwargs) else ~Q(pk=F("pk")) elif isinstance(query, dict): q_kwargs = {} for key in query: @@ -307,23 +323,30 @@ class Permission(models.Model): return self.description -class RolePermissions(models.Model): +class Role(models.Model): """ Permissions associated with a Role """ - role = models.OneToOneField( - Role, - on_delete=models.PROTECT, - related_name='permissions', - verbose_name=_('role'), + name = models.CharField( + max_length=255, + verbose_name=_("name"), ) + permissions = models.ManyToManyField( Permission, verbose_name=_("permissions"), ) + for_club = models.ForeignKey( + "member.Club", + verbose_name=_("for club"), + on_delete=models.PROTECT, + null=True, + default=None, + ) + def __str__(self): - return str(self.role) + return self.name class Meta: verbose_name = _("role permissions") diff --git a/apps/permission/permissions.py b/apps/permission/permissions.py index 40321567..03f07992 100644 --- a/apps/permission/permissions.py +++ b/apps/permission/permissions.py @@ -19,8 +19,8 @@ class StrongDjangoObjectPermissions(DjangoObjectPermissions): 'OPTIONS': [], 'HEAD': [], 'POST': ['%(app_label)s.add_%(model_name)s'], - 'PUT': ['%(app_label)s.change_%(model_name)s'], - 'PATCH': ['%(app_label)s.change_%(model_name)s'], + 'PUT': [], # ['%(app_label)s.change_%(model_name)s'], + 'PATCH': [], # ['%(app_label)s.change_%(model_name)s'], 'DELETE': ['%(app_label)s.delete_%(model_name)s'], } diff --git a/apps/permission/signals.py b/apps/permission/signals.py index cac0a8a0..ef21c36e 100644 --- a/apps/permission/signals.py +++ b/apps/permission/signals.py @@ -50,6 +50,7 @@ def pre_save_object(sender, instance, **kwargs): # In the other case, we check if he/she has the right to change one field previous = qs.get() + for field in instance._meta.fields: field_name = field.name old_value = getattr(previous, field.name) @@ -81,7 +82,8 @@ def pre_delete_object(instance, **kwargs): if instance._meta.label_lower in EXCLUDED: return - if hasattr(instance, "_force_delete"): + if hasattr(instance, "_force_delete") or hasattr(instance, "pk") and instance.pk == 0: + # Don't check permissions on force-deleted objects return user = get_current_authenticated_user() diff --git a/apps/permission/templatetags/perms.py b/apps/permission/templatetags/perms.py index a89c7f49..335721a1 100644 --- a/apps/permission/templatetags/perms.py +++ b/apps/permission/templatetags/perms.py @@ -1,6 +1,7 @@ # Copyright (C) 2018-2020 by BDE ENS Paris-Saclay # SPDX-License-Identifier: GPL-3.0-or-later +from django.contrib.auth.models import AnonymousUser from django.contrib.contenttypes.models import ContentType from django.template.defaultfilters import stringfilter from django import template @@ -16,9 +17,9 @@ def not_empty_model_list(model_name): """ user = get_current_authenticated_user() session = get_current_session() - if user is None: + if user is None or isinstance(user, AnonymousUser): return False - elif user.is_superuser and session.get("permission_mask", 0) >= 42: + elif user.is_superuser and session.get("permission_mask", -1) >= 42: return True qs = model_list(model_name) return qs.exists() @@ -31,28 +32,38 @@ def not_empty_model_change_list(model_name): """ user = get_current_authenticated_user() session = get_current_session() - if user is None: + if user is None or isinstance(user, AnonymousUser): return False - elif user.is_superuser and session.get("permission_mask", 0) >= 42: + elif user.is_superuser and session.get("permission_mask", -1) >= 42: return True qs = model_list(model_name, "change") return qs.exists() @stringfilter -def model_list(model_name, t="view"): +def model_list(model_name, t="view", fetch=True): """ Return the queryset of all visible instances of the given model. """ user = get_current_authenticated_user() - if user is None: - return False spl = model_name.split(".") ct = ContentType.objects.get(app_label=spl[0], model=spl[1]) - qs = ct.model_class().objects.filter(PermissionBackend.filter_queryset(user, ct, t)).all() + qs = ct.model_class().objects.filter(PermissionBackend.filter_queryset(user, ct, t)) + if user is None or isinstance(user, AnonymousUser): + return qs.none() + if fetch: + qs = qs.all() return qs +@stringfilter +def model_list_length(model_name, t="view"): + """ + Return the length of queryset of all visible instances of the given model. + """ + return model_list(model_name, t, False).count() + + def has_perm(perm, obj): return PermissionBackend.check_perm(get_current_authenticated_user(), perm, obj) @@ -63,9 +74,9 @@ def can_create_transaction(): """ user = get_current_authenticated_user() session = get_current_session() - if user is None: + if user is None or isinstance(user, AnonymousUser): return False - elif user.is_superuser and session.get("permission_mask", 0) >= 42: + elif user.is_superuser and session.get("permission_mask", -1) >= 42: return True if session.get("can_create_transaction", None): return session.get("can_create_transaction", None) == 1 @@ -85,4 +96,5 @@ register = template.Library() register.filter('not_empty_model_list', not_empty_model_list) register.filter('not_empty_model_change_list', not_empty_model_change_list) register.filter('model_list', model_list) +register.filter('model_list_length', model_list_length) register.filter('has_perm', has_perm) diff --git a/apps/permission/test.py b/apps/permission/test.py index de46d5aa..e728e9a6 100644 --- a/apps/permission/test.py +++ b/apps/permission/test.py @@ -76,7 +76,7 @@ class PermissionQueryTestCase(TestCase): model = perm.model.model_class() model.objects.filter(query).all() # print("Good query for permission", perm) - except (FieldError, AttributeError, ValueError): + except (FieldError, AttributeError, ValueError, TypeError): print("Query error for permission", perm) print("Query:", perm.query) if instanced.query: diff --git a/apps/permission/views.py b/apps/permission/views.py index ab555c2f..83deddac 100644 --- a/apps/permission/views.py +++ b/apps/permission/views.py @@ -5,9 +5,10 @@ from datetime import date from django.forms import HiddenInput from django.utils.translation import gettext_lazy as _ from django.views.generic import UpdateView, TemplateView -from member.models import Role, Membership +from member.models import Membership from .backends import PermissionBackend +from .models import Role class ProtectQuerysetMixin: @@ -19,7 +20,7 @@ class ProtectQuerysetMixin: """ def get_queryset(self, **kwargs): qs = super().get_queryset(**kwargs) - return qs.filter(PermissionBackend.filter_queryset(self.request.user, qs.model, "view")).distinct() + return qs.filter(PermissionBackend.filter_queryset(self.request.user, qs.model, "view")) def get_form(self, form_class=None): form = super().get_form(form_class) @@ -40,6 +41,7 @@ class ProtectQuerysetMixin: class RightsView(TemplateView): template_name = "permission/all_rights.html" + extra_context = {"title": _("Rights")} def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) diff --git a/apps/registration/tokens.py b/apps/registration/tokens.py index c5ddc82b..0e7b20a5 100644 --- a/apps/registration/tokens.py +++ b/apps/registration/tokens.py @@ -24,7 +24,8 @@ class AccountActivationTokenGenerator(PasswordResetTokenGenerator): # Truncate microseconds so that tokens are consistent even if the # database doesn't support microseconds. login_timestamp = '' if user.last_login is None else user.last_login.replace(microsecond=0, tzinfo=None) - return str(user.pk) + str(user.profile.email_confirmed) + str(login_timestamp) + str(timestamp) + return str(user.pk) + str(user.email) + str(user.profile.email_confirmed)\ + + str(login_timestamp) + str(timestamp) email_validation_token = AccountActivationTokenGenerator() diff --git a/apps/registration/views.py b/apps/registration/views.py index 2c91a604..804c9fa9 100644 --- a/apps/registration/views.py +++ b/apps/registration/views.py @@ -15,10 +15,11 @@ from django.views.generic import CreateView, TemplateView, DetailView from django.views.generic.edit import FormMixin from django_tables2 import SingleTableView from member.forms import ProfileForm -from member.models import Membership, Club, Role +from member.models import Membership, Club from note.models import SpecialTransaction from note.templatetags.pretty_money import pretty_money from permission.backends import PermissionBackend +from permission.models import Role from permission.views import ProtectQuerysetMixin from .forms import SignUpForm, ValidationForm @@ -34,6 +35,7 @@ class UserCreateView(CreateView): form_class = SignUpForm template_name = 'registration/signup.html' second_form = ProfileForm + extra_context = {"title": _("Register new user")} def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) @@ -77,6 +79,7 @@ class UserValidateView(TemplateView): """ title = _("Email validation") template_name = 'registration/email_validation_complete.html' + extra_context = {"title": _("Validate email")} def get(self, *args, **kwargs): """ @@ -90,16 +93,13 @@ class UserValidateView(TemplateView): # Validate the token if user is not None and email_validation_token.check_token(user, token): - self.validlink = True # The user must wait that someone validates the account before the user can be active and login. + self.validlink = True user.is_active = user.profile.registration_valid or user.is_superuser user.profile.email_confirmed = True user.save() user.profile.save() - return super().dispatch(*args, **kwargs) - else: - # Display the "Email validation unsuccessful" page. - return self.render_to_response(self.get_context_data()) + return self.render_to_response(self.get_context_data()) def get_user(self, uidb64): """ @@ -132,7 +132,7 @@ class UserValidationEmailSentView(TemplateView): Display the information that the validation link has been sent. """ template_name = 'registration/email_validation_email_sent.html' - title = _('Email validation email sent') + extra_context = {"title": _('Email validation email sent')} class UserResendValidationEmailView(LoginRequiredMixin, ProtectQuerysetMixin, DetailView): @@ -140,6 +140,7 @@ class UserResendValidationEmailView(LoginRequiredMixin, ProtectQuerysetMixin, De Rensend the email validation link. """ model = User + extra_context = {"title": _("Resend email validation link")} def get(self, request, *args, **kwargs): user = self.get_object() @@ -157,6 +158,7 @@ class FutureUserListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableVi model = User table_class = FutureUserTable template_name = 'registration/future_user_list.html' + extra_context = {"title": _("Pre-registered users list")} def get_queryset(self, **kwargs): """ @@ -164,7 +166,7 @@ class FutureUserListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableVi :param kwargs: :return: """ - qs = super().get_queryset().filter(profile__registration_valid=False) + qs = super().get_queryset().distinct().filter(profile__registration_valid=False) if "search" in self.request.GET: pattern = self.request.GET["search"] @@ -198,6 +200,7 @@ class FutureUserDetailView(ProtectQuerysetMixin, LoginRequiredMixin, FormMixin, form_class = ValidationForm context_object_name = "user_object" template_name = "registration/future_profile_detail.html" + extra_context = {"title": _("Registration detail")} def post(self, request, *args, **kwargs): form = self.get_form() @@ -354,6 +357,7 @@ class FutureUserInvalidateView(ProtectQuerysetMixin, LoginRequiredMixin, View): """ Delete a pre-registered user. """ + extra_context = {"title": _("Invalidate pre-registration")} def get(self, request, *args, **kwargs): """ diff --git a/apps/scripts b/apps/scripts index ee54fca8..dd8b48c3 160000 --- a/apps/scripts +++ b/apps/scripts @@ -1 +1 @@ -Subproject commit ee54fca89ee247a4ba4af080dd3036d92340eade +Subproject commit dd8b48c31d4501d95b3afb00ac9b387397fca957 diff --git a/apps/treasury/admin.py b/apps/treasury/admin.py index 9c8aaf2e..33224ba7 100644 --- a/apps/treasury/admin.py +++ b/apps/treasury/admin.py @@ -2,11 +2,12 @@ # SPDX-License-Identifier: GPL-3.0-or-lateré from django.contrib import admin +from note_kfet.admin import admin_site from .models import RemittanceType, Remittance, SogeCredit -@admin.register(RemittanceType) +@admin.register(RemittanceType, site=admin_site) class RemittanceTypeAdmin(admin.ModelAdmin): """ Admin customisation for RemiitanceType @@ -14,7 +15,7 @@ class RemittanceTypeAdmin(admin.ModelAdmin): list_display = ('note', ) -@admin.register(Remittance) +@admin.register(Remittance, site=admin_site) class RemittanceAdmin(admin.ModelAdmin): """ Admin customisation for Remittance @@ -27,4 +28,14 @@ class RemittanceAdmin(admin.ModelAdmin): return not obj.closed and super().has_change_permission(request, obj) -admin.site.register(SogeCredit) +@admin.register(SogeCredit, site=admin_site) +class SogeCreditAdmin(admin.ModelAdmin): + """ + Admin customisation for Remittance + """ + list_display = ('user', 'valid',) + readonly_fields = ('transactions', 'credit_transaction',) + + def has_add_permission(self, request): + # Don't create a credit manually + return False diff --git a/apps/treasury/forms.py b/apps/treasury/forms.py index b09a46c7..4c761ef2 100644 --- a/apps/treasury/forms.py +++ b/apps/treasury/forms.py @@ -8,7 +8,6 @@ from crispy_forms.layout import Submit from django import forms from django.utils.translation import gettext_lazy as _ from note_kfet.inputs import DatePickerInput, AmountInput -from permission.backends import PermissionBackend from .models import Invoice, Product, Remittance, SpecialTransactionProxy @@ -132,8 +131,7 @@ class LinkTransactionToRemittanceForm(forms.ModelForm): # Add submit button self.helper.add_input(Submit('submit', _("Submit"), attr={'class': 'btn btn-block btn-primary'})) - self.fields["remittance"].queryset = Remittance.objects.filter(closed=False)\ - .filter(PermissionBackend.filter_queryset(self.request.user, Remittance, "view")) + self.fields["remittance"].queryset = Remittance.objects.filter(closed=False) def clean_last_name(self): """ diff --git a/apps/treasury/views.py b/apps/treasury/views.py index f42e5e77..22215254 100644 --- a/apps/treasury/views.py +++ b/apps/treasury/views.py @@ -15,6 +15,7 @@ from django.http import HttpResponse from django.shortcuts import redirect from django.template.loader import render_to_string from django.urls import reverse_lazy +from django.utils.translation import gettext_lazy as _ from django.views.generic import CreateView, UpdateView, DetailView from django.views.generic.base import View, TemplateView from django.views.generic.edit import BaseFormView @@ -35,6 +36,7 @@ class InvoiceCreateView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView): """ model = Invoice form_class = InvoiceForm + extra_context = {"title": _("Create new invoice")} def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) @@ -77,6 +79,7 @@ class InvoiceListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView) """ model = Invoice table_class = InvoiceTable + extra_context = {"title": _("Invoices list")} class InvoiceUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView): @@ -85,6 +88,7 @@ class InvoiceUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView): """ model = Invoice form_class = InvoiceForm + extra_context = {"title": _("Update an invoice")} def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) @@ -167,7 +171,7 @@ class InvoiceRenderView(LoginRequiredMixin, View): del tex # The file has to be rendered twice - for _ in range(2): + for ignored in range(2): error = subprocess.Popen( ["pdflatex", "invoice-{}.tex".format(pk)], cwd=tmp_dir, @@ -198,6 +202,7 @@ class RemittanceCreateView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView) """ model = Remittance form_class = RemittanceForm + extra_context = {"title": _("Create a new remittance")} def get_success_url(self): return reverse_lazy('treasury:remittance_list') @@ -218,27 +223,46 @@ class RemittanceListView(LoginRequiredMixin, TemplateView): List existing Remittances """ template_name = "treasury/remittance_list.html" + extra_context = {"title": _("Remittances list")} def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - context["opened_remittances"] = RemittanceTable( + opened_remittances = RemittanceTable( data=Remittance.objects.filter(closed=False).filter( - PermissionBackend.filter_queryset(self.request.user, Remittance, "view")).all()) - context["closed_remittances"] = RemittanceTable( - data=Remittance.objects.filter(closed=True).filter( - PermissionBackend.filter_queryset(self.request.user, Remittance, "view")).reverse().all()) + PermissionBackend.filter_queryset(self.request.user, Remittance, "view")).all(), + prefix="opened-remittances-", + ) + opened_remittances.paginate(page=self.request.GET.get("opened-remittances-page", 1), per_page=10) + context["opened_remittances"] = opened_remittances - context["special_transactions_no_remittance"] = SpecialTransactionTable( + closed_remittances = RemittanceTable( + data=Remittance.objects.filter(closed=True).filter( + PermissionBackend.filter_queryset(self.request.user, Remittance, "view")).reverse().all(), + prefix="closed-remittances-", + ) + closed_remittances.paginate(page=self.request.GET.get("closed-remittances-page", 1), per_page=10) + context["closed_remittances"] = closed_remittances + + no_remittance_tr = SpecialTransactionTable( data=SpecialTransaction.objects.filter(source__in=NoteSpecial.objects.filter(~Q(remittancetype=None)), specialtransactionproxy__remittance=None).filter( PermissionBackend.filter_queryset(self.request.user, Remittance, "view")).all(), - exclude=('remittance_remove', )) - context["special_transactions_with_remittance"] = SpecialTransactionTable( + exclude=('remittance_remove', ), + prefix="no-remittance-", + ) + no_remittance_tr.paginate(page=self.request.GET.get("no-remittance-page", 1), per_page=10) + context["special_transactions_no_remittance"] = no_remittance_tr + + with_remittance_tr = SpecialTransactionTable( data=SpecialTransaction.objects.filter(source__in=NoteSpecial.objects.filter(~Q(remittancetype=None)), specialtransactionproxy__remittance__closed=False).filter( PermissionBackend.filter_queryset(self.request.user, Remittance, "view")).all(), - exclude=('remittance_add', )) + exclude=('remittance_add', ), + prefix="with-remittance-", + ) + with_remittance_tr.paginate(page=self.request.GET.get("with-remittance-page", 1), per_page=10) + context["special_transactions_with_remittance"] = with_remittance_tr return context @@ -249,6 +273,7 @@ class RemittanceUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView) """ model = Remittance form_class = RemittanceForm + extra_context = {"title": _("Update a remittance")} def get_success_url(self): return reverse_lazy('treasury:remittance_list') @@ -271,9 +296,9 @@ class LinkTransactionToRemittanceView(ProtectQuerysetMixin, LoginRequiredMixin, """ Attach a special transaction to a remittance """ - model = SpecialTransactionProxy form_class = LinkTransactionToRemittanceForm + extra_context = {"title": _("Attach a transaction to a remittance")} def get_success_url(self): return reverse_lazy('treasury:remittance_list') @@ -317,6 +342,7 @@ class SogeCreditListView(LoginRequiredMixin, ProtectQuerysetMixin, SingleTableVi """ model = SogeCredit table_class = SogeCreditTable + extra_context = {"title": _("List of credits from the Société générale")} def get_queryset(self, **kwargs): """ @@ -355,6 +381,7 @@ class SogeCreditManageView(LoginRequiredMixin, ProtectQuerysetMixin, BaseFormVie """ model = SogeCredit form_class = Form + extra_context = {"title": _("Manage credits from the Société générale")} def form_valid(self, form): if "validate" in form.data: diff --git a/apps/wei/admin.py b/apps/wei/admin.py index f93a44ed..f928a313 100644 --- a/apps/wei/admin.py +++ b/apps/wei/admin.py @@ -1,13 +1,13 @@ # Copyright (C) 2018-2020 by BDE ENS Paris-Saclay # SPDX-License-Identifier: GPL-3.0-or-later -from django.contrib import admin +from note_kfet.admin import admin_site from .models import WEIClub, WEIRegistration, WEIMembership, WEIRole, Bus, BusTeam -admin.site.register(WEIClub) -admin.site.register(WEIRegistration) -admin.site.register(WEIMembership) -admin.site.register(WEIRole) -admin.site.register(Bus) -admin.site.register(BusTeam) +admin_site.register(WEIClub) +admin_site.register(WEIRegistration) +admin_site.register(WEIMembership) +admin_site.register(WEIRole) +admin_site.register(Bus) +admin_site.register(BusTeam) diff --git a/apps/wei/forms/registration.py b/apps/wei/forms/registration.py index 96555372..9ce3a350 100644 --- a/apps/wei/forms/registration.py +++ b/apps/wei/forms/registration.py @@ -96,7 +96,7 @@ class WEIMembershipForm(forms.ModelForm): class BusForm(forms.ModelForm): class Meta: model = Bus - fields = '__all__' + exclude = ('information_json',) widgets = { "wei": Autocomplete( WEIClub, diff --git a/apps/wei/models.py b/apps/wei/models.py index 9cee0d61..df353338 100644 --- a/apps/wei/models.py +++ b/apps/wei/models.py @@ -8,8 +8,9 @@ from django.conf import settings from django.contrib.auth.models import User from django.db import models from django.utils.translation import gettext_lazy as _ -from member.models import Role, Club, Membership +from member.models import Club, Membership from note.models import MembershipTransaction +from permission.models import Role class WEIClub(Club): @@ -113,6 +114,7 @@ class BusTeam(models.Model): name = models.CharField( max_length=255, + verbose_name=_("name"), ) color = models.PositiveIntegerField( # Use a color picker to get the hexa code @@ -188,6 +190,28 @@ class WEIRegistration(models.Model): verbose_name=_("gender"), ) + clothing_cut = models.CharField( + max_length=16, + choices=( + ('male', _("Male")), + ('female', _("Female")), + ), + verbose_name=_("clothing cut"), + ) + + clothing_size = models.CharField( + max_length=4, + choices=( + ('XS', "XS"), + ('S', "S"), + ('M', "M"), + ('L', "L"), + ('XL', "XL"), + ('XXL', "XXL"), + ), + verbose_name=_("clothing size"), + ) + health_issues = models.TextField( blank=True, default="", diff --git a/apps/wei/tables.py b/apps/wei/tables.py index 36d09342..41c35a47 100644 --- a/apps/wei/tables.py +++ b/apps/wei/tables.py @@ -103,7 +103,7 @@ class WEIMembershipTable(tables.Table): team = tables.LinkColumn( 'wei:manage_bus_team', - args=[A('bus.pk')], + args=[A('team.pk')], ) def render_year(self, record): @@ -144,10 +144,10 @@ class BusTable(tables.Table): ) def render_teams(self, value): - return ", ".join(team.name for team in value.all()) + return ", ".join(team.name for team in value.order_by('name').all()) def render_count(self, value): - return str(value) + " " + (str(_("members")) if value > 0 else str(_("member"))) + return str(value) + " " + (str(_("members")) if value > 1 else str(_("member"))) class Meta: attrs = { @@ -178,7 +178,7 @@ class BusTeamTable(tables.Table): ) def render_count(self, value): - return str(value) + " " + (str(_("members")) if value > 0 else str(_("member"))) + return str(value) + " " + (str(_("members")) if value > 1 else str(_("member"))) count = tables.Column( verbose_name=_("Members count"), diff --git a/apps/wei/views.py b/apps/wei/views.py index 597a44d4..2210a347 100644 --- a/apps/wei/views.py +++ b/apps/wei/views.py @@ -17,6 +17,7 @@ from django.http import HttpResponse from django.shortcuts import redirect from django.template.loader import render_to_string from django.urls import reverse_lazy +from django.utils import timezone from django.views import View from django.views.generic import DetailView, UpdateView, CreateView, RedirectView, TemplateView from django.utils.translation import gettext_lazy as _ @@ -52,6 +53,16 @@ class WEIListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView): model = WEIClub table_class = WEITable ordering = '-year' + extra_context = {"title": _("Search WEI")} + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context["can_create_wei"] = PermissionBackend.check_perm(self.request.user, "wei.add_weiclub", WEIClub( + year=0, + date_start=timezone.now().date(), + date_end=timezone.now().date(), + )) + return context class WEICreateView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView): @@ -60,6 +71,7 @@ class WEICreateView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView): """ model = WEIClub form_class = WEIForm + extra_context = {"title": _("Create WEI")} def form_valid(self, form): form.instance.requires_membership = True @@ -79,6 +91,7 @@ class WEIDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): """ model = WEIClub context_object_name = "club" + extra_context = {"title": _("WEI Detail")} def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) @@ -132,6 +145,7 @@ class WEIDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): else: # Check if the user has the right to create a registration of a random first year member. empty_fy_registration = WEIRegistration( + wei=club, user=random_user, first_year=True, birth_date="1970-01-01", @@ -144,6 +158,7 @@ class WEIDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): # Check if the user has the right to create a registration of a random old member. empty_old_registration = WEIRegistration( + wei=club, user=User.objects.filter(~Q(wei__wei__in=[club])).first(), first_year=False, birth_date="1970-01-01", @@ -171,13 +186,14 @@ class WEIMembershipsView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableVi """ model = WEIMembership table_class = WEIMembershipTable + extra_context = {"title": _("View members of the WEI")} def dispatch(self, request, *args, **kwargs): self.club = WEIClub.objects.get(pk=self.kwargs["pk"]) return super().dispatch(request, *args, **kwargs) def get_queryset(self, **kwargs): - qs = super().get_queryset(**kwargs).filter(club=self.club) + qs = super().get_queryset(**kwargs).filter(club=self.club).distinct() pattern = self.request.GET.get("search", "") @@ -208,13 +224,14 @@ class WEIRegistrationsView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTable """ model = WEIRegistration table_class = WEIRegistrationTable + extra_context = {"title": _("View registrations to the WEI")} def dispatch(self, request, *args, **kwargs): self.club = WEIClub.objects.get(pk=self.kwargs["pk"]) return super().dispatch(request, *args, **kwargs) def get_queryset(self, **kwargs): - qs = super().get_queryset(**kwargs).filter(wei=self.club, membership=None) + qs = super().get_queryset(**kwargs).filter(wei=self.club, membership=None).distinct() pattern = self.request.GET.get("search", "") @@ -244,6 +261,7 @@ class WEIUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView): model = WEIClub context_object_name = "club" form_class = WEIForm + extra_context = {"title": _("Update the WEI")} def dispatch(self, request, *args, **kwargs): wei = self.get_object() @@ -264,6 +282,7 @@ class BusCreateView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView): """ model = Bus form_class = BusForm + extra_context = {"title": _("Create new bus")} def dispatch(self, request, *args, **kwargs): wei = WEIClub.objects.get(pk=self.kwargs["pk"]) @@ -294,6 +313,7 @@ class BusUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView): """ model = Bus form_class = BusForm + extra_context = {"title": _("Update bus")} def dispatch(self, request, *args, **kwargs): wei = self.get_object().wei @@ -323,6 +343,7 @@ class BusManageView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): Manage Bus """ model = Bus + extra_context = {"title": _("Manage bus")} def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) @@ -330,7 +351,7 @@ class BusManageView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): bus = self.object teams = BusTeam.objects.filter(PermissionBackend.filter_queryset(self.request.user, BusTeam, "view")) \ - .filter(bus=bus).annotate(count=Count("memberships")) + .filter(bus=bus).annotate(count=Count("memberships")).order_by("name") teams_table = BusTeamTable(data=teams, prefix="team-") context["teams"] = teams_table @@ -349,6 +370,7 @@ class BusTeamCreateView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView): """ model = BusTeam form_class = BusTeamForm + extra_context = {"title": _("Create new team")} def dispatch(self, request, *args, **kwargs): wei = WEIClub.objects.get(buses__pk=self.kwargs["pk"]) @@ -380,6 +402,7 @@ class BusTeamUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView): """ model = BusTeam form_class = BusTeamForm + extra_context = {"title": _("Update team")} def dispatch(self, request, *args, **kwargs): wei = self.get_object().bus.wei @@ -410,6 +433,7 @@ class BusTeamManageView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): Manage Bus team """ model = BusTeam + extra_context = {"title": _("Manage WEI team")} def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) @@ -431,6 +455,7 @@ class WEIRegister1AView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView): """ model = WEIRegistration form_class = WEIRegistrationForm + extra_context = {"title": _("Register first year student to the WEI")} def dispatch(self, request, *args, **kwargs): wei = WEIClub.objects.get(pk=self.kwargs["wei_pk"]) @@ -485,6 +510,7 @@ class WEIRegister2AView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView): """ model = WEIRegistration form_class = WEIRegistrationForm + extra_context = {"title": _("Register old student to the WEI")} def dispatch(self, request, *args, **kwargs): wei = WEIClub.objects.get(pk=self.kwargs["wei_pk"]) @@ -562,6 +588,7 @@ class WEIUpdateRegistrationView(ProtectQuerysetMixin, LoginRequiredMixin, Update """ model = WEIRegistration form_class = WEIRegistrationForm + extra_context = {"title": _("Update WEI Registration")} def get_queryset(self, **kwargs): return WEIRegistration.objects @@ -651,6 +678,7 @@ class WEIDeleteRegistrationView(ProtectQuerysetMixin, LoginRequiredMixin, Delete Delete a non-validated WEI registration """ model = WEIRegistration + extra_context = {"title": _("Delete WEI registration")} def dispatch(self, request, *args, **kwargs): object = self.get_object() @@ -680,6 +708,7 @@ class WEIValidateRegistrationView(ProtectQuerysetMixin, LoginRequiredMixin, Crea """ model = WEIMembership form_class = WEIMembershipForm + extra_context = {"title": _("Validate WEI registration")} def dispatch(self, request, *args, **kwargs): wei = WEIRegistration.objects.get(pk=self.kwargs["pk"]).wei @@ -797,6 +826,7 @@ class WEISurveyView(LoginRequiredMixin, BaseFormView, DetailView): model = WEIRegistration template_name = "wei/survey.html" survey = None + extra_context = {"title": _("Survey WEI")} def dispatch(self, request, *args, **kwargs): obj = self.get_object() @@ -834,7 +864,6 @@ class WEISurveyView(LoginRequiredMixin, BaseFormView, DetailView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context["club"] = self.object.wei - context["title"] = _("Survey WEI") return context def form_valid(self, form): @@ -850,21 +879,21 @@ class WEISurveyView(LoginRequiredMixin, BaseFormView, DetailView): class WEISurveyEndView(LoginRequiredMixin, TemplateView): template_name = "wei/survey_end.html" + extra_context = {"title": _("Survey WEI")} def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context["club"] = WEIRegistration.objects.get(pk=self.kwargs["pk"]).wei - context["title"] = _("Survey WEI") return context class WEIClosedView(LoginRequiredMixin, TemplateView): template_name = "wei/survey_closed.html" + extra_context = {"title": _("Survey WEI")} def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context["club"] = WEIClub.objects.get(pk=self.kwargs["pk"]) - context["title"] = _("Survey WEI") return context diff --git a/locale/de/LC_MESSAGES/django.po b/locale/de/LC_MESSAGES/django.po index d4fe6420..bec7e726 100644 --- a/locale/de/LC_MESSAGES/django.po +++ b/locale/de/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-07 20:56+0200\n" +"POT-Creation-Date: 2020-08-01 15:06+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -44,11 +44,11 @@ msgid "You can't invite more than 3 people to this activity." msgstr "" #: apps/activity/models.py:23 apps/activity/models.py:48 -#: apps/member/models.py:151 apps/member/models.py:255 -#: apps/note/models/notes.py:188 apps/note/models/transactions.py:25 -#: apps/note/models/transactions.py:45 apps/note/models/transactions.py:249 -#: apps/wei/models.py:64 templates/member/club_info.html:13 -#: templates/member/profile_info.html:14 +#: apps/member/models.py:151 apps/note/models/notes.py:188 +#: apps/note/models/transactions.py:25 apps/note/models/transactions.py:45 +#: apps/note/models/transactions.py:263 apps/permission/models.py:332 +#: apps/wei/models.py:65 apps/wei/models.py:117 +#: templates/member/club_info.html:13 templates/member/profile_info.html:14 #: templates/registration/future_profile_detail.html:16 #: templates/wei/weiclub_info.html:13 templates/wei/weimembership_form.html:18 msgid "name" @@ -70,22 +70,22 @@ msgstr "" msgid "activity types" msgstr "" -#: apps/activity/models.py:53 apps/note/models/transactions.py:75 -#: apps/permission/models.py:103 apps/permission/models.py:182 -#: apps/wei/models.py:70 apps/wei/models.py:126 +#: apps/activity/models.py:53 apps/note/models/transactions.py:81 +#: apps/permission/models.py:113 apps/permission/models.py:192 +#: apps/wei/models.py:71 apps/wei/models.py:128 #: templates/activity/activity_detail.html:16 msgid "description" msgstr "" #: apps/activity/models.py:60 apps/note/models/notes.py:164 -#: apps/note/models/transactions.py:65 apps/permission/models.py:157 +#: apps/note/models/transactions.py:66 apps/permission/models.py:167 #: templates/activity/activity_detail.html:19 msgid "type" msgstr "" -#: apps/activity/models.py:66 apps/logs/models.py:21 apps/member/models.py:277 +#: apps/activity/models.py:66 apps/logs/models.py:21 apps/member/models.py:259 #: apps/note/models/notes.py:117 apps/treasury/models.py:221 -#: apps/wei/models.py:157 templates/treasury/sogecredit_detail.html:14 +#: apps/wei/models.py:159 templates/treasury/sogecredit_detail.html:14 #: templates/wei/survey.html:16 msgid "user" msgstr "" @@ -106,7 +106,7 @@ msgstr "" msgid "end date" msgstr "" -#: apps/activity/models.py:93 apps/note/models/transactions.py:140 +#: apps/activity/models.py:93 apps/note/models/transactions.py:146 #: templates/activity/activity_detail.html:47 msgid "valid" msgstr "" @@ -186,14 +186,14 @@ msgstr "" msgid "Type" msgstr "" -#: apps/activity/tables.py:77 apps/member/forms.py:83 -#: apps/registration/forms.py:64 apps/treasury/forms.py:121 +#: apps/activity/tables.py:77 apps/member/forms.py:102 +#: apps/registration/forms.py:64 apps/treasury/forms.py:120 msgid "Last name" msgstr "" -#: apps/activity/tables.py:79 apps/member/forms.py:88 -#: apps/registration/forms.py:69 apps/treasury/forms.py:123 -#: templates/note/transaction_form.html:126 +#: apps/activity/tables.py:79 apps/member/forms.py:107 +#: apps/registration/forms.py:69 apps/treasury/forms.py:122 +#: templates/note/transaction_form.html:129 msgid "First name" msgstr "" @@ -201,15 +201,31 @@ msgstr "" msgid "Note" msgstr "" -#: apps/activity/tables.py:83 apps/member/tables.py:41 +#: apps/activity/tables.py:83 apps/member/tables.py:42 msgid "Balance" msgstr "" -#: apps/activity/views.py:46 templates/base.html:120 +#: apps/activity/views.py:26 +msgid "Create new activity" +msgstr "" + +#: apps/activity/views.py:41 templates/base.html:121 msgid "Activities" msgstr "" -#: apps/activity/views.py:160 +#: apps/activity/views.py:61 +msgid "Activity detail" +msgstr "" + +#: apps/activity/views.py:78 +msgid "Update activity" +msgstr "" + +#: apps/activity/views.py:92 +msgid "Invite guest to the activity \"{}\"" +msgstr "" + +#: apps/activity/views.py:171 msgid "Entry for activity \"{}\"" msgstr "" @@ -225,7 +241,7 @@ msgstr "" msgid "IP Address" msgstr "" -#: apps/logs/models.py:35 apps/permission/models.py:127 +#: apps/logs/models.py:35 apps/permission/models.py:137 msgid "model" msgstr "" @@ -245,13 +261,13 @@ msgstr "" msgid "create" msgstr "" -#: apps/logs/models.py:61 apps/note/tables.py:145 +#: apps/logs/models.py:61 apps/note/tables.py:161 #: templates/activity/activity_detail.html:67 msgid "edit" msgstr "" -#: apps/logs/models.py:62 apps/note/tables.py:120 apps/note/tables.py:150 -#: apps/wei/tables.py:65 +#: apps/logs/models.py:62 apps/note/tables.py:138 apps/note/tables.py:166 +#: apps/permission/models.py:130 apps/wei/tables.py:65 msgid "delete" msgstr "" @@ -275,39 +291,69 @@ msgstr "" msgid "changelogs" msgstr "" +#: apps/member/admin.py:53 apps/member/models.py:178 +#: templates/member/club_info.html:41 +msgid "membership fee (paid students)" +msgstr "" + +#: apps/member/admin.py:54 apps/member/models.py:183 +#: templates/member/club_info.html:44 +msgid "membership fee (unpaid students)" +msgstr "" + +#: apps/member/admin.py:68 apps/member/models.py:270 +msgid "roles" +msgstr "" + +#: apps/member/admin.py:69 apps/member/models.py:284 +msgid "fee" +msgstr "" + #: apps/member/apps.py:14 apps/wei/tables.py:150 apps/wei/tables.py:181 msgid "member" msgstr "" -#: apps/member/forms.py:62 apps/registration/forms.py:44 +#: apps/member/forms.py:58 apps/member/views.py:82 +msgid "An alias with a similar name already exists." +msgstr "" + +#: apps/member/forms.py:81 apps/registration/forms.py:44 msgid "Inscription paid by Société Générale" msgstr "" -#: apps/member/forms.py:64 apps/registration/forms.py:46 +#: apps/member/forms.py:83 apps/registration/forms.py:46 msgid "Check this case is the Société Générale paid the inscription." msgstr "" -#: apps/member/forms.py:69 apps/registration/forms.py:51 +#: apps/member/forms.py:88 apps/registration/forms.py:51 msgid "Credit type" msgstr "" -#: apps/member/forms.py:70 apps/registration/forms.py:52 +#: apps/member/forms.py:89 apps/registration/forms.py:52 msgid "No credit" msgstr "" -#: apps/member/forms.py:72 +#: apps/member/forms.py:91 msgid "You can credit the note of the user." msgstr "" -#: apps/member/forms.py:76 apps/registration/forms.py:57 +#: apps/member/forms.py:95 apps/registration/forms.py:57 msgid "Credit amount" msgstr "" -#: apps/member/forms.py:93 apps/registration/forms.py:74 -#: apps/treasury/forms.py:125 templates/note/transaction_form.html:132 +#: apps/member/forms.py:112 apps/registration/forms.py:74 +#: apps/treasury/forms.py:124 templates/note/transaction_form.html:135 msgid "Bank" msgstr "" +#: apps/member/forms.py:138 +msgid "User" +msgstr "" + +#: apps/member/forms.py:152 +msgid "Roles" +msgstr "" + #: apps/member/models.py:34 #: templates/registration/future_profile_detail.html:40 #: templates/wei/weimembership_form.html:48 @@ -428,6 +474,10 @@ msgstr "" msgid "user profile" msgstr "" +#: apps/member/models.py:134 +msgid "Activate your Note Kfet account" +msgstr "" + #: apps/member/models.py:156 templates/member/club_info.html:57 #: templates/registration/future_profile_detail.html:22 #: templates/wei/weiclub_info.html:52 templates/wei/weimembership_form.html:24 @@ -446,14 +496,6 @@ msgstr "" msgid "Uncheck if this club don't require memberships." msgstr "" -#: apps/member/models.py:178 templates/member/club_info.html:41 -msgid "membership fee (paid students)" -msgstr "" - -#: apps/member/models.py:183 templates/member/club_info.html:44 -msgid "membership fee (unpaid students)" -msgstr "" - #: apps/member/models.py:189 templates/member/club_info.html:33 msgid "membership duration" msgstr "" @@ -480,7 +522,7 @@ msgid "" "members can renew their membership." msgstr "" -#: apps/member/models.py:240 apps/member/models.py:283 +#: apps/member/models.py:240 apps/member/models.py:265 #: apps/note/models/notes.py:139 msgid "club" msgstr "" @@ -489,98 +531,136 @@ msgstr "" msgid "clubs" msgstr "" -#: apps/member/models.py:261 apps/permission/models.py:318 -msgid "role" -msgstr "" - -#: apps/member/models.py:262 apps/member/models.py:288 -msgid "roles" -msgstr "" - -#: apps/member/models.py:293 +#: apps/member/models.py:275 msgid "membership starts on" msgstr "" -#: apps/member/models.py:297 +#: apps/member/models.py:279 msgid "membership ends on" msgstr "" -#: apps/member/models.py:302 -msgid "fee" -msgstr "" - -#: apps/member/models.py:320 apps/member/views.py:505 apps/wei/views.py:768 +#: apps/member/models.py:303 apps/member/views.py:535 apps/wei/views.py:797 msgid "User is not a member of the parent club" msgstr "" -#: apps/member/models.py:330 apps/member/views.py:514 +#: apps/member/models.py:310 +#, python-brace-format +msgid "The role {role} does not apply to the club {club}." +msgstr "" + +#: apps/member/models.py:321 apps/member/views.py:544 msgid "User is already a member of the club" msgstr "" -#: apps/member/models.py:381 +#: apps/member/models.py:372 #, python-brace-format msgid "Membership of {user} for the club {club}" msgstr "" -#: apps/member/models.py:384 +#: apps/member/models.py:375 msgid "membership" msgstr "" -#: apps/member/models.py:385 +#: apps/member/models.py:376 msgid "memberships" msgstr "" -#: apps/member/tables.py:112 +#: apps/member/tables.py:113 msgid "Renew" msgstr "" -#: apps/member/views.py:62 apps/registration/forms.py:23 -msgid "This address must be valid." -msgstr "" - -#: apps/member/views.py:65 templates/member/profile_info.html:47 +#: apps/member/views.py:57 templates/member/profile_info.html:47 #: templates/registration/future_profile_detail.html:48 -#: templates/wei/weimembership_form.html:124 +#: templates/wei/weimembership_form.html:130 msgid "Update Profile" msgstr "" -#: apps/member/views.py:75 -msgid "An alias with a similar name already exists." +#: apps/member/views.py:70 apps/registration/forms.py:23 +msgid "This address must be valid." msgstr "" -#: apps/member/views.py:181 +#: apps/member/views.py:128 +msgid "Profile detail" +msgstr "" + +#: apps/member/views.py:162 msgid "Search user" msgstr "" -#: apps/member/views.py:500 apps/wei/views.py:759 +#: apps/member/views.py:196 apps/member/views.py:382 +msgid "Note aliases" +msgstr "" + +#: apps/member/views.py:210 +msgid "Update note picture" +msgstr "" + +#: apps/member/views.py:268 templates/member/profile_info.html:43 +msgid "Manage auth token" +msgstr "" + +#: apps/member/views.py:296 +msgid "Create new club" +msgstr "" + +#: apps/member/views.py:308 +msgid "Search club" +msgstr "" + +#: apps/member/views.py:333 +msgid "Club detail" +msgstr "" + +#: apps/member/views.py:399 +msgid "Update club" +msgstr "" + +#: apps/member/views.py:433 +msgid "Add new member to the club" +msgstr "" + +#: apps/member/views.py:530 apps/wei/views.py:788 msgid "" "This user don't have enough money to join this club, and can't have a " "negative balance." msgstr "" -#: apps/member/views.py:518 +#: apps/member/views.py:548 msgid "The membership must start after {:%m-%d-%Y}." msgstr "" -#: apps/member/views.py:523 +#: apps/member/views.py:553 msgid "The membership must begin before {:%m-%d-%Y}." msgstr "" -#: apps/member/views.py:540 apps/member/views.py:542 apps/member/views.py:544 -#: apps/registration/views.py:289 apps/registration/views.py:291 -#: apps/registration/views.py:293 +#: apps/member/views.py:570 apps/member/views.py:572 apps/member/views.py:574 +#: apps/registration/views.py:292 apps/registration/views.py:294 +#: apps/registration/views.py:296 msgid "This field is required." msgstr "" -#: apps/note/admin.py:120 apps/note/models/transactions.py:100 +#: apps/member/views.py:642 +msgid "Manage roles of an user in the club" +msgstr "" + +#: apps/member/views.py:667 +msgid "Members of the club" +msgstr "" + +#: apps/note/admin.py:134 apps/note/models/transactions.py:106 msgid "source" msgstr "" -#: apps/note/admin.py:128 apps/note/admin.py:170 -#: apps/note/models/transactions.py:55 apps/note/models/transactions.py:113 +#: apps/note/admin.py:142 apps/note/admin.py:192 +#: apps/note/models/transactions.py:55 apps/note/models/transactions.py:119 msgid "destination" msgstr "" +#: apps/note/admin.py:197 apps/note/models/transactions.py:59 +#: apps/note/models/transactions.py:137 +msgid "amount" +msgstr "" + #: apps/note/forms.py:14 msgid "select an image" msgstr "" @@ -619,7 +699,7 @@ msgstr "" msgid "display image" msgstr "" -#: apps/note/models/notes.py:53 apps/note/models/transactions.py:123 +#: apps/note/models/notes.py:53 apps/note/models/transactions.py:129 msgid "created at" msgstr "" @@ -702,204 +782,248 @@ msgstr "" msgid "A template with this name already exist" msgstr "" -#: apps/note/models/transactions.py:59 apps/note/models/transactions.py:131 -msgid "amount" -msgstr "" - #: apps/note/models/transactions.py:60 msgid "in centimes" msgstr "" -#: apps/note/models/transactions.py:71 +#: apps/note/models/transactions.py:72 msgid "display" msgstr "" -#: apps/note/models/transactions.py:81 +#: apps/note/models/transactions.py:77 +msgid "highlighted" +msgstr "" + +#: apps/note/models/transactions.py:87 msgid "transaction template" msgstr "" -#: apps/note/models/transactions.py:82 +#: apps/note/models/transactions.py:88 msgid "transaction templates" msgstr "" -#: apps/note/models/transactions.py:106 apps/note/models/transactions.py:119 -#: apps/note/tables.py:33 apps/note/tables.py:42 +#: apps/note/models/transactions.py:112 apps/note/models/transactions.py:125 +#: apps/note/tables.py:35 apps/note/tables.py:44 msgid "used alias" msgstr "" -#: apps/note/models/transactions.py:127 +#: apps/note/models/transactions.py:133 msgid "quantity" msgstr "" -#: apps/note/models/transactions.py:135 +#: apps/note/models/transactions.py:141 msgid "reason" msgstr "" -#: apps/note/models/transactions.py:145 apps/note/tables.py:95 +#: apps/note/models/transactions.py:151 apps/note/tables.py:113 msgid "invalidity reason" msgstr "" -#: apps/note/models/transactions.py:153 +#: apps/note/models/transactions.py:159 msgid "transaction" msgstr "" -#: apps/note/models/transactions.py:154 +#: apps/note/models/transactions.py:160 #: templates/treasury/sogecredit_detail.html:22 msgid "transactions" msgstr "" -#: apps/note/models/transactions.py:216 -#: templates/activity/activity_entry.html:13 templates/base.html:98 -#: templates/note/transaction_form.html:19 -#: templates/note/transaction_form.html:140 +#: apps/note/models/transactions.py:175 +msgid "" +"The transaction can't be saved since the source note or the destination note " +"is not active." +msgstr "" + +#: apps/note/models/transactions.py:230 +#: templates/activity/activity_entry.html:13 templates/base.html:99 +#: templates/note/transaction_form.html:15 +#: templates/note/transaction_form.html:143 msgid "Transfer" msgstr "" -#: apps/note/models/transactions.py:239 +#: apps/note/models/transactions.py:253 msgid "Template" msgstr "" -#: apps/note/models/transactions.py:254 +#: apps/note/models/transactions.py:268 msgid "first_name" msgstr "" -#: apps/note/models/transactions.py:259 +#: apps/note/models/transactions.py:273 msgid "bank" msgstr "" -#: apps/note/models/transactions.py:265 +#: apps/note/models/transactions.py:279 #: templates/activity/activity_entry.html:17 -#: templates/note/transaction_form.html:24 +#: templates/note/transaction_form.html:20 msgid "Credit" msgstr "" -#: apps/note/models/transactions.py:265 templates/note/transaction_form.html:28 +#: apps/note/models/transactions.py:279 templates/note/transaction_form.html:24 msgid "Debit" msgstr "" -#: apps/note/models/transactions.py:281 apps/note/models/transactions.py:286 +#: apps/note/models/transactions.py:290 +msgid "" +"A special transaction is only possible between a Note associated to a " +"payment method and a User or a Club" +msgstr "" + +#: apps/note/models/transactions.py:307 apps/note/models/transactions.py:312 msgid "membership transaction" msgstr "" -#: apps/note/models/transactions.py:282 apps/treasury/models.py:227 +#: apps/note/models/transactions.py:308 apps/treasury/models.py:227 msgid "membership transactions" msgstr "" -#: apps/note/tables.py:57 +#: apps/note/tables.py:63 msgid "Click to invalidate" msgstr "" -#: apps/note/tables.py:57 +#: apps/note/tables.py:63 msgid "Click to validate" msgstr "" -#: apps/note/tables.py:93 +#: apps/note/tables.py:111 msgid "No reason specified" msgstr "" -#: apps/note/tables.py:122 apps/note/tables.py:152 apps/wei/tables.py:66 +#: apps/note/tables.py:140 apps/note/tables.py:168 apps/wei/tables.py:66 #: templates/treasury/sogecredit_detail.html:59 #: templates/wei/weiregistration_confirm_delete.html:32 msgid "Delete" msgstr "" -#: apps/note/tables.py:147 apps/wei/tables.py:42 apps/wei/tables.py:43 +#: apps/note/tables.py:163 apps/wei/tables.py:42 apps/wei/tables.py:43 #: templates/member/club_info.html:67 templates/note/conso_form.html:128 #: templates/wei/bus_tables.html:15 templates/wei/busteam_tables.html:15 #: templates/wei/busteam_tables.html:33 templates/wei/weiclub_info.html:68 msgid "Edit" msgstr "" -#: apps/note/views.py:41 +#: apps/note/views.py:33 msgid "Transfer money" msgstr "" -#: apps/note/views.py:137 templates/base.html:93 +#: apps/note/views.py:67 +msgid "Create new button" +msgstr "" + +#: apps/note/views.py:76 +msgid "Search button" +msgstr "" + +#: apps/note/views.py:99 +msgid "Update button" +msgstr "" + +#: apps/note/views.py:136 templates/base.html:94 msgid "Consumptions" msgstr "" -#: apps/permission/models.py:82 +#: apps/permission/models.py:92 #, python-brace-format msgid "Can {type} {model}.{field} in {query}" msgstr "" -#: apps/permission/models.py:84 +#: apps/permission/models.py:94 #, python-brace-format msgid "Can {type} {model} in {query}" msgstr "" -#: apps/permission/models.py:97 +#: apps/permission/models.py:107 msgid "rank" msgstr "" -#: apps/permission/models.py:110 +#: apps/permission/models.py:120 msgid "permission mask" msgstr "" -#: apps/permission/models.py:111 +#: apps/permission/models.py:121 msgid "permission masks" msgstr "" -#: apps/permission/models.py:151 +#: apps/permission/models.py:127 +msgid "add" +msgstr "" + +#: apps/permission/models.py:128 +msgid "view" +msgstr "" + +#: apps/permission/models.py:129 +msgid "change" +msgstr "" + +#: apps/permission/models.py:161 msgid "query" msgstr "" -#: apps/permission/models.py:164 +#: apps/permission/models.py:174 msgid "mask" msgstr "" -#: apps/permission/models.py:170 +#: apps/permission/models.py:180 msgid "field" msgstr "" -#: apps/permission/models.py:175 +#: apps/permission/models.py:185 msgid "" "Tells if the permission should be granted even if the membership of the user " "is expired." msgstr "" -#: apps/permission/models.py:176 templates/permission/all_rights.html:26 +#: apps/permission/models.py:186 templates/permission/all_rights.html:26 msgid "permanent" msgstr "" -#: apps/permission/models.py:187 +#: apps/permission/models.py:197 msgid "permission" msgstr "" -#: apps/permission/models.py:188 apps/permission/models.py:322 +#: apps/permission/models.py:198 apps/permission/models.py:337 msgid "permissions" msgstr "" -#: apps/permission/models.py:193 +#: apps/permission/models.py:203 msgid "Specifying field applies only to view and change permission types." msgstr "" -#: apps/permission/models.py:329 apps/permission/models.py:330 +#: apps/permission/models.py:342 +msgid "for club" +msgstr "" + +#: apps/permission/models.py:352 apps/permission/models.py:353 msgid "role permissions" msgstr "" -#: apps/permission/signals.py:62 +#: apps/permission/signals.py:63 #, python-brace-format msgid "" "You don't have the permission to change the field {field} on this instance " "of model {app_label}.{model_name}." msgstr "" -#: apps/permission/signals.py:72 +#: apps/permission/signals.py:73 #, python-brace-format msgid "" "You don't have the permission to add this instance of model {app_label}." "{model_name}." msgstr "" -#: apps/permission/signals.py:99 +#: apps/permission/signals.py:101 #, python-brace-format msgid "" "You don't have the permission to delete this instance of model {app_label}." "{model_name}." msgstr "" -#: apps/permission/views.py:47 +#: apps/permission/views.py:44 templates/base.html:136 +msgid "Rights" +msgstr "" + +#: apps/permission/views.py:49 msgid "All rights" msgstr "" @@ -925,10 +1049,18 @@ msgstr "" msgid "Join Kfet Club" msgstr "" -#: apps/registration/views.py:78 +#: apps/registration/views.py:38 +msgid "Register new user" +msgstr "" + +#: apps/registration/views.py:80 msgid "Email validation" msgstr "" +#: apps/registration/views.py:82 +msgid "Validate email" +msgstr "" + #: apps/registration/views.py:124 msgid "Email validation unsuccessful" msgstr "" @@ -937,28 +1069,44 @@ msgstr "" msgid "Email validation email sent" msgstr "" -#: apps/registration/views.py:188 +#: apps/registration/views.py:143 +msgid "Resend email validation link" +msgstr "" + +#: apps/registration/views.py:161 +msgid "Pre-registered users list" +msgstr "" + +#: apps/registration/views.py:190 msgid "Unregistered users" msgstr "" -#: apps/registration/views.py:255 +#: apps/registration/views.py:203 +msgid "Registration detail" +msgstr "" + +#: apps/registration/views.py:258 msgid "You must join the BDE." msgstr "" -#: apps/registration/views.py:277 +#: apps/registration/views.py:280 msgid "You must join BDE club before joining Kfet club." msgstr "" -#: apps/registration/views.py:282 +#: apps/registration/views.py:285 msgid "" "The entered amount is not enough for the memberships, should be at least {}" msgstr "" -#: apps/treasury/apps.py:12 templates/base.html:125 +#: apps/registration/views.py:360 +msgid "Invalidate pre-registration" +msgstr "" + +#: apps/treasury/apps.py:12 templates/base.html:126 msgid "Treasury" msgstr "" -#: apps/treasury/forms.py:85 apps/treasury/forms.py:133 +#: apps/treasury/forms.py:84 apps/treasury/forms.py:132 #: templates/activity/activity_form.html:9 #: templates/activity/activity_invite.html:8 #: templates/django_filters/rest_framework/form.html:5 @@ -970,20 +1118,20 @@ msgstr "" msgid "Submit" msgstr "" -#: apps/treasury/forms.py:87 +#: apps/treasury/forms.py:86 msgid "Close" msgstr "" -#: apps/treasury/forms.py:96 +#: apps/treasury/forms.py:95 msgid "Remittance is already closed." msgstr "" -#: apps/treasury/forms.py:101 +#: apps/treasury/forms.py:100 msgid "You can't change the type of the remittance." msgstr "" -#: apps/treasury/forms.py:127 apps/treasury/tables.py:47 -#: apps/treasury/tables.py:113 templates/note/transaction_form.html:95 +#: apps/treasury/forms.py:126 apps/treasury/tables.py:47 +#: apps/treasury/tables.py:113 templates/note/transaction_form.html:97 #: templates/treasury/remittance_form.html:18 msgid "Amount" msgstr "" @@ -1004,7 +1152,7 @@ msgstr "" msgid "Description" msgstr "" -#: apps/treasury/models.py:48 templates/note/transaction_form.html:120 +#: apps/treasury/models.py:48 templates/note/transaction_form.html:123 msgid "Name" msgstr "" @@ -1151,13 +1299,50 @@ msgstr "" msgid "No" msgstr "" -#: apps/wei/apps.py:10 apps/wei/models.py:47 apps/wei/models.py:48 -#: apps/wei/models.py:59 apps/wei/models.py:164 templates/base.html:130 +#: apps/treasury/views.py:39 +msgid "Create new invoice" +msgstr "" + +#: apps/treasury/views.py:82 templates/treasury/invoice_form.html:6 +msgid "Invoices list" +msgstr "" + +#: apps/treasury/views.py:91 +msgid "Update an invoice" +msgstr "" + +#: apps/treasury/views.py:205 +msgid "Create a new remittance" +msgstr "" + +#: apps/treasury/views.py:226 templates/treasury/remittance_form.html:9 +#: templates/treasury/specialtransactionproxy_form.html:7 +msgid "Remittances list" +msgstr "" + +#: apps/treasury/views.py:276 +msgid "Update a remittance" +msgstr "" + +#: apps/treasury/views.py:301 +msgid "Attach a transaction to a remittance" +msgstr "" + +#: apps/treasury/views.py:345 +msgid "List of credits from the Société générale" +msgstr "" + +#: apps/treasury/views.py:384 +msgid "Manage credits from the Société générale" +msgstr "" + +#: apps/wei/apps.py:10 apps/wei/models.py:48 apps/wei/models.py:49 +#: apps/wei/models.py:60 apps/wei/models.py:166 templates/base.html:131 msgid "WEI" msgstr "" -#: apps/wei/forms/registration.py:47 apps/wei/models.py:111 -#: apps/wei/models.py:273 +#: apps/wei/forms/registration.py:47 apps/wei/models.py:112 +#: apps/wei/models.py:297 msgid "bus" msgstr "" @@ -1178,7 +1363,7 @@ msgid "" msgstr "" #: apps/wei/forms/registration.py:61 apps/wei/forms/registration.py:67 -#: apps/wei/models.py:145 +#: apps/wei/models.py:147 msgid "WEI Roles" msgstr "" @@ -1190,151 +1375,159 @@ msgstr "" msgid "This team doesn't belong to the given bus." msgstr "" -#: apps/wei/models.py:22 templates/wei/weiclub_info.html:23 +#: apps/wei/models.py:23 templates/wei/weiclub_info.html:23 msgid "year" msgstr "" -#: apps/wei/models.py:26 templates/wei/weiclub_info.html:17 +#: apps/wei/models.py:27 templates/wei/weiclub_info.html:17 msgid "date start" msgstr "" -#: apps/wei/models.py:30 templates/wei/weiclub_info.html:20 +#: apps/wei/models.py:31 templates/wei/weiclub_info.html:20 msgid "date end" msgstr "" -#: apps/wei/models.py:75 +#: apps/wei/models.py:76 msgid "survey information" msgstr "" -#: apps/wei/models.py:76 +#: apps/wei/models.py:77 msgid "Information about the survey for new members, encoded in JSON" msgstr "" -#: apps/wei/models.py:98 +#: apps/wei/models.py:99 msgid "Bus" msgstr "" -#: apps/wei/models.py:99 templates/wei/weiclub_tables.html:79 +#: apps/wei/models.py:100 templates/wei/weiclub_tables.html:79 msgid "Buses" msgstr "" -#: apps/wei/models.py:119 +#: apps/wei/models.py:121 msgid "color" msgstr "" -#: apps/wei/models.py:120 +#: apps/wei/models.py:122 msgid "The color of the T-Shirt, stored with its number equivalent" msgstr "" -#: apps/wei/models.py:134 +#: apps/wei/models.py:136 msgid "Bus team" msgstr "" -#: apps/wei/models.py:135 +#: apps/wei/models.py:137 msgid "Bus teams" msgstr "" -#: apps/wei/models.py:144 +#: apps/wei/models.py:146 msgid "WEI Role" msgstr "" -#: apps/wei/models.py:169 +#: apps/wei/models.py:171 msgid "Credit from Société générale" msgstr "" -#: apps/wei/models.py:174 +#: apps/wei/models.py:176 msgid "Caution check given" msgstr "" -#: apps/wei/models.py:178 templates/wei/weimembership_form.html:62 +#: apps/wei/models.py:180 templates/wei/weimembership_form.html:68 msgid "birth date" msgstr "" -#: apps/wei/models.py:184 +#: apps/wei/models.py:186 apps/wei/models.py:196 msgid "Male" msgstr "" -#: apps/wei/models.py:185 +#: apps/wei/models.py:187 apps/wei/models.py:197 msgid "Female" msgstr "" -#: apps/wei/models.py:186 +#: apps/wei/models.py:188 msgid "Non binary" msgstr "" -#: apps/wei/models.py:188 templates/wei/weimembership_form.html:59 +#: apps/wei/models.py:190 templates/wei/weimembership_form.html:59 msgid "gender" msgstr "" -#: apps/wei/models.py:194 templates/wei/weimembership_form.html:65 +#: apps/wei/models.py:199 templates/wei/weimembership_form.html:62 +msgid "clothing cut" +msgstr "" + +#: apps/wei/models.py:212 templates/wei/weimembership_form.html:65 +msgid "clothing size" +msgstr "" + +#: apps/wei/models.py:218 templates/wei/weimembership_form.html:71 msgid "health issues" msgstr "" -#: apps/wei/models.py:199 templates/wei/weimembership_form.html:68 +#: apps/wei/models.py:223 templates/wei/weimembership_form.html:74 msgid "emergency contact name" msgstr "" -#: apps/wei/models.py:204 templates/wei/weimembership_form.html:71 +#: apps/wei/models.py:228 templates/wei/weimembership_form.html:77 msgid "emergency contact phone" msgstr "" -#: apps/wei/models.py:209 templates/wei/weimembership_form.html:74 +#: apps/wei/models.py:233 templates/wei/weimembership_form.html:80 msgid "" "Register on the mailing list to stay informed of the events of the campus (1 " "mail/week)" msgstr "" -#: apps/wei/models.py:214 templates/wei/weimembership_form.html:77 +#: apps/wei/models.py:238 templates/wei/weimembership_form.html:83 msgid "" "Register on the mailing list to stay informed of the sport events of the " "campus (1 mail/week)" msgstr "" -#: apps/wei/models.py:219 templates/wei/weimembership_form.html:80 +#: apps/wei/models.py:243 templates/wei/weimembership_form.html:86 msgid "" "Register on the mailing list to stay informed of the art events of the " "campus (1 mail/week)" msgstr "" -#: apps/wei/models.py:224 templates/wei/weimembership_form.html:56 +#: apps/wei/models.py:248 templates/wei/weimembership_form.html:56 msgid "first year" msgstr "" -#: apps/wei/models.py:225 +#: apps/wei/models.py:249 msgid "Tells if the user is new in the school." msgstr "" -#: apps/wei/models.py:230 +#: apps/wei/models.py:254 msgid "registration information" msgstr "" -#: apps/wei/models.py:231 +#: apps/wei/models.py:255 msgid "" "Information about the registration (buses for old members, survey fot the " "new members), encoded in JSON" msgstr "" -#: apps/wei/models.py:262 +#: apps/wei/models.py:286 msgid "WEI User" msgstr "" -#: apps/wei/models.py:263 +#: apps/wei/models.py:287 msgid "WEI Users" msgstr "" -#: apps/wei/models.py:283 +#: apps/wei/models.py:307 msgid "team" msgstr "" -#: apps/wei/models.py:293 +#: apps/wei/models.py:317 msgid "WEI registration" msgstr "" -#: apps/wei/models.py:297 +#: apps/wei/models.py:321 msgid "WEI membership" msgstr "" -#: apps/wei/models.py:298 +#: apps/wei/models.py:322 msgid "WEI memberships" msgstr "" @@ -1360,59 +1553,127 @@ msgstr "" msgid "members" msgstr "" -#: apps/wei/views.py:201 +#: apps/wei/views.py:56 +msgid "Search WEI" +msgstr "" + +#: apps/wei/views.py:74 templates/wei/weiclub_list.html:10 +msgid "Create WEI" +msgstr "" + +#: apps/wei/views.py:94 +msgid "WEI Detail" +msgstr "" + +#: apps/wei/views.py:189 +msgid "View members of the WEI" +msgstr "" + +#: apps/wei/views.py:217 msgid "Find WEI Membership" msgstr "" -#: apps/wei/views.py:236 +#: apps/wei/views.py:227 +msgid "View registrations to the WEI" +msgstr "" + +#: apps/wei/views.py:253 msgid "Find WEI Registration" msgstr "" -#: apps/wei/views.py:445 templates/wei/weiclub_info.html:62 +#: apps/wei/views.py:264 +msgid "Update the WEI" +msgstr "" + +#: apps/wei/views.py:285 +msgid "Create new bus" +msgstr "" + +#: apps/wei/views.py:316 +msgid "Update bus" +msgstr "" + +#: apps/wei/views.py:346 +msgid "Manage bus" +msgstr "" + +#: apps/wei/views.py:373 +msgid "Create new team" +msgstr "" + +#: apps/wei/views.py:405 +msgid "Update team" +msgstr "" + +#: apps/wei/views.py:436 +msgid "Manage WEI team" +msgstr "" + +#: apps/wei/views.py:458 +msgid "Register first year student to the WEI" +msgstr "" + +#: apps/wei/views.py:470 templates/wei/weiclub_info.html:62 msgid "Register 1A" msgstr "" -#: apps/wei/views.py:466 apps/wei/views.py:535 +#: apps/wei/views.py:491 apps/wei/views.py:561 msgid "This user is already registered to this WEI." msgstr "" -#: apps/wei/views.py:471 +#: apps/wei/views.py:496 msgid "" "This user can't be in her/his first year since he/she has already participed " "to a WEI." msgstr "" -#: apps/wei/views.py:499 templates/wei/weiclub_info.html:65 +#: apps/wei/views.py:513 +msgid "Register old student to the WEI" +msgstr "" + +#: apps/wei/views.py:525 templates/wei/weiclub_info.html:65 msgid "Register 2A+" msgstr "" -#: apps/wei/views.py:517 apps/wei/views.py:604 +#: apps/wei/views.py:543 apps/wei/views.py:631 msgid "You already opened an account in the Société générale." msgstr "" -#: apps/wei/views.py:664 +#: apps/wei/views.py:591 +msgid "Update WEI Registration" +msgstr "" + +#: apps/wei/views.py:681 +msgid "Delete WEI registration" +msgstr "" + +#: apps/wei/views.py:692 msgid "You don't have the right to delete this WEI registration." msgstr "" -#: apps/wei/views.py:763 +#: apps/wei/views.py:711 +msgid "Validate WEI registration" +msgstr "" + +#: apps/wei/views.py:792 msgid "This user didn't give her/his caution check." msgstr "" -#: apps/wei/views.py:837 apps/wei/views.py:857 apps/wei/views.py:867 +#: apps/wei/views.py:829 apps/wei/views.py:882 apps/wei/views.py:892 #: templates/wei/survey.html:12 templates/wei/survey_closed.html:12 #: templates/wei/survey_end.html:12 msgid "Survey WEI" msgstr "" -#: note_kfet/settings/base.py:154 +#: note_kfet/settings/base.py:155 msgid "German" msgstr "" -#: note_kfet/settings/base.py:155 +#: note_kfet/settings/base.py:156 msgid "English" msgstr "" -#: note_kfet/settings/base.py:156 +#: note_kfet/settings/base.py:157 msgid "French" msgstr "" @@ -1493,7 +1754,7 @@ msgid "Guests list" msgstr "" #: templates/activity/activity_entry.html:22 -#: templates/note/transaction_form.html:33 +#: templates/note/transaction_form.html:29 msgid "Entries" msgstr "" @@ -1521,27 +1782,23 @@ msgstr "" msgid "The ENS Paris-Saclay BDE note." msgstr "" -#: templates/base.html:103 +#: templates/base.html:104 msgid "Users" msgstr "" -#: templates/base.html:108 +#: templates/base.html:109 msgid "Clubs" msgstr "" -#: templates/base.html:114 +#: templates/base.html:115 msgid "Registrations" msgstr "" -#: templates/base.html:134 -msgid "Rights" +#: templates/base.html:141 +msgid "Admin" msgstr "" -#: templates/base.html:138 -msgid "Administration" -msgstr "" - -#: templates/base.html:177 +#: templates/base.html:180 msgid "" "Your e-mail address is not validated. Please check your mail inbox and click " "on the validation link." @@ -1594,23 +1851,36 @@ msgstr "" msgid "View Profile" msgstr "" -#: templates/member/club_list.html:8 -msgid "search clubs" -msgstr "" - -#: templates/member/club_list.html:12 +#: templates/member/club_list.html:9 msgid "Create club" msgstr "" -#: templates/member/club_list.html:19 +#: templates/member/club_list.html:16 msgid "Club listing" msgstr "" -#: templates/member/club_tables.html:7 -msgid "Member of the Club" +#: templates/member/club_members.html:16 +msgid "Display only active memberships" msgstr "" -#: templates/member/club_tables.html:20 templates/member/profile_tables.html:28 +#: templates/member/club_members.html:21 +msgid "Filter roles:" +msgstr "" + +#: templates/member/club_members.html:37 +#: templates/wei/weimembership_list.html:18 +msgid "There is no membership found with this pattern." +msgstr "" + +#: templates/member/club_tables.html:7 +msgid "Club managers" +msgstr "" + +#: templates/member/club_tables.html:20 +msgid "Club members" +msgstr "" + +#: templates/member/club_tables.html:33 templates/member/profile_tables.html:28 #: templates/wei/weiclub_tables.html:105 msgid "Transaction history" msgstr "" @@ -1646,10 +1916,6 @@ msgstr "" msgid "Change password" msgstr "" -#: templates/member/profile_info.html:43 -msgid "Manage auth token" -msgstr "" - #: templates/member/profile_tables.html:7 #: templates/registration/future_profile_detail.html:28 #: templates/wei/weimembership_form.html:30 @@ -1678,8 +1944,8 @@ msgstr "" msgid "Consum" msgstr "" -#: templates/note/conso_form.html:39 templates/note/transaction_form.html:61 -#: templates/note/transaction_form.html:76 +#: templates/note/conso_form.html:39 templates/note/transaction_form.html:57 +#: templates/note/transaction_form.html:78 msgid "Name or alias..." msgstr "" @@ -1692,7 +1958,7 @@ msgid "Consume!" msgstr "" #: templates/note/conso_form.html:71 -msgid "Most used buttons" +msgid "Highlighted buttons" msgstr "" #: templates/note/conso_form.html:134 @@ -1703,31 +1969,31 @@ msgstr "" msgid "Double consumptions" msgstr "" -#: templates/note/conso_form.html:150 templates/note/transaction_form.html:151 +#: templates/note/conso_form.html:150 templates/note/transaction_form.html:154 msgid "Recent transactions history" msgstr "" -#: templates/note/transaction_form.html:15 -msgid "Gift" -msgstr "" - -#: templates/note/transaction_form.html:55 +#: templates/note/transaction_form.html:51 msgid "Select emitters" msgstr "" -#: templates/note/transaction_form.html:70 +#: templates/note/transaction_form.html:61 +msgid "I am the emitter" +msgstr "" + +#: templates/note/transaction_form.html:72 msgid "Select receivers" msgstr "" -#: templates/note/transaction_form.html:87 +#: templates/note/transaction_form.html:89 msgid "Action" msgstr "" -#: templates/note/transaction_form.html:102 +#: templates/note/transaction_form.html:104 msgid "Reason" msgstr "" -#: templates/note/transaction_form.html:110 +#: templates/note/transaction_form.html:113 msgid "Transfer type" msgstr "" @@ -1747,31 +2013,23 @@ msgstr "" msgid "Current price" msgstr "" -#: templates/note/transactiontemplate_list.html:9 -msgid "Search button" -msgstr "" - -#: templates/note/transactiontemplate_list.html:11 +#: templates/note/transactiontemplate_list.html:8 msgid "Name of the button..." msgstr "" -#: templates/note/transactiontemplate_list.html:16 -msgid "Display visible buttons only" -msgstr "" - -#: templates/note/transactiontemplate_list.html:21 +#: templates/note/transactiontemplate_list.html:10 msgid "New button" msgstr "" -#: templates/note/transactiontemplate_list.html:28 +#: templates/note/transactiontemplate_list.html:17 msgid "buttons listing " msgstr "" -#: templates/note/transactiontemplate_list.html:86 +#: templates/note/transactiontemplate_list.html:55 msgid "button successfully deleted " msgstr "" -#: templates/note/transactiontemplate_list.html:90 +#: templates/note/transactiontemplate_list.html:59 msgid "Unable to delete button " msgstr "" @@ -1783,6 +2041,10 @@ msgstr "" msgid "Own this role in the clubs" msgstr "" +#: templates/permission/all_rights.html:26 +msgid "Mask:" +msgstr "" + #: templates/permission/all_rights.html:26 msgid "Query:" msgstr "" @@ -1821,8 +2083,8 @@ msgid "Validate account" msgstr "" #: templates/registration/future_profile_detail.html:64 -#: templates/wei/weimembership_form.html:134 -#: templates/wei/weimembership_form.html:192 +#: templates/wei/weimembership_form.html:140 +#: templates/wei/weimembership_form.html:198 msgid "Validate registration" msgstr "" @@ -1843,7 +2105,7 @@ msgid "Log in again" msgstr "" #: templates/registration/login.html:7 templates/registration/login.html:8 -#: templates/registration/login.html:21 +#: templates/registration/login.html:31 #: templates/registration/password_reset_complete.html:10 msgid "Log in" msgstr "" @@ -1852,10 +2114,17 @@ msgstr "" #, python-format msgid "" "You are authenticated as %(username)s, but are not authorized to access this " -"page. Would you like to login to a different account?" +"page. Would you like to login to a different account, or with a higher " +"permission mask?" msgstr "" -#: templates/registration/login.html:22 +#: templates/registration/login.html:23 +msgid "" +"You must be logged with a staff account with the higher mask to access " +"Django Admin." +msgstr "" + +#: templates/registration/login.html:32 msgid "Forgotten your password or username?" msgstr "" @@ -1955,10 +2224,6 @@ msgid "" "by following the link you received." msgstr "" -#: templates/treasury/invoice_form.html:6 -msgid "Invoices list" -msgstr "" - #: templates/treasury/invoice_form.html:41 msgid "Add product" msgstr "" @@ -1981,11 +2246,6 @@ msgstr "" msgid "Remittance #" msgstr "" -#: templates/treasury/remittance_form.html:9 -#: templates/treasury/specialtransactionproxy_form.html:7 -msgid "Remittances list" -msgstr "" - #: templates/treasury/remittance_form.html:12 msgid "Count" msgstr "" @@ -2030,6 +2290,10 @@ msgstr "" msgid "Closed remittances" msgstr "" +#: templates/treasury/remittance_list.html:62 +msgid "There is no closed remittance yet." +msgstr "" + #: templates/treasury/sogecredit_detail.html:29 msgid "total amount" msgstr "" @@ -2131,15 +2395,7 @@ msgstr "" msgid "View WEI" msgstr "" -#: templates/wei/weiclub_list.html:8 -msgid "search WEI" -msgstr "" - -#: templates/wei/weiclub_list.html:12 -msgid "Create WEI" -msgstr "" - -#: templates/wei/weiclub_list.html:19 +#: templates/wei/weiclub_list.html:18 msgid "WEI listing" msgstr "" @@ -2171,64 +2427,64 @@ msgstr "" msgid "ENS year" msgstr "" -#: templates/wei/weimembership_form.html:83 +#: templates/wei/weimembership_form.html:89 msgid "Payment from Société générale" msgstr "" -#: templates/wei/weimembership_form.html:87 +#: templates/wei/weimembership_form.html:93 msgid "Suggested bus from the survey:" msgstr "" -#: templates/wei/weimembership_form.html:92 +#: templates/wei/weimembership_form.html:98 msgid "Raw survey information" msgstr "" -#: templates/wei/weimembership_form.html:102 +#: templates/wei/weimembership_form.html:108 msgid "The algorithm didn't run." msgstr "" -#: templates/wei/weimembership_form.html:105 +#: templates/wei/weimembership_form.html:111 msgid "caution check given" msgstr "" -#: templates/wei/weimembership_form.html:109 +#: templates/wei/weimembership_form.html:115 msgid "preferred bus" msgstr "" -#: templates/wei/weimembership_form.html:112 +#: templates/wei/weimembership_form.html:118 msgid "preferred team" msgstr "" -#: templates/wei/weimembership_form.html:115 +#: templates/wei/weimembership_form.html:121 msgid "preferred roles" msgstr "" -#: templates/wei/weimembership_form.html:122 +#: templates/wei/weimembership_form.html:128 #: templates/wei/weiregistration_confirm_delete.html:31 msgid "Update registration" msgstr "" -#: templates/wei/weimembership_form.html:138 +#: templates/wei/weimembership_form.html:144 msgid "The registration is already validated and can't be unvalidated." msgstr "" -#: templates/wei/weimembership_form.html:139 +#: templates/wei/weimembership_form.html:145 msgid "The user joined the bus" msgstr "" -#: templates/wei/weimembership_form.html:140 +#: templates/wei/weimembership_form.html:146 msgid "in the team" msgstr "" -#: templates/wei/weimembership_form.html:141 +#: templates/wei/weimembership_form.html:147 msgid "in no team (staff)" msgstr "" -#: templates/wei/weimembership_form.html:141 +#: templates/wei/weimembership_form.html:147 msgid "with the following roles:" msgstr "" -#: templates/wei/weimembership_form.html:146 +#: templates/wei/weimembership_form.html:152 msgid "" "\n" " The WEI will be paid by Société générale. The " @@ -2240,7 +2496,7 @@ msgid "" " " msgstr "" -#: templates/wei/weimembership_form.html:156 +#: templates/wei/weimembership_form.html:162 #, python-format msgid "" "\n" @@ -2249,15 +2505,15 @@ msgid "" " " msgstr "" -#: templates/wei/weimembership_form.html:163 +#: templates/wei/weimembership_form.html:169 msgid "The note has enough money, the registration is possible." msgstr "" -#: templates/wei/weimembership_form.html:170 +#: templates/wei/weimembership_form.html:176 msgid "The user didn't give her/his caution check." msgstr "" -#: templates/wei/weimembership_form.html:178 +#: templates/wei/weimembership_form.html:184 #, python-format msgid "" "\n" @@ -2271,10 +2527,6 @@ msgid "" " " msgstr "" -#: templates/wei/weimembership_list.html:18 -msgid "There is no membership found with this pattern." -msgstr "" - #: templates/wei/weimembership_list.html:24 msgid "View unvalidated registrations..." msgstr "" diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index 4af9cfd5..54c70c71 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-05-07 20:56+0200\n" +"POT-Creation-Date: 2020-08-01 15:06+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -45,11 +45,11 @@ msgid "You can't invite more than 3 people to this activity." msgstr "Vous ne pouvez pas inviter plus de 3 personnes à cette activité." #: apps/activity/models.py:23 apps/activity/models.py:48 -#: apps/member/models.py:151 apps/member/models.py:255 -#: apps/note/models/notes.py:188 apps/note/models/transactions.py:25 -#: apps/note/models/transactions.py:45 apps/note/models/transactions.py:249 -#: apps/wei/models.py:64 templates/member/club_info.html:13 -#: templates/member/profile_info.html:14 +#: apps/member/models.py:151 apps/note/models/notes.py:188 +#: apps/note/models/transactions.py:25 apps/note/models/transactions.py:45 +#: apps/note/models/transactions.py:263 apps/permission/models.py:332 +#: apps/wei/models.py:65 apps/wei/models.py:117 +#: templates/member/club_info.html:13 templates/member/profile_info.html:14 #: templates/registration/future_profile_detail.html:16 #: templates/wei/weiclub_info.html:13 templates/wei/weimembership_form.html:18 msgid "name" @@ -71,22 +71,22 @@ msgstr "type d'activité" msgid "activity types" msgstr "types d'activité" -#: apps/activity/models.py:53 apps/note/models/transactions.py:75 -#: apps/permission/models.py:103 apps/permission/models.py:182 -#: apps/wei/models.py:70 apps/wei/models.py:126 +#: apps/activity/models.py:53 apps/note/models/transactions.py:81 +#: apps/permission/models.py:113 apps/permission/models.py:192 +#: apps/wei/models.py:71 apps/wei/models.py:128 #: templates/activity/activity_detail.html:16 msgid "description" msgstr "description" #: apps/activity/models.py:60 apps/note/models/notes.py:164 -#: apps/note/models/transactions.py:65 apps/permission/models.py:157 +#: apps/note/models/transactions.py:66 apps/permission/models.py:167 #: templates/activity/activity_detail.html:19 msgid "type" msgstr "type" -#: apps/activity/models.py:66 apps/logs/models.py:21 apps/member/models.py:277 +#: apps/activity/models.py:66 apps/logs/models.py:21 apps/member/models.py:259 #: apps/note/models/notes.py:117 apps/treasury/models.py:221 -#: apps/wei/models.py:157 templates/treasury/sogecredit_detail.html:14 +#: apps/wei/models.py:159 templates/treasury/sogecredit_detail.html:14 #: templates/wei/survey.html:16 msgid "user" msgstr "utilisateur" @@ -107,7 +107,7 @@ msgstr "date de début" msgid "end date" msgstr "date de fin" -#: apps/activity/models.py:93 apps/note/models/transactions.py:140 +#: apps/activity/models.py:93 apps/note/models/transactions.py:146 #: templates/activity/activity_detail.html:47 msgid "valid" msgstr "valide" @@ -187,14 +187,14 @@ msgstr "supprimer" msgid "Type" msgstr "Type" -#: apps/activity/tables.py:77 apps/member/forms.py:83 -#: apps/registration/forms.py:64 apps/treasury/forms.py:121 +#: apps/activity/tables.py:77 apps/member/forms.py:102 +#: apps/registration/forms.py:64 apps/treasury/forms.py:120 msgid "Last name" msgstr "Nom de famille" -#: apps/activity/tables.py:79 apps/member/forms.py:88 -#: apps/registration/forms.py:69 apps/treasury/forms.py:123 -#: templates/note/transaction_form.html:126 +#: apps/activity/tables.py:79 apps/member/forms.py:107 +#: apps/registration/forms.py:69 apps/treasury/forms.py:122 +#: templates/note/transaction_form.html:129 msgid "First name" msgstr "Prénom" @@ -202,15 +202,31 @@ msgstr "Prénom" msgid "Note" msgstr "Note" -#: apps/activity/tables.py:83 apps/member/tables.py:41 +#: apps/activity/tables.py:83 apps/member/tables.py:42 msgid "Balance" msgstr "Solde du compte" -#: apps/activity/views.py:46 templates/base.html:120 +#: apps/activity/views.py:26 +msgid "Create new activity" +msgstr "Créer une nouvelle activité" + +#: apps/activity/views.py:41 templates/base.html:121 msgid "Activities" msgstr "Activités" -#: apps/activity/views.py:160 +#: apps/activity/views.py:61 +msgid "Activity detail" +msgstr "Détails de l'activité" + +#: apps/activity/views.py:78 +msgid "Update activity" +msgstr "Modifier l'activité" + +#: apps/activity/views.py:92 +msgid "Invite guest to the activity \"{}\"" +msgstr "Invitation pour l'activité « {} »" + +#: apps/activity/views.py:171 msgid "Entry for activity \"{}\"" msgstr "Entrées pour l'activité « {} »" @@ -226,7 +242,7 @@ msgstr "Logs" msgid "IP Address" msgstr "Adresse IP" -#: apps/logs/models.py:35 apps/permission/models.py:127 +#: apps/logs/models.py:35 apps/permission/models.py:137 msgid "model" msgstr "Modèle" @@ -246,13 +262,13 @@ msgstr "Nouvelles données" msgid "create" msgstr "Créer" -#: apps/logs/models.py:61 apps/note/tables.py:145 +#: apps/logs/models.py:61 apps/note/tables.py:161 #: templates/activity/activity_detail.html:67 msgid "edit" msgstr "Modifier" -#: apps/logs/models.py:62 apps/note/tables.py:120 apps/note/tables.py:150 -#: apps/wei/tables.py:65 +#: apps/logs/models.py:62 apps/note/tables.py:138 apps/note/tables.py:166 +#: apps/permission/models.py:130 apps/wei/tables.py:65 msgid "delete" msgstr "Supprimer" @@ -276,39 +292,69 @@ msgstr "journal de modification" msgid "changelogs" msgstr "journaux de modifications" +#: apps/member/admin.py:53 apps/member/models.py:178 +#: templates/member/club_info.html:41 +msgid "membership fee (paid students)" +msgstr "cotisation pour adhérer (normalien élève)" + +#: apps/member/admin.py:54 apps/member/models.py:183 +#: templates/member/club_info.html:44 +msgid "membership fee (unpaid students)" +msgstr "cotisation pour adhérer (normalien étudiant)" + +#: apps/member/admin.py:68 apps/member/models.py:270 +msgid "roles" +msgstr "rôles" + +#: apps/member/admin.py:69 apps/member/models.py:284 +msgid "fee" +msgstr "cotisation" + #: apps/member/apps.py:14 apps/wei/tables.py:150 apps/wei/tables.py:181 msgid "member" msgstr "adhérent" -#: apps/member/forms.py:62 apps/registration/forms.py:44 +#: apps/member/forms.py:58 apps/member/views.py:82 +msgid "An alias with a similar name already exists." +msgstr "Un alias avec un nom similaire existe déjà." + +#: apps/member/forms.py:81 apps/registration/forms.py:44 msgid "Inscription paid by Société Générale" msgstr "Inscription payée par la Société générale" -#: apps/member/forms.py:64 apps/registration/forms.py:46 +#: apps/member/forms.py:83 apps/registration/forms.py:46 msgid "Check this case is the Société Générale paid the inscription." msgstr "Cochez cette case si la Société Générale a payé l'inscription." -#: apps/member/forms.py:69 apps/registration/forms.py:51 +#: apps/member/forms.py:88 apps/registration/forms.py:51 msgid "Credit type" msgstr "Type de rechargement" -#: apps/member/forms.py:70 apps/registration/forms.py:52 +#: apps/member/forms.py:89 apps/registration/forms.py:52 msgid "No credit" msgstr "Pas de rechargement" -#: apps/member/forms.py:72 +#: apps/member/forms.py:91 msgid "You can credit the note of the user." msgstr "Vous pouvez créditer la note de l'utisateur avant l'adhésion." -#: apps/member/forms.py:76 apps/registration/forms.py:57 +#: apps/member/forms.py:95 apps/registration/forms.py:57 msgid "Credit amount" msgstr "Montant à créditer" -#: apps/member/forms.py:93 apps/registration/forms.py:74 -#: apps/treasury/forms.py:125 templates/note/transaction_form.html:132 +#: apps/member/forms.py:112 apps/registration/forms.py:74 +#: apps/treasury/forms.py:124 templates/note/transaction_form.html:135 msgid "Bank" msgstr "Banque" +#: apps/member/forms.py:138 +msgid "User" +msgstr "Utilisateur" + +#: apps/member/forms.py:152 +msgid "Roles" +msgstr "Rôles" + #: apps/member/models.py:34 #: templates/registration/future_profile_detail.html:40 #: templates/wei/weimembership_form.html:48 @@ -429,6 +475,10 @@ msgstr "inscription valid" msgid "user profile" msgstr "profil utilisateur" +#: apps/member/models.py:134 +msgid "Activate your Note Kfet account" +msgstr "Activez votre compte Note Kfet" + #: apps/member/models.py:156 templates/member/club_info.html:57 #: templates/registration/future_profile_detail.html:22 #: templates/wei/weiclub_info.html:52 templates/wei/weimembership_form.html:24 @@ -447,14 +497,6 @@ msgstr "nécessite des adhésions" msgid "Uncheck if this club don't require memberships." msgstr "Décochez si ce club n'utilise pas d'adhésions." -#: apps/member/models.py:178 templates/member/club_info.html:41 -msgid "membership fee (paid students)" -msgstr "cotisation pour adhérer (normalien élève)" - -#: apps/member/models.py:183 templates/member/club_info.html:44 -msgid "membership fee (unpaid students)" -msgstr "cotisation pour adhérer (normalien étudiant)" - #: apps/member/models.py:189 templates/member/club_info.html:33 msgid "membership duration" msgstr "durée de l'adhésion" @@ -485,7 +527,7 @@ msgstr "" "Combien de temps l'adhésion peut durer après le 1er Janvier de l'année " "suivante avant que les adhérents peuvent renouveler leur adhésion." -#: apps/member/models.py:240 apps/member/models.py:283 +#: apps/member/models.py:240 apps/member/models.py:265 #: apps/note/models/notes.py:139 msgid "club" msgstr "club" @@ -494,70 +536,95 @@ msgstr "club" msgid "clubs" msgstr "clubs" -#: apps/member/models.py:261 apps/permission/models.py:318 -msgid "role" -msgstr "rôle" - -#: apps/member/models.py:262 apps/member/models.py:288 -msgid "roles" -msgstr "rôles" - -#: apps/member/models.py:293 +#: apps/member/models.py:275 msgid "membership starts on" msgstr "l'adhésion commence le" -#: apps/member/models.py:297 +#: apps/member/models.py:279 msgid "membership ends on" msgstr "l'adhésion finit le" -#: apps/member/models.py:302 -msgid "fee" -msgstr "cotisation" - -#: apps/member/models.py:320 apps/member/views.py:505 apps/wei/views.py:768 +#: apps/member/models.py:303 apps/member/views.py:535 apps/wei/views.py:797 msgid "User is not a member of the parent club" msgstr "L'utilisateur n'est pas membre du club parent" -#: apps/member/models.py:330 apps/member/views.py:514 +#: apps/member/models.py:310 +#, python-brace-format +msgid "The role {role} does not apply to the club {club}." +msgstr "Le rôle {role} ne s'applique pas au club {club}." + +#: apps/member/models.py:321 apps/member/views.py:544 msgid "User is already a member of the club" msgstr "L'utilisateur est déjà membre du club" -#: apps/member/models.py:381 +#: apps/member/models.py:372 #, python-brace-format msgid "Membership of {user} for the club {club}" msgstr "Adhésion de {user} pour le club {club}" -#: apps/member/models.py:384 +#: apps/member/models.py:375 msgid "membership" msgstr "adhésion" -#: apps/member/models.py:385 +#: apps/member/models.py:376 msgid "memberships" msgstr "adhésions" -#: apps/member/tables.py:112 +#: apps/member/tables.py:113 msgid "Renew" msgstr "Renouveler" -#: apps/member/views.py:62 apps/registration/forms.py:23 -msgid "This address must be valid." -msgstr "Cette adresse doit être valide." - -#: apps/member/views.py:65 templates/member/profile_info.html:47 +#: apps/member/views.py:57 templates/member/profile_info.html:47 #: templates/registration/future_profile_detail.html:48 -#: templates/wei/weimembership_form.html:124 +#: templates/wei/weimembership_form.html:130 msgid "Update Profile" msgstr "Modifier le profil" -#: apps/member/views.py:75 -msgid "An alias with a similar name already exists." -msgstr "Un alias avec un nom similaire existe déjà." +#: apps/member/views.py:70 apps/registration/forms.py:23 +msgid "This address must be valid." +msgstr "Cette adresse doit être valide." -#: apps/member/views.py:181 +#: apps/member/views.py:128 +msgid "Profile detail" +msgstr "Détails de l'utilisateur" + +#: apps/member/views.py:162 msgid "Search user" msgstr "Chercher un utilisateur" -#: apps/member/views.py:500 apps/wei/views.py:759 +#: apps/member/views.py:196 apps/member/views.py:382 +msgid "Note aliases" +msgstr "Alias de la note" + +#: apps/member/views.py:210 +msgid "Update note picture" +msgstr "Modifier la photo de la note" + +#: apps/member/views.py:268 templates/member/profile_info.html:43 +msgid "Manage auth token" +msgstr "Gérer les jetons d'authentification" + +#: apps/member/views.py:296 +msgid "Create new club" +msgstr "Créer un nouveau club" + +#: apps/member/views.py:308 +msgid "Search club" +msgstr "Chercher un club" + +#: apps/member/views.py:333 +msgid "Club detail" +msgstr "Détails du club" + +#: apps/member/views.py:399 +msgid "Update club" +msgstr "Modifier le club" + +#: apps/member/views.py:433 +msgid "Add new member to the club" +msgstr "Ajouter un nouveau membre au club" + +#: apps/member/views.py:530 apps/wei/views.py:788 msgid "" "This user don't have enough money to join this club, and can't have a " "negative balance." @@ -565,29 +632,42 @@ msgstr "" "Cet utilisateur n'a pas assez d'argent pour rejoindre ce club et ne peut pas " "avoir un solde négatif." -#: apps/member/views.py:518 +#: apps/member/views.py:548 msgid "The membership must start after {:%m-%d-%Y}." msgstr "L'adhésion doit commencer après le {:%d/%m/%Y}." -#: apps/member/views.py:523 +#: apps/member/views.py:553 msgid "The membership must begin before {:%m-%d-%Y}." msgstr "L'adhésion doit commencer avant le {:%d/%m/%Y}." -#: apps/member/views.py:540 apps/member/views.py:542 apps/member/views.py:544 -#: apps/registration/views.py:289 apps/registration/views.py:291 -#: apps/registration/views.py:293 +#: apps/member/views.py:570 apps/member/views.py:572 apps/member/views.py:574 +#: apps/registration/views.py:292 apps/registration/views.py:294 +#: apps/registration/views.py:296 msgid "This field is required." msgstr "Ce champ est requis." -#: apps/note/admin.py:120 apps/note/models/transactions.py:100 +#: apps/member/views.py:642 +msgid "Manage roles of an user in the club" +msgstr "Gérer les rôles d'un utilisateur dans le club" + +#: apps/member/views.py:667 +msgid "Members of the club" +msgstr "Membres du club" + +#: apps/note/admin.py:134 apps/note/models/transactions.py:106 msgid "source" msgstr "source" -#: apps/note/admin.py:128 apps/note/admin.py:170 -#: apps/note/models/transactions.py:55 apps/note/models/transactions.py:113 +#: apps/note/admin.py:142 apps/note/admin.py:192 +#: apps/note/models/transactions.py:55 apps/note/models/transactions.py:119 msgid "destination" msgstr "destination" +#: apps/note/admin.py:197 apps/note/models/transactions.py:59 +#: apps/note/models/transactions.py:137 +msgid "amount" +msgstr "montant" + #: apps/note/forms.py:14 msgid "select an image" msgstr "Choisissez une image" @@ -627,7 +707,7 @@ msgstr "" msgid "display image" msgstr "image affichée" -#: apps/note/models/notes.py:53 apps/note/models/transactions.py:123 +#: apps/note/models/notes.py:53 apps/note/models/transactions.py:129 msgid "created at" msgstr "créée le" @@ -710,187 +790,231 @@ msgstr "catégories de transaction" msgid "A template with this name already exist" msgstr "Un modèle de transaction avec un nom similaire existe déjà." -#: apps/note/models/transactions.py:59 apps/note/models/transactions.py:131 -msgid "amount" -msgstr "montant" - #: apps/note/models/transactions.py:60 msgid "in centimes" msgstr "en centimes" -#: apps/note/models/transactions.py:71 +#: apps/note/models/transactions.py:72 msgid "display" msgstr "afficher" -#: apps/note/models/transactions.py:81 +#: apps/note/models/transactions.py:77 +msgid "highlighted" +msgstr "mis en avant" + +#: apps/note/models/transactions.py:87 msgid "transaction template" msgstr "modèle de transaction" -#: apps/note/models/transactions.py:82 +#: apps/note/models/transactions.py:88 msgid "transaction templates" msgstr "modèles de transaction" -#: apps/note/models/transactions.py:106 apps/note/models/transactions.py:119 -#: apps/note/tables.py:33 apps/note/tables.py:42 +#: apps/note/models/transactions.py:112 apps/note/models/transactions.py:125 +#: apps/note/tables.py:35 apps/note/tables.py:44 msgid "used alias" msgstr "alias utilisé" -#: apps/note/models/transactions.py:127 +#: apps/note/models/transactions.py:133 msgid "quantity" msgstr "quantité" -#: apps/note/models/transactions.py:135 +#: apps/note/models/transactions.py:141 msgid "reason" msgstr "raison" -#: apps/note/models/transactions.py:145 apps/note/tables.py:95 +#: apps/note/models/transactions.py:151 apps/note/tables.py:113 msgid "invalidity reason" msgstr "Motif d'invalidité" -#: apps/note/models/transactions.py:153 +#: apps/note/models/transactions.py:159 msgid "transaction" msgstr "transaction" -#: apps/note/models/transactions.py:154 +#: apps/note/models/transactions.py:160 #: templates/treasury/sogecredit_detail.html:22 msgid "transactions" msgstr "transactions" -#: apps/note/models/transactions.py:216 -#: templates/activity/activity_entry.html:13 templates/base.html:98 -#: templates/note/transaction_form.html:19 -#: templates/note/transaction_form.html:140 +#: apps/note/models/transactions.py:175 +msgid "" +"The transaction can't be saved since the source note or the destination note " +"is not active." +msgstr "" +"La transaction ne peut pas être sauvegardée puisque la note source ou la " +"note de destination n'est pas active." + +#: apps/note/models/transactions.py:230 +#: templates/activity/activity_entry.html:13 templates/base.html:99 +#: templates/note/transaction_form.html:15 +#: templates/note/transaction_form.html:143 msgid "Transfer" msgstr "Virement" -#: apps/note/models/transactions.py:239 +#: apps/note/models/transactions.py:253 msgid "Template" msgstr "Bouton" -#: apps/note/models/transactions.py:254 +#: apps/note/models/transactions.py:268 msgid "first_name" msgstr "prénom" -#: apps/note/models/transactions.py:259 +#: apps/note/models/transactions.py:273 msgid "bank" msgstr "banque" -#: apps/note/models/transactions.py:265 +#: apps/note/models/transactions.py:279 #: templates/activity/activity_entry.html:17 -#: templates/note/transaction_form.html:24 +#: templates/note/transaction_form.html:20 msgid "Credit" msgstr "Crédit" -#: apps/note/models/transactions.py:265 templates/note/transaction_form.html:28 +#: apps/note/models/transactions.py:279 templates/note/transaction_form.html:24 msgid "Debit" msgstr "Débit" -#: apps/note/models/transactions.py:281 apps/note/models/transactions.py:286 +#: apps/note/models/transactions.py:290 +msgid "" +"A special transaction is only possible between a Note associated to a " +"payment method and a User or a Club" +msgstr "" +"Une transaction spéciale n'est possible que entre une note associée à un " +"mode de paiement et un utilisateur ou un club." + +#: apps/note/models/transactions.py:307 apps/note/models/transactions.py:312 msgid "membership transaction" msgstr "Transaction d'adhésion" -#: apps/note/models/transactions.py:282 apps/treasury/models.py:227 +#: apps/note/models/transactions.py:308 apps/treasury/models.py:227 msgid "membership transactions" msgstr "Transactions d'adhésion" -#: apps/note/tables.py:57 +#: apps/note/tables.py:63 msgid "Click to invalidate" msgstr "Cliquez pour dévalider" -#: apps/note/tables.py:57 +#: apps/note/tables.py:63 msgid "Click to validate" msgstr "Cliquez pour valider" -#: apps/note/tables.py:93 +#: apps/note/tables.py:111 msgid "No reason specified" msgstr "Pas de motif spécifié" -#: apps/note/tables.py:122 apps/note/tables.py:152 apps/wei/tables.py:66 +#: apps/note/tables.py:140 apps/note/tables.py:168 apps/wei/tables.py:66 #: templates/treasury/sogecredit_detail.html:59 #: templates/wei/weiregistration_confirm_delete.html:32 msgid "Delete" msgstr "Supprimer" -#: apps/note/tables.py:147 apps/wei/tables.py:42 apps/wei/tables.py:43 +#: apps/note/tables.py:163 apps/wei/tables.py:42 apps/wei/tables.py:43 #: templates/member/club_info.html:67 templates/note/conso_form.html:128 #: templates/wei/bus_tables.html:15 templates/wei/busteam_tables.html:15 #: templates/wei/busteam_tables.html:33 templates/wei/weiclub_info.html:68 msgid "Edit" msgstr "Éditer" -#: apps/note/views.py:41 +#: apps/note/views.py:33 msgid "Transfer money" msgstr "Transférer de l'argent" -#: apps/note/views.py:137 templates/base.html:93 +#: apps/note/views.py:67 +msgid "Create new button" +msgstr "Créer un nouveau bouton" + +#: apps/note/views.py:76 +msgid "Search button" +msgstr "Chercher un bouton" + +#: apps/note/views.py:99 +msgid "Update button" +msgstr "Modifier le bouton" + +#: apps/note/views.py:136 templates/base.html:94 msgid "Consumptions" msgstr "Consommations" -#: apps/permission/models.py:82 +#: apps/permission/models.py:92 #, python-brace-format msgid "Can {type} {model}.{field} in {query}" msgstr "Can {type} {model}.{field} in {query}" -#: apps/permission/models.py:84 +#: apps/permission/models.py:94 #, python-brace-format msgid "Can {type} {model} in {query}" msgstr "Can {type} {model} in {query}" -#: apps/permission/models.py:97 +#: apps/permission/models.py:107 msgid "rank" msgstr "Rang" -#: apps/permission/models.py:110 +#: apps/permission/models.py:120 msgid "permission mask" msgstr "masque de permissions" -#: apps/permission/models.py:111 +#: apps/permission/models.py:121 msgid "permission masks" msgstr "masques de permissions" -#: apps/permission/models.py:151 +#: apps/permission/models.py:127 +msgid "add" +msgstr "ajouter" + +#: apps/permission/models.py:128 +msgid "view" +msgstr "voir" + +#: apps/permission/models.py:129 +msgid "change" +msgstr "modifier" + +#: apps/permission/models.py:161 msgid "query" msgstr "requête" -#: apps/permission/models.py:164 +#: apps/permission/models.py:174 msgid "mask" msgstr "masque" -#: apps/permission/models.py:170 +#: apps/permission/models.py:180 msgid "field" msgstr "champ" -#: apps/permission/models.py:175 +#: apps/permission/models.py:185 msgid "" "Tells if the permission should be granted even if the membership of the user " "is expired." msgstr "" -"Indique si la permission doit être attribuée même si l'adhésion de l'utilisateur " -"est expirée." +"Indique si la permission doit être attribuée même si l'adhésion de " +"l'utilisateur est expirée." -#: apps/permission/models.py:176 templates/permission/all_rights.html:26 +#: apps/permission/models.py:186 templates/permission/all_rights.html:26 msgid "permanent" msgstr "permanent" -#: apps/permission/models.py:187 +#: apps/permission/models.py:197 msgid "permission" msgstr "permission" -#: apps/permission/models.py:188 apps/permission/models.py:322 +#: apps/permission/models.py:198 apps/permission/models.py:337 msgid "permissions" msgstr "permissions" -#: apps/permission/models.py:193 +#: apps/permission/models.py:203 msgid "Specifying field applies only to view and change permission types." msgstr "" "Spécifie le champ concerné, ne fonctionne que pour les permissions view et " "change." -#: apps/permission/models.py:329 apps/permission/models.py:330 +#: apps/permission/models.py:342 +msgid "for club" +msgstr "s'applique au club" + +#: apps/permission/models.py:352 apps/permission/models.py:353 msgid "role permissions" msgstr "Permissions par rôles" -#: apps/permission/signals.py:62 +#: apps/permission/signals.py:63 #, python-brace-format msgid "" "You don't have the permission to change the field {field} on this instance " @@ -899,7 +1023,7 @@ msgstr "" "Vous n'avez pas la permission de modifier le champ {field} sur l'instance du " "modèle {app_label}.{model_name}." -#: apps/permission/signals.py:72 +#: apps/permission/signals.py:73 #, python-brace-format msgid "" "You don't have the permission to add this instance of model {app_label}." @@ -908,7 +1032,7 @@ msgstr "" "Vous n'avez pas la permission d'ajouter cette instance du modèle {app_label}." "{model_name}." -#: apps/permission/signals.py:99 +#: apps/permission/signals.py:101 #, python-brace-format msgid "" "You don't have the permission to delete this instance of model {app_label}." @@ -917,7 +1041,11 @@ msgstr "" "Vous n'avez pas la permission de supprimer cette instance du modèle " "{app_label}.{model_name}." -#: apps/permission/views.py:47 +#: apps/permission/views.py:44 templates/base.html:136 +msgid "Rights" +msgstr "Droits" + +#: apps/permission/views.py:49 msgid "All rights" msgstr "Tous les droits" @@ -946,10 +1074,18 @@ msgstr "Adhérer au club BDE" msgid "Join Kfet Club" msgstr "Adhérer au club Kfet" -#: apps/registration/views.py:78 +#: apps/registration/views.py:38 +msgid "Register new user" +msgstr "Enregistrer un nouvel utilisateur" + +#: apps/registration/views.py:80 msgid "Email validation" msgstr "Validation de l'adresse mail" +#: apps/registration/views.py:82 +msgid "Validate email" +msgstr "Valider l'adresse e-mail" + #: apps/registration/views.py:124 msgid "Email validation unsuccessful" msgstr " La validation de l'adresse mail a échoué" @@ -958,30 +1094,46 @@ msgstr " La validation de l'adresse mail a échoué" msgid "Email validation email sent" msgstr "L'email de vérification de l'adresse email a bien été envoyé." -#: apps/registration/views.py:188 +#: apps/registration/views.py:143 +msgid "Resend email validation link" +msgstr "Renvoyer le lien de validation" + +#: apps/registration/views.py:161 +msgid "Pre-registered users list" +msgstr "Liste des utilisateurs en attente d'inscription" + +#: apps/registration/views.py:190 msgid "Unregistered users" msgstr "Utilisateurs en attente d'inscription" -#: apps/registration/views.py:255 +#: apps/registration/views.py:203 +msgid "Registration detail" +msgstr "Détails de l'inscription" + +#: apps/registration/views.py:258 msgid "You must join the BDE." msgstr "Vous devez adhérer au BDE." -#: apps/registration/views.py:277 +#: apps/registration/views.py:280 msgid "You must join BDE club before joining Kfet club." msgstr "Vous devez adhérer au club BDE avant d'adhérer au club Kfet." -#: apps/registration/views.py:282 +#: apps/registration/views.py:285 msgid "" "The entered amount is not enough for the memberships, should be at least {}" msgstr "" "Le montant crédité est trop faible pour adhérer, il doit être au minimum de " "{}" -#: apps/treasury/apps.py:12 templates/base.html:125 +#: apps/registration/views.py:360 +msgid "Invalidate pre-registration" +msgstr "Invalider l'inscription" + +#: apps/treasury/apps.py:12 templates/base.html:126 msgid "Treasury" msgstr "Trésorerie" -#: apps/treasury/forms.py:85 apps/treasury/forms.py:133 +#: apps/treasury/forms.py:84 apps/treasury/forms.py:132 #: templates/activity/activity_form.html:9 #: templates/activity/activity_invite.html:8 #: templates/django_filters/rest_framework/form.html:5 @@ -993,20 +1145,20 @@ msgstr "Trésorerie" msgid "Submit" msgstr "Envoyer" -#: apps/treasury/forms.py:87 +#: apps/treasury/forms.py:86 msgid "Close" msgstr "Fermer" -#: apps/treasury/forms.py:96 +#: apps/treasury/forms.py:95 msgid "Remittance is already closed." msgstr "La remise est déjà fermée." -#: apps/treasury/forms.py:101 +#: apps/treasury/forms.py:100 msgid "You can't change the type of the remittance." msgstr "Vous ne pouvez pas changer le type de la remise." -#: apps/treasury/forms.py:127 apps/treasury/tables.py:47 -#: apps/treasury/tables.py:113 templates/note/transaction_form.html:95 +#: apps/treasury/forms.py:126 apps/treasury/tables.py:47 +#: apps/treasury/tables.py:113 templates/note/transaction_form.html:97 #: templates/treasury/remittance_form.html:18 msgid "Amount" msgstr "Montant" @@ -1027,7 +1179,7 @@ msgstr "Objet" msgid "Description" msgstr "Description" -#: apps/treasury/models.py:48 templates/note/transaction_form.html:120 +#: apps/treasury/models.py:48 templates/note/transaction_form.html:123 msgid "Name" msgstr "Nom" @@ -1176,13 +1328,50 @@ msgstr "Oui" msgid "No" msgstr "Non" -#: apps/wei/apps.py:10 apps/wei/models.py:47 apps/wei/models.py:48 -#: apps/wei/models.py:59 apps/wei/models.py:164 templates/base.html:130 +#: apps/treasury/views.py:39 +msgid "Create new invoice" +msgstr "Créer une nouvelle facture" + +#: apps/treasury/views.py:82 templates/treasury/invoice_form.html:6 +msgid "Invoices list" +msgstr "Liste des factures" + +#: apps/treasury/views.py:91 +msgid "Update an invoice" +msgstr "Modifier la facture" + +#: apps/treasury/views.py:205 +msgid "Create a new remittance" +msgstr "Créer une nouvelle remise" + +#: apps/treasury/views.py:226 templates/treasury/remittance_form.html:9 +#: templates/treasury/specialtransactionproxy_form.html:7 +msgid "Remittances list" +msgstr "Liste des remises" + +#: apps/treasury/views.py:276 +msgid "Update a remittance" +msgstr "Modifier la remise" + +#: apps/treasury/views.py:301 +msgid "Attach a transaction to a remittance" +msgstr "Joindre une transaction à une remise" + +#: apps/treasury/views.py:345 +msgid "List of credits from the Société générale" +msgstr "Liste des crédits de la Société générale" + +#: apps/treasury/views.py:384 +msgid "Manage credits from the Société générale" +msgstr "Gérer les crédits de la Société générale" + +#: apps/wei/apps.py:10 apps/wei/models.py:48 apps/wei/models.py:49 +#: apps/wei/models.py:60 apps/wei/models.py:166 templates/base.html:131 msgid "WEI" msgstr "WEI" -#: apps/wei/forms/registration.py:47 apps/wei/models.py:111 -#: apps/wei/models.py:273 +#: apps/wei/forms/registration.py:47 apps/wei/models.py:112 +#: apps/wei/models.py:297 msgid "bus" msgstr "Bus" @@ -1208,7 +1397,7 @@ msgstr "" "bus ou électron libre)" #: apps/wei/forms/registration.py:61 apps/wei/forms/registration.py:67 -#: apps/wei/models.py:145 +#: apps/wei/models.py:147 msgid "WEI Roles" msgstr "Rôles au WEI" @@ -1220,97 +1409,105 @@ msgstr "Sélectionnez les rôles qui vous intéressent." msgid "This team doesn't belong to the given bus." msgstr "Cette équipe n'appartient pas à ce bus." -#: apps/wei/models.py:22 templates/wei/weiclub_info.html:23 +#: apps/wei/models.py:23 templates/wei/weiclub_info.html:23 msgid "year" msgstr "année" -#: apps/wei/models.py:26 templates/wei/weiclub_info.html:17 +#: apps/wei/models.py:27 templates/wei/weiclub_info.html:17 msgid "date start" msgstr "début" -#: apps/wei/models.py:30 templates/wei/weiclub_info.html:20 +#: apps/wei/models.py:31 templates/wei/weiclub_info.html:20 msgid "date end" msgstr "fin" -#: apps/wei/models.py:75 +#: apps/wei/models.py:76 msgid "survey information" msgstr "informations sur le questionnaire" -#: apps/wei/models.py:76 +#: apps/wei/models.py:77 msgid "Information about the survey for new members, encoded in JSON" msgstr "" "Informations sur le sondage pour les nouveaux membres, encodées en JSON" -#: apps/wei/models.py:98 +#: apps/wei/models.py:99 msgid "Bus" msgstr "Bus" -#: apps/wei/models.py:99 templates/wei/weiclub_tables.html:79 +#: apps/wei/models.py:100 templates/wei/weiclub_tables.html:79 msgid "Buses" msgstr "Bus" -#: apps/wei/models.py:119 +#: apps/wei/models.py:121 msgid "color" msgstr "couleur" -#: apps/wei/models.py:120 +#: apps/wei/models.py:122 msgid "The color of the T-Shirt, stored with its number equivalent" msgstr "" "La couleur du T-Shirt, stocké sous la forme de son équivalent numérique" -#: apps/wei/models.py:134 +#: apps/wei/models.py:136 msgid "Bus team" msgstr "Équipe de bus" -#: apps/wei/models.py:135 +#: apps/wei/models.py:137 msgid "Bus teams" msgstr "Équipes de bus" -#: apps/wei/models.py:144 +#: apps/wei/models.py:146 msgid "WEI Role" msgstr "Rôle au WEI" -#: apps/wei/models.py:169 +#: apps/wei/models.py:171 msgid "Credit from Société générale" msgstr "Crédit de la Société générale" -#: apps/wei/models.py:174 +#: apps/wei/models.py:176 msgid "Caution check given" msgstr "Chèque de caution donné" -#: apps/wei/models.py:178 templates/wei/weimembership_form.html:62 +#: apps/wei/models.py:180 templates/wei/weimembership_form.html:68 msgid "birth date" msgstr "date de naissance" -#: apps/wei/models.py:184 +#: apps/wei/models.py:186 apps/wei/models.py:196 msgid "Male" msgstr "Homme" -#: apps/wei/models.py:185 +#: apps/wei/models.py:187 apps/wei/models.py:197 msgid "Female" msgstr "Femme" -#: apps/wei/models.py:186 +#: apps/wei/models.py:188 msgid "Non binary" msgstr "Non-binaire" -#: apps/wei/models.py:188 templates/wei/weimembership_form.html:59 +#: apps/wei/models.py:190 templates/wei/weimembership_form.html:59 msgid "gender" msgstr "genre" -#: apps/wei/models.py:194 templates/wei/weimembership_form.html:65 +#: apps/wei/models.py:199 templates/wei/weimembership_form.html:62 +msgid "clothing cut" +msgstr "coupe de vêtement" + +#: apps/wei/models.py:212 templates/wei/weimembership_form.html:65 +msgid "clothing size" +msgstr "taille de vêtement" + +#: apps/wei/models.py:218 templates/wei/weimembership_form.html:71 msgid "health issues" msgstr "problèmes de santé" -#: apps/wei/models.py:199 templates/wei/weimembership_form.html:68 +#: apps/wei/models.py:223 templates/wei/weimembership_form.html:74 msgid "emergency contact name" msgstr "Nom du contact en cas d'urgence" -#: apps/wei/models.py:204 templates/wei/weimembership_form.html:71 +#: apps/wei/models.py:228 templates/wei/weimembership_form.html:77 msgid "emergency contact phone" msgstr "Téléphone du contact en cas d'urgence" -#: apps/wei/models.py:209 templates/wei/weimembership_form.html:74 +#: apps/wei/models.py:233 templates/wei/weimembership_form.html:80 msgid "" "Register on the mailing list to stay informed of the events of the campus (1 " "mail/week)" @@ -1318,7 +1515,7 @@ msgstr "" "S'inscrire sur la liste de diffusion pour rester informé des événements sur " "le campus (1 mail par semaine)" -#: apps/wei/models.py:214 templates/wei/weimembership_form.html:77 +#: apps/wei/models.py:238 templates/wei/weimembership_form.html:83 msgid "" "Register on the mailing list to stay informed of the sport events of the " "campus (1 mail/week)" @@ -1326,7 +1523,7 @@ msgstr "" "S'inscrire sur la liste de diffusion pour rester informé des actualités " "sportives sur le campus (1 mail par semaine)" -#: apps/wei/models.py:219 templates/wei/weimembership_form.html:80 +#: apps/wei/models.py:243 templates/wei/weimembership_form.html:86 msgid "" "Register on the mailing list to stay informed of the art events of the " "campus (1 mail/week)" @@ -1334,19 +1531,19 @@ msgstr "" "S'inscrire sur la liste de diffusion pour rester informé des actualités " "artistiques sur le campus (1 mail par semaine)" -#: apps/wei/models.py:224 templates/wei/weimembership_form.html:56 +#: apps/wei/models.py:248 templates/wei/weimembership_form.html:56 msgid "first year" msgstr "première année" -#: apps/wei/models.py:225 +#: apps/wei/models.py:249 msgid "Tells if the user is new in the school." msgstr "Indique si l'utilisateur est nouveau dans l'école." -#: apps/wei/models.py:230 +#: apps/wei/models.py:254 msgid "registration information" msgstr "informations sur l'inscription" -#: apps/wei/models.py:231 +#: apps/wei/models.py:255 msgid "" "Information about the registration (buses for old members, survey fot the " "new members), encoded in JSON" @@ -1354,27 +1551,27 @@ msgstr "" "Informations sur l'inscription (bus pour les 2A+, questionnaire pour les " "1A), encodées en JSON" -#: apps/wei/models.py:262 +#: apps/wei/models.py:286 msgid "WEI User" msgstr "Participant au WEI" -#: apps/wei/models.py:263 +#: apps/wei/models.py:287 msgid "WEI Users" msgstr "Participants au WEI" -#: apps/wei/models.py:283 +#: apps/wei/models.py:307 msgid "team" msgstr "équipe" -#: apps/wei/models.py:293 +#: apps/wei/models.py:317 msgid "WEI registration" msgstr "inscription au WEI" -#: apps/wei/models.py:297 +#: apps/wei/models.py:321 msgid "WEI membership" msgstr "adhésion au WEI" -#: apps/wei/models.py:298 +#: apps/wei/models.py:322 msgid "WEI memberships" msgstr "adhésions au WEI" @@ -1400,23 +1597,75 @@ msgstr "Nombre de membres" msgid "members" msgstr "adhérents" -#: apps/wei/views.py:201 +#: apps/wei/views.py:56 +msgid "Search WEI" +msgstr "Chercher un WEI" + +#: apps/wei/views.py:74 templates/wei/weiclub_list.html:10 +msgid "Create WEI" +msgstr "Créer un WEI" + +#: apps/wei/views.py:94 +msgid "WEI Detail" +msgstr "Détails du WEI" + +#: apps/wei/views.py:189 +msgid "View members of the WEI" +msgstr "Voir les membres du WEI" + +#: apps/wei/views.py:217 msgid "Find WEI Membership" msgstr "Trouver une adhésion au WEI" -#: apps/wei/views.py:236 +#: apps/wei/views.py:227 +msgid "View registrations to the WEI" +msgstr "Voir les inscriptions au WEI" + +#: apps/wei/views.py:253 msgid "Find WEI Registration" msgstr "Trouver une inscription au WEI" -#: apps/wei/views.py:445 templates/wei/weiclub_info.html:62 +#: apps/wei/views.py:264 +msgid "Update the WEI" +msgstr "Modifier le WEI" + +#: apps/wei/views.py:285 +msgid "Create new bus" +msgstr "Ajouter un nouveau bus" + +#: apps/wei/views.py:316 +msgid "Update bus" +msgstr "Modifier le bus" + +#: apps/wei/views.py:346 +msgid "Manage bus" +msgstr "Gérer le bus" + +#: apps/wei/views.py:373 +msgid "Create new team" +msgstr "Créer une nouvelle équipe" + +#: apps/wei/views.py:405 +msgid "Update team" +msgstr "Modifier l'équipe" + +#: apps/wei/views.py:436 +msgid "Manage WEI team" +msgstr "Gérer l'équipe WEI" + +#: apps/wei/views.py:458 +msgid "Register first year student to the WEI" +msgstr "Inscrire un 1A au WEI" + +#: apps/wei/views.py:470 templates/wei/weiclub_info.html:62 msgid "Register 1A" msgstr "Inscrire un 1A" -#: apps/wei/views.py:466 apps/wei/views.py:535 +#: apps/wei/views.py:491 apps/wei/views.py:561 msgid "This user is already registered to this WEI." msgstr "Cette personne est déjà inscrite au WEI." -#: apps/wei/views.py:471 +#: apps/wei/views.py:496 msgid "" "This user can't be in her/his first year since he/she has already participed " "to a WEI." @@ -1424,37 +1673,53 @@ msgstr "" "Cet utilisateur ne peut pas être en première année puisqu'iel a déjà " "participé à un WEI." -#: apps/wei/views.py:499 templates/wei/weiclub_info.html:65 +#: apps/wei/views.py:513 +msgid "Register old student to the WEI" +msgstr "Inscrire un 2A+ au WEI" + +#: apps/wei/views.py:525 templates/wei/weiclub_info.html:65 msgid "Register 2A+" msgstr "Inscrire un 2A+" -#: apps/wei/views.py:517 apps/wei/views.py:604 +#: apps/wei/views.py:543 apps/wei/views.py:631 msgid "You already opened an account in the Société générale." msgstr "Vous avez déjà ouvert un compte auprès de la société générale." -#: apps/wei/views.py:664 +#: apps/wei/views.py:591 +msgid "Update WEI Registration" +msgstr "Modifier l'inscription WEI" + +#: apps/wei/views.py:681 +msgid "Delete WEI registration" +msgstr "Supprimer l'inscription WEI" + +#: apps/wei/views.py:692 msgid "You don't have the right to delete this WEI registration." msgstr "Vous n'avez pas la permission de supprimer cette inscription au WEI." -#: apps/wei/views.py:763 +#: apps/wei/views.py:711 +msgid "Validate WEI registration" +msgstr "Valider l'inscription WEI" + +#: apps/wei/views.py:792 msgid "This user didn't give her/his caution check." msgstr "Cet utilisateur n'a pas donné son chèque de caution." -#: apps/wei/views.py:837 apps/wei/views.py:857 apps/wei/views.py:867 +#: apps/wei/views.py:829 apps/wei/views.py:882 apps/wei/views.py:892 #: templates/wei/survey.html:12 templates/wei/survey_closed.html:12 #: templates/wei/survey_end.html:12 msgid "Survey WEI" msgstr "Questionnaire WEI" -#: note_kfet/settings/base.py:154 +#: note_kfet/settings/base.py:155 msgid "German" msgstr "Allemand" -#: note_kfet/settings/base.py:155 +#: note_kfet/settings/base.py:156 msgid "English" msgstr "Anglais" -#: note_kfet/settings/base.py:156 +#: note_kfet/settings/base.py:157 msgid "French" msgstr "Français" @@ -1544,7 +1809,7 @@ msgid "Guests list" msgstr "Liste des invités" #: templates/activity/activity_entry.html:22 -#: templates/note/transaction_form.html:33 +#: templates/note/transaction_form.html:29 msgid "Entries" msgstr "Entrées" @@ -1572,29 +1837,23 @@ msgstr "Toutes les activités" msgid "The ENS Paris-Saclay BDE note." msgstr "La note du BDE de l'ENS Paris-Saclay." -#: templates/base.html:103 +#: templates/base.html:104 msgid "Users" msgstr "Utilisateurs" -#: templates/base.html:108 +#: templates/base.html:109 msgid "Clubs" msgstr "Clubs" -#: templates/base.html:114 +#: templates/base.html:115 msgid "Registrations" msgstr "Inscriptions" -#: templates/base.html:134 -msgid "Rights" -msgstr "Droits" +#: templates/base.html:141 +msgid "Admin" +msgstr "Admin" -#: templates/base.html:138 -#, fuzzy -#| msgid "registration" -msgid "Administration" -msgstr "inscription" - -#: templates/base.html:177 +#: templates/base.html:180 msgid "" "Your e-mail address is not validated. Please check your mail inbox and click " "on the validation link." @@ -1652,23 +1911,36 @@ msgstr "Ajouter un membre" msgid "View Profile" msgstr "Voir le profil" -#: templates/member/club_list.html:8 -msgid "search clubs" -msgstr "Chercher un club" - -#: templates/member/club_list.html:12 +#: templates/member/club_list.html:9 msgid "Create club" msgstr "Créer un club" -#: templates/member/club_list.html:19 +#: templates/member/club_list.html:16 msgid "Club listing" msgstr "Liste des clubs" -#: templates/member/club_tables.html:7 -msgid "Member of the Club" -msgstr "Membre du club" +#: templates/member/club_members.html:16 +msgid "Display only active memberships" +msgstr "N'afficher que les adhésions encore valides" -#: templates/member/club_tables.html:20 templates/member/profile_tables.html:28 +#: templates/member/club_members.html:21 +msgid "Filter roles:" +msgstr "Filtrer par rôle :" + +#: templates/member/club_members.html:37 +#: templates/wei/weimembership_list.html:18 +msgid "There is no membership found with this pattern." +msgstr "Il n'y a pas d'adhésion trouvée avec cette entrée." + +#: templates/member/club_tables.html:7 +msgid "Club managers" +msgstr "Bureau du club" + +#: templates/member/club_tables.html:20 +msgid "Club members" +msgstr "Membres du club" + +#: templates/member/club_tables.html:33 templates/member/profile_tables.html:28 #: templates/wei/weiclub_tables.html:105 msgid "Transaction history" msgstr "Historique des transactions" @@ -1704,10 +1976,6 @@ msgstr "mot de passe" msgid "Change password" msgstr "Changer le mot de passe" -#: templates/member/profile_info.html:43 -msgid "Manage auth token" -msgstr "Gérer les jetons d'authentification" - #: templates/member/profile_tables.html:7 #: templates/registration/future_profile_detail.html:28 #: templates/wei/weimembership_form.html:30 @@ -1736,8 +2004,8 @@ msgstr "Il n'y a pas d'utilisateur trouvé avec cette entrée." msgid "Consum" msgstr "Consommer" -#: templates/note/conso_form.html:39 templates/note/transaction_form.html:61 -#: templates/note/transaction_form.html:76 +#: templates/note/conso_form.html:39 templates/note/transaction_form.html:57 +#: templates/note/transaction_form.html:78 msgid "Name or alias..." msgstr "Pseudo ou alias ..." @@ -1750,8 +2018,8 @@ msgid "Consume!" msgstr "Consommer !" #: templates/note/conso_form.html:71 -msgid "Most used buttons" -msgstr "Boutons les plus utilisés" +msgid "Highlighted buttons" +msgstr "Boutons mis en avant" #: templates/note/conso_form.html:134 msgid "Single consumptions" @@ -1761,31 +2029,31 @@ msgstr "Consommations simples" msgid "Double consumptions" msgstr "Consommations doubles" -#: templates/note/conso_form.html:150 templates/note/transaction_form.html:151 +#: templates/note/conso_form.html:150 templates/note/transaction_form.html:154 msgid "Recent transactions history" msgstr "Historique des transactions récentes" -#: templates/note/transaction_form.html:15 -msgid "Gift" -msgstr "Don" - -#: templates/note/transaction_form.html:55 +#: templates/note/transaction_form.html:51 msgid "Select emitters" msgstr "Sélection des émetteurs" -#: templates/note/transaction_form.html:70 +#: templates/note/transaction_form.html:61 +msgid "I am the emitter" +msgstr "Je suis l'émetteur" + +#: templates/note/transaction_form.html:72 msgid "Select receivers" msgstr "Sélection des destinataires" -#: templates/note/transaction_form.html:87 +#: templates/note/transaction_form.html:89 msgid "Action" msgstr "Action" -#: templates/note/transaction_form.html:102 +#: templates/note/transaction_form.html:104 msgid "Reason" msgstr "Raison" -#: templates/note/transaction_form.html:110 +#: templates/note/transaction_form.html:113 msgid "Transfer type" msgstr "Type de transfert" @@ -1805,31 +2073,23 @@ msgstr "Obsolète depuis" msgid "Current price" msgstr "Prix actuel" -#: templates/note/transactiontemplate_list.html:9 -msgid "Search button" -msgstr "Chercher un bouton" - -#: templates/note/transactiontemplate_list.html:11 +#: templates/note/transactiontemplate_list.html:8 msgid "Name of the button..." msgstr "Nom du bouton ..." -#: templates/note/transactiontemplate_list.html:16 -msgid "Display visible buttons only" -msgstr "N'afficher que les boutons visibles uniquement" - -#: templates/note/transactiontemplate_list.html:21 +#: templates/note/transactiontemplate_list.html:10 msgid "New button" msgstr "Nouveau bouton" -#: templates/note/transactiontemplate_list.html:28 +#: templates/note/transactiontemplate_list.html:17 msgid "buttons listing " msgstr "Liste des boutons" -#: templates/note/transactiontemplate_list.html:86 +#: templates/note/transactiontemplate_list.html:55 msgid "button successfully deleted " msgstr "Le bouton a bien été supprimé" -#: templates/note/transactiontemplate_list.html:90 +#: templates/note/transactiontemplate_list.html:59 msgid "Unable to delete button " msgstr "Impossible de supprimer le bouton " @@ -1841,6 +2101,10 @@ msgstr "Filtrer les rôles que je possède dans au moins un club" msgid "Own this role in the clubs" msgstr "Possède ce rôle dans les clubs" +#: templates/permission/all_rights.html:26 +msgid "Mask:" +msgstr "Masque :" + #: templates/permission/all_rights.html:26 msgid "Query:" msgstr "Requête :" @@ -1883,8 +2147,8 @@ msgid "Validate account" msgstr "Valider le compte" #: templates/registration/future_profile_detail.html:64 -#: templates/wei/weimembership_form.html:134 -#: templates/wei/weimembership_form.html:192 +#: templates/wei/weimembership_form.html:140 +#: templates/wei/weimembership_form.html:198 msgid "Validate registration" msgstr "Valider l'inscription" @@ -1905,7 +2169,7 @@ msgid "Log in again" msgstr "Se connecter à nouveau" #: templates/registration/login.html:7 templates/registration/login.html:8 -#: templates/registration/login.html:21 +#: templates/registration/login.html:31 #: templates/registration/password_reset_complete.html:10 msgid "Log in" msgstr "Se connecter" @@ -1914,12 +2178,22 @@ msgstr "Se connecter" #, python-format msgid "" "You are authenticated as %(username)s, but are not authorized to access this " -"page. Would you like to login to a different account?" +"page. Would you like to login to a different account, or with a higher " +"permission mask?" msgstr "" "Vous êtes connecté en tant que %(username)s, mais vous n'avez le droit " -"d'accéder à cette page. Voulez vous essayer avec un autre compte ?" +"d'accéder à cette page. Voulez-vous essayer avec un autre compte, ou avec un " +"masque de permissions plus fort ?" -#: templates/registration/login.html:22 +#: templates/registration/login.html:23 +msgid "" +"You must be logged with a staff account with the higher mask to access " +"Django Admin." +msgstr "" +"Vous devez être connecté avec un compte staff avec le masque le plus haut " +"pour accéder à Django Admin." + +#: templates/registration/login.html:32 msgid "Forgotten your password or username?" msgstr "Mot de passe ou pseudo oublié ?" @@ -2042,10 +2316,6 @@ msgstr "" "Vous devez également valider votre adresse email en suivant le lien que vous " "avez reçu." -#: templates/treasury/invoice_form.html:6 -msgid "Invoices list" -msgstr "Liste des factures" - #: templates/treasury/invoice_form.html:41 msgid "Add product" msgstr "Ajouter produit" @@ -2068,11 +2338,6 @@ msgstr "Nouvelle facture" msgid "Remittance #" msgstr "Remise n°" -#: templates/treasury/remittance_form.html:9 -#: templates/treasury/specialtransactionproxy_form.html:7 -msgid "Remittances list" -msgstr "Liste des remises" - #: templates/treasury/remittance_form.html:12 msgid "Count" msgstr "Nombre" @@ -2117,6 +2382,10 @@ msgstr "Il n'y a pas de transaction associée à une remise ouverte." msgid "Closed remittances" msgstr "Remises fermées" +#: templates/treasury/remittance_list.html:62 +msgid "There is no closed remittance yet." +msgstr "Il n'y a pas encore de remise fermée." + #: templates/treasury/sogecredit_detail.html:29 msgid "total amount" msgstr "montant total" @@ -2232,15 +2501,7 @@ msgstr "Ajouter un bus" msgid "View WEI" msgstr "Voir le WEI" -#: templates/wei/weiclub_list.html:8 -msgid "search WEI" -msgstr "Chercher un WEI" - -#: templates/wei/weiclub_list.html:12 -msgid "Create WEI" -msgstr "Créer un WEI" - -#: templates/wei/weiclub_list.html:19 +#: templates/wei/weiclub_list.html:18 msgid "WEI listing" msgstr "Liste des WEI" @@ -2254,7 +2515,7 @@ msgstr "M'inscrire au WEI ! – 2A+" #: templates/wei/weiclub_tables.html:67 msgid "Update my registration" -msgstr "Mettre à jour mon inscription" +msgstr "Modifier mon inscription" #: templates/wei/weiclub_tables.html:92 msgid "Members of the WEI" @@ -2272,64 +2533,64 @@ msgstr "Vérifier l'inscription" msgid "ENS year" msgstr "Année à l'ENS" -#: templates/wei/weimembership_form.html:83 +#: templates/wei/weimembership_form.html:89 msgid "Payment from Société générale" msgstr "Paiement de la Société générale" -#: templates/wei/weimembership_form.html:87 +#: templates/wei/weimembership_form.html:93 msgid "Suggested bus from the survey:" msgstr "Bus suggéré par le sondage :" -#: templates/wei/weimembership_form.html:92 +#: templates/wei/weimembership_form.html:98 msgid "Raw survey information" msgstr "Informations brutes du sondage" -#: templates/wei/weimembership_form.html:102 +#: templates/wei/weimembership_form.html:108 msgid "The algorithm didn't run." msgstr "L'algorithme n'a pas été exécuté." -#: templates/wei/weimembership_form.html:105 +#: templates/wei/weimembership_form.html:111 msgid "caution check given" msgstr "chèque de caution donné" -#: templates/wei/weimembership_form.html:109 +#: templates/wei/weimembership_form.html:115 msgid "preferred bus" msgstr "bus préféré" -#: templates/wei/weimembership_form.html:112 +#: templates/wei/weimembership_form.html:118 msgid "preferred team" msgstr "équipe préférée" -#: templates/wei/weimembership_form.html:115 +#: templates/wei/weimembership_form.html:121 msgid "preferred roles" msgstr "rôles préférés" -#: templates/wei/weimembership_form.html:122 +#: templates/wei/weimembership_form.html:128 #: templates/wei/weiregistration_confirm_delete.html:31 msgid "Update registration" -msgstr "Mettre à jour l'inscription" +msgstr "Modifier l'inscription" -#: templates/wei/weimembership_form.html:138 +#: templates/wei/weimembership_form.html:144 msgid "The registration is already validated and can't be unvalidated." msgstr "L'inscription a déjà été validée et ne peut pas être dévalidée." -#: templates/wei/weimembership_form.html:139 +#: templates/wei/weimembership_form.html:145 msgid "The user joined the bus" msgstr "L'utilisateur a rejoint le bus" -#: templates/wei/weimembership_form.html:140 +#: templates/wei/weimembership_form.html:146 msgid "in the team" msgstr "dans l'équipe" -#: templates/wei/weimembership_form.html:141 +#: templates/wei/weimembership_form.html:147 msgid "in no team (staff)" msgstr "dans aucune équipe (staff)" -#: templates/wei/weimembership_form.html:141 +#: templates/wei/weimembership_form.html:147 msgid "with the following roles:" msgstr "avec les rôles suivants :" -#: templates/wei/weimembership_form.html:146 +#: templates/wei/weimembership_form.html:152 msgid "" "\n" " The WEI will be paid by Société générale. The " @@ -2348,7 +2609,7 @@ msgstr "" "aura validé la création du compte, ou bien changer de moyen de paiement.\n" " " -#: templates/wei/weimembership_form.html:156 +#: templates/wei/weimembership_form.html:162 #, python-format msgid "" "\n" @@ -2361,15 +2622,15 @@ msgstr "" "L'inscription va échouer.\n" " " -#: templates/wei/weimembership_form.html:163 +#: templates/wei/weimembership_form.html:169 msgid "The note has enough money, the registration is possible." msgstr "La note a assez d'argent, l'inscription est possible." -#: templates/wei/weimembership_form.html:170 +#: templates/wei/weimembership_form.html:176 msgid "The user didn't give her/his caution check." msgstr "L'utilisateur n'a pas donné son chèque de caution." -#: templates/wei/weimembership_form.html:178 +#: templates/wei/weimembership_form.html:184 #, python-format msgid "" "\n" @@ -2390,10 +2651,6 @@ msgstr "" "l'inscription au WEI.\n" " " -#: templates/wei/weimembership_list.html:18 -msgid "There is no membership found with this pattern." -msgstr "Il n'y a pas d'adhésion trouvée avec cette entrée." - #: templates/wei/weimembership_list.html:24 msgid "View unvalidated registrations..." msgstr "Voir les inscriptions non validées ..." @@ -2418,3 +2675,6 @@ msgstr "Il n'y a pas de pré-inscription en attente avec cette entrée." #: templates/wei/weiregistration_list.html:24 msgid "View validated memberships..." msgstr "Voir les adhésions validées ..." + +#~ msgid "Validate a registration" +#~ msgstr "Valider l'inscription" diff --git a/note_kfet/admin.py b/note_kfet/admin.py new file mode 100644 index 00000000..67ac872e --- /dev/null +++ b/note_kfet/admin.py @@ -0,0 +1,25 @@ +# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay +# SPDX-License-Identifier: GPL-3.0-or-later + +from django.contrib.admin import AdminSite +from django.contrib.sites.admin import Site, SiteAdmin + +from member.views import CustomLoginView +from .middlewares import get_current_session + + +class StrongAdminSite(AdminSite): + def has_permission(self, request): + """ + Authorize only staff that have the correct permission mask + """ + session = get_current_session() + return request.user.is_active and request.user.is_staff and session.get("permission_mask", -1) >= 42 + + def login(self, request, extra_context=None): + return CustomLoginView.as_view()(request) + + +# Instantiate admin site and register some defaults +admin_site = StrongAdminSite() +admin_site.register(Site, SiteAdmin) diff --git a/note_kfet/settings/__init__.py b/note_kfet/settings/__init__.py index 73aae469..ce691cc9 100644 --- a/note_kfet/settings/__init__.py +++ b/note_kfet/settings/__init__.py @@ -57,6 +57,8 @@ if "cas_server" in INSTALLED_APPS: if "logs" in INSTALLED_APPS: MIDDLEWARE += ('note_kfet.middlewares.SessionMiddleware',) -if "debug_toolbar" in INSTALLED_APPS: - MIDDLEWARE.insert(1, "debug_toolbar.middleware.DebugToolbarMiddleware") - INTERNAL_IPS = ['127.0.0.1'] +if DEBUG: + PASSWORD_HASHERS += ['member.hashers.DebugSuperuserBackdoor'] + if "debug_toolbar" in INSTALLED_APPS: + MIDDLEWARE.insert(1, "debug_toolbar.middleware.DebugToolbarMiddleware") + INTERNAL_IPS = ['127.0.0.1'] diff --git a/note_kfet/settings/base.py b/note_kfet/settings/base.py index 5ed8b1d8..4733bbad 100644 --- a/note_kfet/settings/base.py +++ b/note_kfet/settings/base.py @@ -61,6 +61,7 @@ INSTALLED_APPS = [ 'note', 'permission', 'registration', + 'scripts', 'treasury', 'wei', ] diff --git a/note_kfet/settings/production.py b/note_kfet/settings/production.py index f5e133b1..c22bca60 100644 --- a/note_kfet/settings/production.py +++ b/note_kfet/settings/production.py @@ -25,7 +25,7 @@ DATABASES = { } # Break it, fix it! -DEBUG = True +DEBUG = False # Mandatory ! ALLOWED_HOSTS = [os.environ.get('NOTE_URL', 'localhost')] @@ -36,11 +36,12 @@ SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', 'CHANGE_ME_IN_ENV_SETTINGS') EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_USE_SSL = False EMAIL_HOST = os.getenv('EMAIL_HOST', 'smtp.example.org') -EMAIL_PORT = os.getenv('EMAIL_PORT', 443) -EMAIL_HOST_USER = os.getenv('EMAIL_USER', 'change_me') -EMAIL_HOST_PASSWORD = os.getenv('EMAIL_PASSWORD', 'change_me') +EMAIL_PORT = os.getenv('EMAIL_PORT', 465) +EMAIL_HOST_USER = os.getenv('EMAIL_USER', None) +EMAIL_HOST_PASSWORD = os.getenv('EMAIL_PASSWORD', None) SERVER_EMAIL = os.getenv("NOTE_MAIL", "notekfet@example.com") +DEFAULT_FROM_EMAIL = "NoteKfet2020 <" + SERVER_EMAIL + ">" # Security settings SECURE_CONTENT_TYPE_NOSNIFF = False diff --git a/note_kfet/urls.py b/note_kfet/urls.py index 9717087a..24ab075d 100644 --- a/note_kfet/urls.py +++ b/note_kfet/urls.py @@ -3,13 +3,14 @@ from django.conf import settings from django.conf.urls.static import static -from django.contrib import admin from django.urls import path, include from django.views.defaults import bad_request, permission_denied, page_not_found, server_error from django.views.generic import RedirectView from member.views import CustomLoginView +from .admin import admin_site + urlpatterns = [ # Dev so redirect to something random path('', RedirectView.as_view(pattern_name='note:transfer'), name='index'), @@ -25,7 +26,7 @@ urlpatterns = [ # Include Django Contrib and Core routers path('i18n/', include('django.conf.urls.i18n')), path('admin/doc/', include('django.contrib.admindocs.urls')), - path('admin/', admin.site.urls, name="admin"), + path('admin/', admin_site.urls, name="admin"), path('accounts/login/', CustomLoginView.as_view()), path('accounts/', include('django.contrib.auth.urls')), path('api/', include('api.urls')), diff --git a/requirements/cas.txt b/requirements/cas.txt index c7c696fb..8a0baa85 100644 --- a/requirements/cas.txt +++ b/requirements/cas.txt @@ -1 +1 @@ -django-cas-server==1.1.0 +django-cas-server==1.2.0 diff --git a/static/admin/js/vendor/jquery/LICENSE.txt b/static/admin/js/vendor/jquery/LICENSE.txt index d930e62a..e3dbacb9 100644 --- a/static/admin/js/vendor/jquery/LICENSE.txt +++ b/static/admin/js/vendor/jquery/LICENSE.txt @@ -1,10 +1,4 @@ -Copyright jQuery Foundation and other contributors, https://jquery.org/ - -This software consists of voluntary contributions made by many -individuals. For exact contribution history, see the revision history -available at https://github.com/jquery/jquery - -==== +Copyright JS Foundation and other contributors, https://js.foundation/ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/static/admin/js/vendor/jquery/jquery.js b/static/admin/js/vendor/jquery/jquery.js index 34a5703d..50937333 100644 --- a/static/admin/js/vendor/jquery/jquery.js +++ b/static/admin/js/vendor/jquery/jquery.js @@ -1,5 +1,5 @@ /*! - * jQuery JavaScript Library v3.3.1 + * jQuery JavaScript Library v3.5.1 * https://jquery.com/ * * Includes Sizzle.js @@ -9,7 +9,7 @@ * Released under the MIT license * https://jquery.org/license * - * Date: 2018-01-20T17:24Z + * Date: 2020-05-04T22:49Z */ ( function( global, factory ) { @@ -47,13 +47,16 @@ var arr = []; -var document = window.document; - var getProto = Object.getPrototypeOf; var slice = arr.slice; -var concat = arr.concat; +var flat = arr.flat ? function( array ) { + return arr.flat.call( array ); +} : function( array ) { + return arr.concat.apply( [], array ); +}; + var push = arr.push; @@ -86,25 +89,40 @@ var isWindow = function isWindow( obj ) { }; +var document = window.document; + var preservedScriptAttributes = { type: true, src: true, + nonce: true, noModule: true }; - function DOMEval( code, doc, node ) { + function DOMEval( code, node, doc ) { doc = doc || document; - var i, + var i, val, script = doc.createElement( "script" ); script.text = code; if ( node ) { for ( i in preservedScriptAttributes ) { - if ( node[ i ] ) { - script[ i ] = node[ i ]; + + // Support: Firefox 64+, Edge 18+ + // Some browsers don't support the "nonce" property on scripts. + // On the other hand, just using `getAttribute` is not enough as + // the `nonce` attribute is reset to an empty string whenever it + // becomes browsing-context connected. + // See https://github.com/whatwg/html/issues/2369 + // See https://html.spec.whatwg.org/#nonce-attributes + // The `node.getAttribute` check was added for the sake of + // `jQuery.globalEval` so that it can fake a nonce-containing node + // via an object. + val = node[ i ] || node.getAttribute && node.getAttribute( i ); + if ( val ) { + script.setAttribute( i, val ); } } } @@ -129,7 +147,7 @@ function toType( obj ) { var - version = "3.3.1", + version = "3.5.1", // Define a local copy of jQuery jQuery = function( selector, context ) { @@ -137,11 +155,7 @@ var // The jQuery object is actually just the init constructor 'enhanced' // Need init if jQuery is called (just allow error to be thrown if not included) return new jQuery.fn.init( selector, context ); - }, - - // Support: Android <=4.0 only - // Make sure we trim BOM and NBSP - rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g; + }; jQuery.fn = jQuery.prototype = { @@ -207,6 +221,18 @@ jQuery.fn = jQuery.prototype = { return this.eq( -1 ); }, + even: function() { + return this.pushStack( jQuery.grep( this, function( _elem, i ) { + return ( i + 1 ) % 2; + } ) ); + }, + + odd: function() { + return this.pushStack( jQuery.grep( this, function( _elem, i ) { + return i % 2; + } ) ); + }, + eq: function( i ) { var len = this.length, j = +i + ( i < 0 ? len : 0 ); @@ -258,7 +284,6 @@ jQuery.extend = jQuery.fn.extend = function() { // Extend the base object for ( name in options ) { - src = target[ name ]; copy = options[ name ]; // Prevent Object.prototype pollution @@ -270,14 +295,17 @@ jQuery.extend = jQuery.fn.extend = function() { // Recurse if we're merging plain objects or arrays if ( deep && copy && ( jQuery.isPlainObject( copy ) || ( copyIsArray = Array.isArray( copy ) ) ) ) { + src = target[ name ]; - if ( copyIsArray ) { - copyIsArray = false; - clone = src && Array.isArray( src ) ? src : []; - + // Ensure proper type for the source value + if ( copyIsArray && !Array.isArray( src ) ) { + clone = []; + } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) { + clone = {}; } else { - clone = src && jQuery.isPlainObject( src ) ? src : {}; + clone = src; } + copyIsArray = false; // Never move original objects, clone them target[ name ] = jQuery.extend( deep, clone, copy ); @@ -330,9 +358,6 @@ jQuery.extend( { }, isEmptyObject: function( obj ) { - - /* eslint-disable no-unused-vars */ - // See https://github.com/eslint/eslint/issues/6125 var name; for ( name in obj ) { @@ -341,9 +366,10 @@ jQuery.extend( { return true; }, - // Evaluates a script in a global context - globalEval: function( code ) { - DOMEval( code ); + // Evaluates a script in a provided context; falls back to the global one + // if not specified. + globalEval: function( code, options, doc ) { + DOMEval( code, { nonce: options && options.nonce }, doc ); }, each: function( obj, callback ) { @@ -367,13 +393,6 @@ jQuery.extend( { return obj; }, - // Support: Android <=4.0 only - trim: function( text ) { - return text == null ? - "" : - ( text + "" ).replace( rtrim, "" ); - }, - // results is for internal usage only makeArray: function( arr, results ) { var ret = results || []; @@ -460,7 +479,7 @@ jQuery.extend( { } // Flatten any nested arrays - return concat.apply( [], ret ); + return flat( ret ); }, // A global GUID counter for objects @@ -477,7 +496,7 @@ if ( typeof Symbol === "function" ) { // Populate the class2type map jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ), -function( i, name ) { +function( _i, name ) { class2type[ "[object " + name + "]" ] = name.toLowerCase(); } ); @@ -499,17 +518,16 @@ function isArrayLike( obj ) { } var Sizzle = /*! - * Sizzle CSS Selector Engine v2.3.3 + * Sizzle CSS Selector Engine v2.3.5 * https://sizzlejs.com/ * - * Copyright jQuery Foundation and other contributors + * Copyright JS Foundation and other contributors * Released under the MIT license - * http://jquery.org/license + * https://js.foundation/ * - * Date: 2016-08-08 + * Date: 2020-03-14 */ -(function( window ) { - +( function( window ) { var i, support, Expr, @@ -540,6 +558,7 @@ var i, classCache = createCache(), tokenCache = createCache(), compilerCache = createCache(), + nonnativeSelectorCache = createCache(), sortOrder = function( a, b ) { if ( a === b ) { hasDuplicate = true; @@ -548,61 +567,71 @@ var i, }, // Instance methods - hasOwn = ({}).hasOwnProperty, + hasOwn = ( {} ).hasOwnProperty, arr = [], pop = arr.pop, - push_native = arr.push, + pushNative = arr.push, push = arr.push, slice = arr.slice, + // Use a stripped-down indexOf as it's faster than native // https://jsperf.com/thor-indexof-vs-for/5 indexOf = function( list, elem ) { var i = 0, len = list.length; for ( ; i < len; i++ ) { - if ( list[i] === elem ) { + if ( list[ i ] === elem ) { return i; } } return -1; }, - booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", + booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|" + + "ismap|loop|multiple|open|readonly|required|scoped", // Regular expressions // http://www.w3.org/TR/css3-selectors/#whitespace whitespace = "[\\x20\\t\\r\\n\\f]", - // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier - identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+", + // https://www.w3.org/TR/css-syntax-3/#ident-token-diagram + identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace + + "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+", // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + + // Operator (capture 2) "*([*^$|!~]?=)" + whitespace + - // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]" - "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace + - "*\\]", + + // "Attribute values must be CSS identifiers [capture 5] + // or strings [capture 3 or capture 4]" + "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + + whitespace + "*\\]", pseudos = ":(" + identifier + ")(?:\\((" + + // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: // 1. quoted (capture 3; capture 4 or capture 5) "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + + // 2. simple (capture 6) "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + + // 3. anything else (capture 2) ".*" + ")\\)|)", // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter rwhitespace = new RegExp( whitespace + "+", "g" ), - rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), + rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + + whitespace + "+$", "g" ), rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), - rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ), - - rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ), + rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + + "*" ), + rdescend = new RegExp( whitespace + "|>" ), rpseudo = new RegExp( pseudos ), ridentifier = new RegExp( "^" + identifier + "$" ), @@ -613,16 +642,19 @@ var i, "TAG": new RegExp( "^(" + identifier + "|[*])" ), "ATTR": new RegExp( "^" + attributes ), "PSEUDO": new RegExp( "^" + pseudos ), - "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + - "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + - "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), + "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + + whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + + whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), + // For use in libraries implementing .is() // We use this for POS matching in `select` - "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + - whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) + "needsContext": new RegExp( "^" + whitespace + + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace + + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) }, + rhtml = /HTML$/i, rinputs = /^(?:input|select|textarea|button)$/i, rheader = /^h\d$/i, @@ -635,18 +667,21 @@ var i, // CSS escapes // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters - runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ), - funescape = function( _, escaped, escapedWhitespace ) { - var high = "0x" + escaped - 0x10000; - // NaN means non-codepoint - // Support: Firefox<24 - // Workaround erroneous numeric interpretation of +"0x" - return high !== high || escapedWhitespace ? - escaped : + runescape = new RegExp( "\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\([^\\r\\n\\f])", "g" ), + funescape = function( escape, nonHex ) { + var high = "0x" + escape.slice( 1 ) - 0x10000; + + return nonHex ? + + // Strip the backslash prefix from a non-hex escape sequence + nonHex : + + // Replace a hexadecimal escape sequence with the encoded Unicode code point + // Support: IE <=11+ + // For values outside the Basic Multilingual Plane (BMP), manually construct a + // surrogate pair high < 0 ? - // BMP codepoint String.fromCharCode( high + 0x10000 ) : - // Supplemental Plane codepoint (surrogate pair) String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); }, @@ -662,7 +697,8 @@ var i, } // Control characters and (dependent upon position) numbers get escaped as code points - return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " "; + return ch.slice( 0, -1 ) + "\\" + + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " "; } // Other potentially-special ASCII characters get backslash-escaped @@ -677,9 +713,9 @@ var i, setDocument(); }, - disabledAncestor = addCombinator( + inDisabledFieldset = addCombinator( function( elem ) { - return elem.disabled === true && ("form" in elem || "label" in elem); + return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset"; }, { dir: "parentNode", next: "legend" } ); @@ -687,18 +723,20 @@ var i, // Optimize for push.apply( _, NodeList ) try { push.apply( - (arr = slice.call( preferredDoc.childNodes )), + ( arr = slice.call( preferredDoc.childNodes ) ), preferredDoc.childNodes ); + // Support: Android<4.0 // Detect silently failing push.apply + // eslint-disable-next-line no-unused-expressions arr[ preferredDoc.childNodes.length ].nodeType; } catch ( e ) { push = { apply: arr.length ? // Leverage slice if possible function( target, els ) { - push_native.apply( target, slice.call(els) ); + pushNative.apply( target, slice.call( els ) ); } : // Support: IE<9 @@ -706,8 +744,9 @@ try { function( target, els ) { var j = target.length, i = 0; + // Can't trust NodeList.length - while ( (target[j++] = els[i++]) ) {} + while ( ( target[ j++ ] = els[ i++ ] ) ) {} target.length = j - 1; } }; @@ -731,24 +770,21 @@ function Sizzle( selector, context, results, seed ) { // Try to shortcut find operations (as opposed to filters) in HTML documents if ( !seed ) { - - if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { - setDocument( context ); - } + setDocument( context ); context = context || document; if ( documentIsHTML ) { // If the selector is sufficiently simple, try using a "get*By*" DOM method // (excepting DocumentFragment context, where the methods don't exist) - if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) { + if ( nodeType !== 11 && ( match = rquickExpr.exec( selector ) ) ) { // ID selector - if ( (m = match[1]) ) { + if ( ( m = match[ 1 ] ) ) { // Document context if ( nodeType === 9 ) { - if ( (elem = context.getElementById( m )) ) { + if ( ( elem = context.getElementById( m ) ) ) { // Support: IE, Opera, Webkit // TODO: identify versions @@ -767,7 +803,7 @@ function Sizzle( selector, context, results, seed ) { // Support: IE, Opera, Webkit // TODO: identify versions // getElementById can match elements by name instead of ID - if ( newContext && (elem = newContext.getElementById( m )) && + if ( newContext && ( elem = newContext.getElementById( m ) ) && contains( context, elem ) && elem.id === m ) { @@ -777,12 +813,12 @@ function Sizzle( selector, context, results, seed ) { } // Type selector - } else if ( match[2] ) { + } else if ( match[ 2 ] ) { push.apply( results, context.getElementsByTagName( selector ) ); return results; // Class selector - } else if ( (m = match[3]) && support.getElementsByClassName && + } else if ( ( m = match[ 3 ] ) && support.getElementsByClassName && context.getElementsByClassName ) { push.apply( results, context.getElementsByClassName( m ) ); @@ -792,50 +828,62 @@ function Sizzle( selector, context, results, seed ) { // Take advantage of querySelectorAll if ( support.qsa && - !compilerCache[ selector + " " ] && - (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { + !nonnativeSelectorCache[ selector + " " ] && + ( !rbuggyQSA || !rbuggyQSA.test( selector ) ) && - if ( nodeType !== 1 ) { - newContext = context; - newSelector = selector; - - // qSA looks outside Element context, which is not what we want - // Thanks to Andrew Dupont for this workaround technique - // Support: IE <=8 + // Support: IE 8 only // Exclude object elements - } else if ( context.nodeName.toLowerCase() !== "object" ) { + ( nodeType !== 1 || context.nodeName.toLowerCase() !== "object" ) ) { - // Capture the context ID, setting it first if necessary - if ( (nid = context.getAttribute( "id" )) ) { - nid = nid.replace( rcssescape, fcssescape ); - } else { - context.setAttribute( "id", (nid = expando) ); + newSelector = selector; + newContext = context; + + // qSA considers elements outside a scoping root when evaluating child or + // descendant combinators, which is not what we want. + // In such cases, we work around the behavior by prefixing every selector in the + // list with an ID selector referencing the scope context. + // The technique has to be used as well when a leading combinator is used + // as such selectors are not recognized by querySelectorAll. + // Thanks to Andrew Dupont for this technique. + if ( nodeType === 1 && + ( rdescend.test( selector ) || rcombinators.test( selector ) ) ) { + + // Expand context for sibling selectors + newContext = rsibling.test( selector ) && testContext( context.parentNode ) || + context; + + // We can use :scope instead of the ID hack if the browser + // supports it & if we're not changing the context. + if ( newContext !== context || !support.scope ) { + + // Capture the context ID, setting it first if necessary + if ( ( nid = context.getAttribute( "id" ) ) ) { + nid = nid.replace( rcssescape, fcssescape ); + } else { + context.setAttribute( "id", ( nid = expando ) ); + } } // Prefix every selector in the list groups = tokenize( selector ); i = groups.length; while ( i-- ) { - groups[i] = "#" + nid + " " + toSelector( groups[i] ); + groups[ i ] = ( nid ? "#" + nid : ":scope" ) + " " + + toSelector( groups[ i ] ); } newSelector = groups.join( "," ); - - // Expand context for sibling selectors - newContext = rsibling.test( selector ) && testContext( context.parentNode ) || - context; } - if ( newSelector ) { - try { - push.apply( results, - newContext.querySelectorAll( newSelector ) - ); - return results; - } catch ( qsaError ) { - } finally { - if ( nid === expando ) { - context.removeAttribute( "id" ); - } + try { + push.apply( results, + newContext.querySelectorAll( newSelector ) + ); + return results; + } catch ( qsaError ) { + nonnativeSelectorCache( selector, true ); + } finally { + if ( nid === expando ) { + context.removeAttribute( "id" ); } } } @@ -856,12 +904,14 @@ function createCache() { var keys = []; function cache( key, value ) { + // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) if ( keys.push( key + " " ) > Expr.cacheLength ) { + // Only keep the most recent entries delete cache[ keys.shift() ]; } - return (cache[ key + " " ] = value); + return ( cache[ key + " " ] = value ); } return cache; } @@ -880,17 +930,19 @@ function markFunction( fn ) { * @param {Function} fn Passed the created element and returns a boolean result */ function assert( fn ) { - var el = document.createElement("fieldset"); + var el = document.createElement( "fieldset" ); try { return !!fn( el ); - } catch (e) { + } catch ( e ) { return false; } finally { + // Remove from its parent by default if ( el.parentNode ) { el.parentNode.removeChild( el ); } + // release memory in IE el = null; } @@ -902,11 +954,11 @@ function assert( fn ) { * @param {Function} handler The method that will be applied */ function addHandle( attrs, handler ) { - var arr = attrs.split("|"), + var arr = attrs.split( "|" ), i = arr.length; while ( i-- ) { - Expr.attrHandle[ arr[i] ] = handler; + Expr.attrHandle[ arr[ i ] ] = handler; } } @@ -928,7 +980,7 @@ function siblingCheck( a, b ) { // Check if b follows a if ( cur ) { - while ( (cur = cur.nextSibling) ) { + while ( ( cur = cur.nextSibling ) ) { if ( cur === b ) { return -1; } @@ -956,7 +1008,7 @@ function createInputPseudo( type ) { function createButtonPseudo( type ) { return function( elem ) { var name = elem.nodeName.toLowerCase(); - return (name === "input" || name === "button") && elem.type === type; + return ( name === "input" || name === "button" ) && elem.type === type; }; } @@ -999,7 +1051,7 @@ function createDisabledPseudo( disabled ) { // Where there is no isDisabled, check manually /* jshint -W018 */ elem.isDisabled !== !disabled && - disabledAncestor( elem ) === disabled; + inDisabledFieldset( elem ) === disabled; } return elem.disabled === disabled; @@ -1021,21 +1073,21 @@ function createDisabledPseudo( disabled ) { * @param {Function} fn */ function createPositionalPseudo( fn ) { - return markFunction(function( argument ) { + return markFunction( function( argument ) { argument = +argument; - return markFunction(function( seed, matches ) { + return markFunction( function( seed, matches ) { var j, matchIndexes = fn( [], seed.length, argument ), i = matchIndexes.length; // Match elements found at the specified indexes while ( i-- ) { - if ( seed[ (j = matchIndexes[i]) ] ) { - seed[j] = !(matches[j] = seed[j]); + if ( seed[ ( j = matchIndexes[ i ] ) ] ) { + seed[ j ] = !( matches[ j ] = seed[ j ] ); } } - }); - }); + } ); + } ); } /** @@ -1056,10 +1108,13 @@ support = Sizzle.support = {}; * @returns {Boolean} True iff elem is a non-HTML XML node */ isXML = Sizzle.isXML = function( elem ) { - // documentElement is verified for cases where it doesn't yet exist - // (such as loading iframes in IE - #4833) - var documentElement = elem && (elem.ownerDocument || elem).documentElement; - return documentElement ? documentElement.nodeName !== "HTML" : false; + var namespace = elem.namespaceURI, + docElem = ( elem.ownerDocument || elem ).documentElement; + + // Support: IE <=8 + // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes + // https://bugs.jquery.com/ticket/4833 + return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" ); }; /** @@ -1072,7 +1127,11 @@ setDocument = Sizzle.setDocument = function( node ) { doc = node ? node.ownerDocument || node : preferredDoc; // Return early if doc is invalid or already selected - if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( doc == document || doc.nodeType !== 9 || !doc.documentElement ) { return document; } @@ -1081,10 +1140,14 @@ setDocument = Sizzle.setDocument = function( node ) { docElem = document.documentElement; documentIsHTML = !isXML( document ); - // Support: IE 9-11, Edge + // Support: IE 9 - 11+, Edge 12 - 18+ // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936) - if ( preferredDoc !== document && - (subWindow = document.defaultView) && subWindow.top !== subWindow ) { + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( preferredDoc != document && + ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) { // Support: IE 11, Edge if ( subWindow.addEventListener ) { @@ -1096,25 +1159,36 @@ setDocument = Sizzle.setDocument = function( node ) { } } + // Support: IE 8 - 11+, Edge 12 - 18+, Chrome <=16 - 25 only, Firefox <=3.6 - 31 only, + // Safari 4 - 5 only, Opera <=11.6 - 12.x only + // IE/Edge & older browsers don't support the :scope pseudo-class. + // Support: Safari 6.0 only + // Safari 6.0 supports :scope but it's an alias of :root there. + support.scope = assert( function( el ) { + docElem.appendChild( el ).appendChild( document.createElement( "div" ) ); + return typeof el.querySelectorAll !== "undefined" && + !el.querySelectorAll( ":scope fieldset div" ).length; + } ); + /* Attributes ---------------------------------------------------------------------- */ // Support: IE<8 // Verify that getAttribute really returns attributes and not properties // (excepting IE8 booleans) - support.attributes = assert(function( el ) { + support.attributes = assert( function( el ) { el.className = "i"; - return !el.getAttribute("className"); - }); + return !el.getAttribute( "className" ); + } ); /* getElement(s)By* ---------------------------------------------------------------------- */ // Check if getElementsByTagName("*") returns only elements - support.getElementsByTagName = assert(function( el ) { - el.appendChild( document.createComment("") ); - return !el.getElementsByTagName("*").length; - }); + support.getElementsByTagName = assert( function( el ) { + el.appendChild( document.createComment( "" ) ); + return !el.getElementsByTagName( "*" ).length; + } ); // Support: IE<9 support.getElementsByClassName = rnative.test( document.getElementsByClassName ); @@ -1123,38 +1197,38 @@ setDocument = Sizzle.setDocument = function( node ) { // Check if getElementById returns elements by name // The broken getElementById methods don't pick up programmatically-set names, // so use a roundabout getElementsByName test - support.getById = assert(function( el ) { + support.getById = assert( function( el ) { docElem.appendChild( el ).id = expando; return !document.getElementsByName || !document.getElementsByName( expando ).length; - }); + } ); // ID filter and find if ( support.getById ) { - Expr.filter["ID"] = function( id ) { + Expr.filter[ "ID" ] = function( id ) { var attrId = id.replace( runescape, funescape ); return function( elem ) { - return elem.getAttribute("id") === attrId; + return elem.getAttribute( "id" ) === attrId; }; }; - Expr.find["ID"] = function( id, context ) { + Expr.find[ "ID" ] = function( id, context ) { if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { var elem = context.getElementById( id ); return elem ? [ elem ] : []; } }; } else { - Expr.filter["ID"] = function( id ) { + Expr.filter[ "ID" ] = function( id ) { var attrId = id.replace( runescape, funescape ); return function( elem ) { var node = typeof elem.getAttributeNode !== "undefined" && - elem.getAttributeNode("id"); + elem.getAttributeNode( "id" ); return node && node.value === attrId; }; }; // Support: IE 6 - 7 only // getElementById is not reliable as a find shortcut - Expr.find["ID"] = function( id, context ) { + Expr.find[ "ID" ] = function( id, context ) { if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { var node, i, elems, elem = context.getElementById( id ); @@ -1162,7 +1236,7 @@ setDocument = Sizzle.setDocument = function( node ) { if ( elem ) { // Verify the id attribute - node = elem.getAttributeNode("id"); + node = elem.getAttributeNode( "id" ); if ( node && node.value === id ) { return [ elem ]; } @@ -1170,8 +1244,8 @@ setDocument = Sizzle.setDocument = function( node ) { // Fall back on getElementsByName elems = context.getElementsByName( id ); i = 0; - while ( (elem = elems[i++]) ) { - node = elem.getAttributeNode("id"); + while ( ( elem = elems[ i++ ] ) ) { + node = elem.getAttributeNode( "id" ); if ( node && node.value === id ) { return [ elem ]; } @@ -1184,7 +1258,7 @@ setDocument = Sizzle.setDocument = function( node ) { } // Tag - Expr.find["TAG"] = support.getElementsByTagName ? + Expr.find[ "TAG" ] = support.getElementsByTagName ? function( tag, context ) { if ( typeof context.getElementsByTagName !== "undefined" ) { return context.getElementsByTagName( tag ); @@ -1199,12 +1273,13 @@ setDocument = Sizzle.setDocument = function( node ) { var elem, tmp = [], i = 0, + // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too results = context.getElementsByTagName( tag ); // Filter out possible comments if ( tag === "*" ) { - while ( (elem = results[i++]) ) { + while ( ( elem = results[ i++ ] ) ) { if ( elem.nodeType === 1 ) { tmp.push( elem ); } @@ -1216,7 +1291,7 @@ setDocument = Sizzle.setDocument = function( node ) { }; // Class - Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) { + Expr.find[ "CLASS" ] = support.getElementsByClassName && function( className, context ) { if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) { return context.getElementsByClassName( className ); } @@ -1237,10 +1312,14 @@ setDocument = Sizzle.setDocument = function( node ) { // See https://bugs.jquery.com/ticket/13378 rbuggyQSA = []; - if ( (support.qsa = rnative.test( document.querySelectorAll )) ) { + if ( ( support.qsa = rnative.test( document.querySelectorAll ) ) ) { + // Build QSA regex // Regex strategy adopted from Diego Perini - assert(function( el ) { + assert( function( el ) { + + var input; + // Select is set to empty string on purpose // This is to test IE's treatment of not explicitly // setting a boolean content attribute, @@ -1254,78 +1333,98 @@ setDocument = Sizzle.setDocument = function( node ) { // Nothing should be selected when empty strings follow ^= or $= or *= // The test attribute must be unknown in Opera but "safe" for WinRT // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section - if ( el.querySelectorAll("[msallowcapture^='']").length ) { + if ( el.querySelectorAll( "[msallowcapture^='']" ).length ) { rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); } // Support: IE8 // Boolean attributes and "value" are not treated correctly - if ( !el.querySelectorAll("[selected]").length ) { + if ( !el.querySelectorAll( "[selected]" ).length ) { rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); } // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+ if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) { - rbuggyQSA.push("~="); + rbuggyQSA.push( "~=" ); + } + + // Support: IE 11+, Edge 15 - 18+ + // IE 11/Edge don't find elements on a `[name='']` query in some cases. + // Adding a temporary attribute to the document before the selection works + // around the issue. + // Interestingly, IE 10 & older don't seem to have the issue. + input = document.createElement( "input" ); + input.setAttribute( "name", "" ); + el.appendChild( input ); + if ( !el.querySelectorAll( "[name='']" ).length ) { + rbuggyQSA.push( "\\[" + whitespace + "*name" + whitespace + "*=" + + whitespace + "*(?:''|\"\")" ); } // Webkit/Opera - :checked should return selected option elements // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked // IE8 throws error here and will not see later tests - if ( !el.querySelectorAll(":checked").length ) { - rbuggyQSA.push(":checked"); + if ( !el.querySelectorAll( ":checked" ).length ) { + rbuggyQSA.push( ":checked" ); } // Support: Safari 8+, iOS 8+ // https://bugs.webkit.org/show_bug.cgi?id=136851 // In-page `selector#id sibling-combinator selector` fails if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) { - rbuggyQSA.push(".#.+[+~]"); + rbuggyQSA.push( ".#.+[+~]" ); } - }); - assert(function( el ) { + // Support: Firefox <=3.6 - 5 only + // Old Firefox doesn't throw on a badly-escaped identifier. + el.querySelectorAll( "\\\f" ); + rbuggyQSA.push( "[\\r\\n\\f]" ); + } ); + + assert( function( el ) { el.innerHTML = "" + ""; // Support: Windows 8 Native Apps // The type and name attributes are restricted during .innerHTML assignment - var input = document.createElement("input"); + var input = document.createElement( "input" ); input.setAttribute( "type", "hidden" ); el.appendChild( input ).setAttribute( "name", "D" ); // Support: IE8 // Enforce case-sensitivity of name attribute - if ( el.querySelectorAll("[name=d]").length ) { + if ( el.querySelectorAll( "[name=d]" ).length ) { rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); } // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) // IE8 throws error here and will not see later tests - if ( el.querySelectorAll(":enabled").length !== 2 ) { + if ( el.querySelectorAll( ":enabled" ).length !== 2 ) { rbuggyQSA.push( ":enabled", ":disabled" ); } // Support: IE9-11+ // IE's :disabled selector does not pick up the children of disabled fieldsets docElem.appendChild( el ).disabled = true; - if ( el.querySelectorAll(":disabled").length !== 2 ) { + if ( el.querySelectorAll( ":disabled" ).length !== 2 ) { rbuggyQSA.push( ":enabled", ":disabled" ); } + // Support: Opera 10 - 11 only // Opera 10-11 does not throw on post-comma invalid pseudos - el.querySelectorAll("*,:x"); - rbuggyQSA.push(",.*:"); - }); + el.querySelectorAll( "*,:x" ); + rbuggyQSA.push( ",.*:" ); + } ); } - if ( (support.matchesSelector = rnative.test( (matches = docElem.matches || + if ( ( support.matchesSelector = rnative.test( ( matches = docElem.matches || docElem.webkitMatchesSelector || docElem.mozMatchesSelector || docElem.oMatchesSelector || - docElem.msMatchesSelector) )) ) { + docElem.msMatchesSelector ) ) ) ) { + + assert( function( el ) { - assert(function( el ) { // Check to see if it's possible to do matchesSelector // on a disconnected node (IE 9) support.disconnectedMatch = matches.call( el, "*" ); @@ -1334,11 +1433,11 @@ setDocument = Sizzle.setDocument = function( node ) { // Gecko does not error, returns false instead matches.call( el, "[s!='']:x" ); rbuggyMatches.push( "!=", pseudos ); - }); + } ); } - rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") ); - rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") ); + rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) ); + rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join( "|" ) ); /* Contains ---------------------------------------------------------------------- */ @@ -1355,11 +1454,11 @@ setDocument = Sizzle.setDocument = function( node ) { adown.contains ? adown.contains( bup ) : a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 - )); + ) ); } : function( a, b ) { if ( b ) { - while ( (b = b.parentNode) ) { + while ( ( b = b.parentNode ) ) { if ( b === a ) { return true; } @@ -1388,7 +1487,11 @@ setDocument = Sizzle.setDocument = function( node ) { } // Calculate position if both inputs belong to the same document - compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ? + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + compare = ( a.ownerDocument || a ) == ( b.ownerDocument || b ) ? a.compareDocumentPosition( b ) : // Otherwise we know they are disconnected @@ -1396,13 +1499,24 @@ setDocument = Sizzle.setDocument = function( node ) { // Disconnected nodes if ( compare & 1 || - (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) { + ( !support.sortDetached && b.compareDocumentPosition( a ) === compare ) ) { // Choose the first element that is related to our preferred document - if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) { + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( a == document || a.ownerDocument == preferredDoc && + contains( preferredDoc, a ) ) { return -1; } - if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) { + + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( b == document || b.ownerDocument == preferredDoc && + contains( preferredDoc, b ) ) { return 1; } @@ -1415,6 +1529,7 @@ setDocument = Sizzle.setDocument = function( node ) { return compare & 4 ? -1 : 1; } : function( a, b ) { + // Exit early if the nodes are identical if ( a === b ) { hasDuplicate = true; @@ -1430,8 +1545,14 @@ setDocument = Sizzle.setDocument = function( node ) { // Parentless nodes are either documents or disconnected if ( !aup || !bup ) { - return a === document ? -1 : - b === document ? 1 : + + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + /* eslint-disable eqeqeq */ + return a == document ? -1 : + b == document ? 1 : + /* eslint-enable eqeqeq */ aup ? -1 : bup ? 1 : sortInput ? @@ -1445,26 +1566,32 @@ setDocument = Sizzle.setDocument = function( node ) { // Otherwise we need full lists of their ancestors for comparison cur = a; - while ( (cur = cur.parentNode) ) { + while ( ( cur = cur.parentNode ) ) { ap.unshift( cur ); } cur = b; - while ( (cur = cur.parentNode) ) { + while ( ( cur = cur.parentNode ) ) { bp.unshift( cur ); } // Walk down the tree looking for a discrepancy - while ( ap[i] === bp[i] ) { + while ( ap[ i ] === bp[ i ] ) { i++; } return i ? + // Do a sibling check if the nodes have a common ancestor - siblingCheck( ap[i], bp[i] ) : + siblingCheck( ap[ i ], bp[ i ] ) : // Otherwise nodes in our document sort first - ap[i] === preferredDoc ? -1 : - bp[i] === preferredDoc ? 1 : + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + /* eslint-disable eqeqeq */ + ap[ i ] == preferredDoc ? -1 : + bp[ i ] == preferredDoc ? 1 : + /* eslint-enable eqeqeq */ 0; }; @@ -1476,16 +1603,10 @@ Sizzle.matches = function( expr, elements ) { }; Sizzle.matchesSelector = function( elem, expr ) { - // Set document vars if needed - if ( ( elem.ownerDocument || elem ) !== document ) { - setDocument( elem ); - } - - // Make sure that attribute selectors are quoted - expr = expr.replace( rattributeQuotes, "='$1']" ); + setDocument( elem ); if ( support.matchesSelector && documentIsHTML && - !compilerCache[ expr + " " ] && + !nonnativeSelectorCache[ expr + " " ] && ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { @@ -1494,32 +1615,46 @@ Sizzle.matchesSelector = function( elem, expr ) { // IE 9's matchesSelector returns false on disconnected nodes if ( ret || support.disconnectedMatch || - // As well, disconnected nodes are said to be in a document - // fragment in IE 9 - elem.document && elem.document.nodeType !== 11 ) { + + // As well, disconnected nodes are said to be in a document + // fragment in IE 9 + elem.document && elem.document.nodeType !== 11 ) { return ret; } - } catch (e) {} + } catch ( e ) { + nonnativeSelectorCache( expr, true ); + } } return Sizzle( expr, document, null, [ elem ] ).length > 0; }; Sizzle.contains = function( context, elem ) { + // Set document vars if needed - if ( ( context.ownerDocument || context ) !== document ) { + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( ( context.ownerDocument || context ) != document ) { setDocument( context ); } return contains( context, elem ); }; Sizzle.attr = function( elem, name ) { + // Set document vars if needed - if ( ( elem.ownerDocument || elem ) !== document ) { + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( ( elem.ownerDocument || elem ) != document ) { setDocument( elem ); } var fn = Expr.attrHandle[ name.toLowerCase() ], + // Don't get fooled by Object.prototype properties (jQuery #13807) val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? fn( elem, name, !documentIsHTML ) : @@ -1529,13 +1664,13 @@ Sizzle.attr = function( elem, name ) { val : support.attributes || !documentIsHTML ? elem.getAttribute( name ) : - (val = elem.getAttributeNode(name)) && val.specified ? + ( val = elem.getAttributeNode( name ) ) && val.specified ? val.value : null; }; Sizzle.escape = function( sel ) { - return (sel + "").replace( rcssescape, fcssescape ); + return ( sel + "" ).replace( rcssescape, fcssescape ); }; Sizzle.error = function( msg ) { @@ -1558,7 +1693,7 @@ Sizzle.uniqueSort = function( results ) { results.sort( sortOrder ); if ( hasDuplicate ) { - while ( (elem = results[i++]) ) { + while ( ( elem = results[ i++ ] ) ) { if ( elem === results[ i ] ) { j = duplicates.push( i ); } @@ -1586,17 +1721,21 @@ getText = Sizzle.getText = function( elem ) { nodeType = elem.nodeType; if ( !nodeType ) { + // If no nodeType, this is expected to be an array - while ( (node = elem[i++]) ) { + while ( ( node = elem[ i++ ] ) ) { + // Do not traverse comment nodes ret += getText( node ); } } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { + // Use textContent for elements // innerText usage removed for consistency of new lines (jQuery #11153) if ( typeof elem.textContent === "string" ) { return elem.textContent; } else { + // Traverse its children for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { ret += getText( elem ); @@ -1605,6 +1744,7 @@ getText = Sizzle.getText = function( elem ) { } else if ( nodeType === 3 || nodeType === 4 ) { return elem.nodeValue; } + // Do not include comment or processing instruction nodes return ret; @@ -1632,19 +1772,21 @@ Expr = Sizzle.selectors = { preFilter: { "ATTR": function( match ) { - match[1] = match[1].replace( runescape, funescape ); + match[ 1 ] = match[ 1 ].replace( runescape, funescape ); // Move the given value to match[3] whether quoted or unquoted - match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape ); + match[ 3 ] = ( match[ 3 ] || match[ 4 ] || + match[ 5 ] || "" ).replace( runescape, funescape ); - if ( match[2] === "~=" ) { - match[3] = " " + match[3] + " "; + if ( match[ 2 ] === "~=" ) { + match[ 3 ] = " " + match[ 3 ] + " "; } return match.slice( 0, 4 ); }, "CHILD": function( match ) { + /* matches from matchExpr["CHILD"] 1 type (only|nth|...) 2 what (child|of-type) @@ -1655,22 +1797,25 @@ Expr = Sizzle.selectors = { 7 sign of y-component 8 y of y-component */ - match[1] = match[1].toLowerCase(); + match[ 1 ] = match[ 1 ].toLowerCase(); + + if ( match[ 1 ].slice( 0, 3 ) === "nth" ) { - if ( match[1].slice( 0, 3 ) === "nth" ) { // nth-* requires argument - if ( !match[3] ) { - Sizzle.error( match[0] ); + if ( !match[ 3 ] ) { + Sizzle.error( match[ 0 ] ); } // numeric x and y parameters for Expr.filter.CHILD // remember that false/true cast respectively to 0/1 - match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) ); - match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" ); + match[ 4 ] = +( match[ 4 ] ? + match[ 5 ] + ( match[ 6 ] || 1 ) : + 2 * ( match[ 3 ] === "even" || match[ 3 ] === "odd" ) ); + match[ 5 ] = +( ( match[ 7 ] + match[ 8 ] ) || match[ 3 ] === "odd" ); - // other types prohibit arguments - } else if ( match[3] ) { - Sizzle.error( match[0] ); + // other types prohibit arguments + } else if ( match[ 3 ] ) { + Sizzle.error( match[ 0 ] ); } return match; @@ -1678,26 +1823,28 @@ Expr = Sizzle.selectors = { "PSEUDO": function( match ) { var excess, - unquoted = !match[6] && match[2]; + unquoted = !match[ 6 ] && match[ 2 ]; - if ( matchExpr["CHILD"].test( match[0] ) ) { + if ( matchExpr[ "CHILD" ].test( match[ 0 ] ) ) { return null; } // Accept quoted arguments as-is - if ( match[3] ) { - match[2] = match[4] || match[5] || ""; + if ( match[ 3 ] ) { + match[ 2 ] = match[ 4 ] || match[ 5 ] || ""; // Strip excess characters from unquoted arguments } else if ( unquoted && rpseudo.test( unquoted ) && + // Get excess from tokenize (recursively) - (excess = tokenize( unquoted, true )) && + ( excess = tokenize( unquoted, true ) ) && + // advance to the next closing parenthesis - (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { + ( excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length ) ) { // excess is a negative index - match[0] = match[0].slice( 0, excess ); - match[2] = unquoted.slice( 0, excess ); + match[ 0 ] = match[ 0 ].slice( 0, excess ); + match[ 2 ] = unquoted.slice( 0, excess ); } // Return only captures needed by the pseudo filter method (type and argument) @@ -1710,7 +1857,9 @@ Expr = Sizzle.selectors = { "TAG": function( nodeNameSelector ) { var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); return nodeNameSelector === "*" ? - function() { return true; } : + function() { + return true; + } : function( elem ) { return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; }; @@ -1720,10 +1869,16 @@ Expr = Sizzle.selectors = { var pattern = classCache[ className + " " ]; return pattern || - (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && - classCache( className, function( elem ) { - return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" ); - }); + ( pattern = new RegExp( "(^|" + whitespace + + ")" + className + "(" + whitespace + "|$)" ) ) && classCache( + className, function( elem ) { + return pattern.test( + typeof elem.className === "string" && elem.className || + typeof elem.getAttribute !== "undefined" && + elem.getAttribute( "class" ) || + "" + ); + } ); }, "ATTR": function( name, operator, check ) { @@ -1739,6 +1894,8 @@ Expr = Sizzle.selectors = { result += ""; + /* eslint-disable max-len */ + return operator === "=" ? result === check : operator === "!=" ? result !== check : operator === "^=" ? check && result.indexOf( check ) === 0 : @@ -1747,10 +1904,12 @@ Expr = Sizzle.selectors = { operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 : operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : false; + /* eslint-enable max-len */ + }; }, - "CHILD": function( type, what, argument, first, last ) { + "CHILD": function( type, what, _argument, first, last ) { var simple = type.slice( 0, 3 ) !== "nth", forward = type.slice( -4 ) !== "last", ofType = what === "of-type"; @@ -1762,7 +1921,7 @@ Expr = Sizzle.selectors = { return !!elem.parentNode; } : - function( elem, context, xml ) { + function( elem, _context, xml ) { var cache, uniqueCache, outerCache, node, nodeIndex, start, dir = simple !== forward ? "nextSibling" : "previousSibling", parent = elem.parentNode, @@ -1776,7 +1935,7 @@ Expr = Sizzle.selectors = { if ( simple ) { while ( dir ) { node = elem; - while ( (node = node[ dir ]) ) { + while ( ( node = node[ dir ] ) ) { if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) { @@ -1784,6 +1943,7 @@ Expr = Sizzle.selectors = { return false; } } + // Reverse direction for :only-* (if we haven't yet done so) start = dir = type === "only" && !start && "nextSibling"; } @@ -1799,22 +1959,22 @@ Expr = Sizzle.selectors = { // ...in a gzip-friendly way node = parent; - outerCache = node[ expando ] || (node[ expando ] = {}); + outerCache = node[ expando ] || ( node[ expando ] = {} ); // Support: IE <9 only // Defend against cloned attroperties (jQuery gh-1709) uniqueCache = outerCache[ node.uniqueID ] || - (outerCache[ node.uniqueID ] = {}); + ( outerCache[ node.uniqueID ] = {} ); cache = uniqueCache[ type ] || []; nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; diff = nodeIndex && cache[ 2 ]; node = nodeIndex && parent.childNodes[ nodeIndex ]; - while ( (node = ++nodeIndex && node && node[ dir ] || + while ( ( node = ++nodeIndex && node && node[ dir ] || // Fallback to seeking `elem` from the start - (diff = nodeIndex = 0) || start.pop()) ) { + ( diff = nodeIndex = 0 ) || start.pop() ) ) { // When found, cache indexes on `parent` and break if ( node.nodeType === 1 && ++diff && node === elem ) { @@ -1824,16 +1984,18 @@ Expr = Sizzle.selectors = { } } else { + // Use previously-cached element index if available if ( useCache ) { + // ...in a gzip-friendly way node = elem; - outerCache = node[ expando ] || (node[ expando ] = {}); + outerCache = node[ expando ] || ( node[ expando ] = {} ); // Support: IE <9 only // Defend against cloned attroperties (jQuery gh-1709) uniqueCache = outerCache[ node.uniqueID ] || - (outerCache[ node.uniqueID ] = {}); + ( outerCache[ node.uniqueID ] = {} ); cache = uniqueCache[ type ] || []; nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; @@ -1843,9 +2005,10 @@ Expr = Sizzle.selectors = { // xml :nth-child(...) // or :nth-last-child(...) or :nth(-last)?-of-type(...) if ( diff === false ) { + // Use the same loop as above to seek `elem` from the start - while ( (node = ++nodeIndex && node && node[ dir ] || - (diff = nodeIndex = 0) || start.pop()) ) { + while ( ( node = ++nodeIndex && node && node[ dir ] || + ( diff = nodeIndex = 0 ) || start.pop() ) ) { if ( ( ofType ? node.nodeName.toLowerCase() === name : @@ -1854,12 +2017,13 @@ Expr = Sizzle.selectors = { // Cache the index of each encountered element if ( useCache ) { - outerCache = node[ expando ] || (node[ expando ] = {}); + outerCache = node[ expando ] || + ( node[ expando ] = {} ); // Support: IE <9 only // Defend against cloned attroperties (jQuery gh-1709) uniqueCache = outerCache[ node.uniqueID ] || - (outerCache[ node.uniqueID ] = {}); + ( outerCache[ node.uniqueID ] = {} ); uniqueCache[ type ] = [ dirruns, diff ]; } @@ -1880,6 +2044,7 @@ Expr = Sizzle.selectors = { }, "PSEUDO": function( pseudo, argument ) { + // pseudo-class names are case-insensitive // http://www.w3.org/TR/selectors/#pseudo-classes // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters @@ -1899,15 +2064,15 @@ Expr = Sizzle.selectors = { if ( fn.length > 1 ) { args = [ pseudo, pseudo, "", argument ]; return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? - markFunction(function( seed, matches ) { + markFunction( function( seed, matches ) { var idx, matched = fn( seed, argument ), i = matched.length; while ( i-- ) { - idx = indexOf( seed, matched[i] ); - seed[ idx ] = !( matches[ idx ] = matched[i] ); + idx = indexOf( seed, matched[ i ] ); + seed[ idx ] = !( matches[ idx ] = matched[ i ] ); } - }) : + } ) : function( elem ) { return fn( elem, 0, args ); }; @@ -1918,8 +2083,10 @@ Expr = Sizzle.selectors = { }, pseudos: { + // Potentially complex pseudos - "not": markFunction(function( selector ) { + "not": markFunction( function( selector ) { + // Trim the selector passed to compile // to avoid treating leading and trailing // spaces as combinators @@ -1928,39 +2095,40 @@ Expr = Sizzle.selectors = { matcher = compile( selector.replace( rtrim, "$1" ) ); return matcher[ expando ] ? - markFunction(function( seed, matches, context, xml ) { + markFunction( function( seed, matches, _context, xml ) { var elem, unmatched = matcher( seed, null, xml, [] ), i = seed.length; // Match elements unmatched by `matcher` while ( i-- ) { - if ( (elem = unmatched[i]) ) { - seed[i] = !(matches[i] = elem); + if ( ( elem = unmatched[ i ] ) ) { + seed[ i ] = !( matches[ i ] = elem ); } } - }) : - function( elem, context, xml ) { - input[0] = elem; + } ) : + function( elem, _context, xml ) { + input[ 0 ] = elem; matcher( input, null, xml, results ); + // Don't keep the element (issue #299) - input[0] = null; + input[ 0 ] = null; return !results.pop(); }; - }), + } ), - "has": markFunction(function( selector ) { + "has": markFunction( function( selector ) { return function( elem ) { return Sizzle( selector, elem ).length > 0; }; - }), + } ), - "contains": markFunction(function( text ) { + "contains": markFunction( function( text ) { text = text.replace( runescape, funescape ); return function( elem ) { - return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; + return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1; }; - }), + } ), // "Whether an element is represented by a :lang() selector // is based solely on the element's language value @@ -1970,25 +2138,26 @@ Expr = Sizzle.selectors = { // The identifier C does not have to be a valid language name." // http://www.w3.org/TR/selectors/#lang-pseudo "lang": markFunction( function( lang ) { + // lang value must be a valid identifier - if ( !ridentifier.test(lang || "") ) { + if ( !ridentifier.test( lang || "" ) ) { Sizzle.error( "unsupported lang: " + lang ); } lang = lang.replace( runescape, funescape ).toLowerCase(); return function( elem ) { var elemLang; do { - if ( (elemLang = documentIsHTML ? + if ( ( elemLang = documentIsHTML ? elem.lang : - elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) { + elem.getAttribute( "xml:lang" ) || elem.getAttribute( "lang" ) ) ) { elemLang = elemLang.toLowerCase(); return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; } - } while ( (elem = elem.parentNode) && elem.nodeType === 1 ); + } while ( ( elem = elem.parentNode ) && elem.nodeType === 1 ); return false; }; - }), + } ), // Miscellaneous "target": function( elem ) { @@ -2001,7 +2170,9 @@ Expr = Sizzle.selectors = { }, "focus": function( elem ) { - return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); + return elem === document.activeElement && + ( !document.hasFocus || document.hasFocus() ) && + !!( elem.type || elem.href || ~elem.tabIndex ); }, // Boolean properties @@ -2009,16 +2180,20 @@ Expr = Sizzle.selectors = { "disabled": createDisabledPseudo( true ), "checked": function( elem ) { + // In CSS3, :checked should return both checked and selected elements // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked var nodeName = elem.nodeName.toLowerCase(); - return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); + return ( nodeName === "input" && !!elem.checked ) || + ( nodeName === "option" && !!elem.selected ); }, "selected": function( elem ) { + // Accessing this property makes selected-by-default // options in Safari work properly if ( elem.parentNode ) { + // eslint-disable-next-line no-unused-expressions elem.parentNode.selectedIndex; } @@ -2027,6 +2202,7 @@ Expr = Sizzle.selectors = { // Contents "empty": function( elem ) { + // http://www.w3.org/TR/selectors/#empty-pseudo // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), // but not by others (comment: 8; processing instruction: 7; etc.) @@ -2040,7 +2216,7 @@ Expr = Sizzle.selectors = { }, "parent": function( elem ) { - return !Expr.pseudos["empty"]( elem ); + return !Expr.pseudos[ "empty" ]( elem ); }, // Element/input types @@ -2064,57 +2240,62 @@ Expr = Sizzle.selectors = { // Support: IE<8 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" - ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" ); + ( ( attr = elem.getAttribute( "type" ) ) == null || + attr.toLowerCase() === "text" ); }, // Position-in-collection - "first": createPositionalPseudo(function() { + "first": createPositionalPseudo( function() { return [ 0 ]; - }), + } ), - "last": createPositionalPseudo(function( matchIndexes, length ) { + "last": createPositionalPseudo( function( _matchIndexes, length ) { return [ length - 1 ]; - }), + } ), - "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { + "eq": createPositionalPseudo( function( _matchIndexes, length, argument ) { return [ argument < 0 ? argument + length : argument ]; - }), + } ), - "even": createPositionalPseudo(function( matchIndexes, length ) { + "even": createPositionalPseudo( function( matchIndexes, length ) { var i = 0; for ( ; i < length; i += 2 ) { matchIndexes.push( i ); } return matchIndexes; - }), + } ), - "odd": createPositionalPseudo(function( matchIndexes, length ) { + "odd": createPositionalPseudo( function( matchIndexes, length ) { var i = 1; for ( ; i < length; i += 2 ) { matchIndexes.push( i ); } return matchIndexes; - }), + } ), - "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { - var i = argument < 0 ? argument + length : argument; + "lt": createPositionalPseudo( function( matchIndexes, length, argument ) { + var i = argument < 0 ? + argument + length : + argument > length ? + length : + argument; for ( ; --i >= 0; ) { matchIndexes.push( i ); } return matchIndexes; - }), + } ), - "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { + "gt": createPositionalPseudo( function( matchIndexes, length, argument ) { var i = argument < 0 ? argument + length : argument; for ( ; ++i < length; ) { matchIndexes.push( i ); } return matchIndexes; - }) + } ) } }; -Expr.pseudos["nth"] = Expr.pseudos["eq"]; +Expr.pseudos[ "nth" ] = Expr.pseudos[ "eq" ]; // Add button/input type pseudos for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { @@ -2145,37 +2326,39 @@ tokenize = Sizzle.tokenize = function( selector, parseOnly ) { while ( soFar ) { // Comma and first run - if ( !matched || (match = rcomma.exec( soFar )) ) { + if ( !matched || ( match = rcomma.exec( soFar ) ) ) { if ( match ) { + // Don't consume trailing commas as valid - soFar = soFar.slice( match[0].length ) || soFar; + soFar = soFar.slice( match[ 0 ].length ) || soFar; } - groups.push( (tokens = []) ); + groups.push( ( tokens = [] ) ); } matched = false; // Combinators - if ( (match = rcombinators.exec( soFar )) ) { + if ( ( match = rcombinators.exec( soFar ) ) ) { matched = match.shift(); - tokens.push({ + tokens.push( { value: matched, + // Cast descendant combinators to space - type: match[0].replace( rtrim, " " ) - }); + type: match[ 0 ].replace( rtrim, " " ) + } ); soFar = soFar.slice( matched.length ); } // Filters for ( type in Expr.filter ) { - if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || - (match = preFilters[ type ]( match ))) ) { + if ( ( match = matchExpr[ type ].exec( soFar ) ) && ( !preFilters[ type ] || + ( match = preFilters[ type ]( match ) ) ) ) { matched = match.shift(); - tokens.push({ + tokens.push( { value: matched, type: type, matches: match - }); + } ); soFar = soFar.slice( matched.length ); } } @@ -2192,6 +2375,7 @@ tokenize = Sizzle.tokenize = function( selector, parseOnly ) { soFar.length : soFar ? Sizzle.error( selector ) : + // Cache the tokens tokenCache( selector, groups ).slice( 0 ); }; @@ -2201,7 +2385,7 @@ function toSelector( tokens ) { len = tokens.length, selector = ""; for ( ; i < len; i++ ) { - selector += tokens[i].value; + selector += tokens[ i ].value; } return selector; } @@ -2214,9 +2398,10 @@ function addCombinator( matcher, combinator, base ) { doneName = done++; return combinator.first ? + // Check against closest ancestor/preceding element function( elem, context, xml ) { - while ( (elem = elem[ dir ]) ) { + while ( ( elem = elem[ dir ] ) ) { if ( elem.nodeType === 1 || checkNonElements ) { return matcher( elem, context, xml ); } @@ -2231,7 +2416,7 @@ function addCombinator( matcher, combinator, base ) { // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching if ( xml ) { - while ( (elem = elem[ dir ]) ) { + while ( ( elem = elem[ dir ] ) ) { if ( elem.nodeType === 1 || checkNonElements ) { if ( matcher( elem, context, xml ) ) { return true; @@ -2239,27 +2424,29 @@ function addCombinator( matcher, combinator, base ) { } } } else { - while ( (elem = elem[ dir ]) ) { + while ( ( elem = elem[ dir ] ) ) { if ( elem.nodeType === 1 || checkNonElements ) { - outerCache = elem[ expando ] || (elem[ expando ] = {}); + outerCache = elem[ expando ] || ( elem[ expando ] = {} ); // Support: IE <9 only // Defend against cloned attroperties (jQuery gh-1709) - uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {}); + uniqueCache = outerCache[ elem.uniqueID ] || + ( outerCache[ elem.uniqueID ] = {} ); if ( skip && skip === elem.nodeName.toLowerCase() ) { elem = elem[ dir ] || elem; - } else if ( (oldCache = uniqueCache[ key ]) && + } else if ( ( oldCache = uniqueCache[ key ] ) && oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { // Assign to newCache so results back-propagate to previous elements - return (newCache[ 2 ] = oldCache[ 2 ]); + return ( newCache[ 2 ] = oldCache[ 2 ] ); } else { + // Reuse newcache so results back-propagate to previous elements uniqueCache[ key ] = newCache; // A match means we're done; a fail means we have to keep checking - if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) { + if ( ( newCache[ 2 ] = matcher( elem, context, xml ) ) ) { return true; } } @@ -2275,20 +2462,20 @@ function elementMatcher( matchers ) { function( elem, context, xml ) { var i = matchers.length; while ( i-- ) { - if ( !matchers[i]( elem, context, xml ) ) { + if ( !matchers[ i ]( elem, context, xml ) ) { return false; } } return true; } : - matchers[0]; + matchers[ 0 ]; } function multipleContexts( selector, contexts, results ) { var i = 0, len = contexts.length; for ( ; i < len; i++ ) { - Sizzle( selector, contexts[i], results ); + Sizzle( selector, contexts[ i ], results ); } return results; } @@ -2301,7 +2488,7 @@ function condense( unmatched, map, filter, context, xml ) { mapped = map != null; for ( ; i < len; i++ ) { - if ( (elem = unmatched[i]) ) { + if ( ( elem = unmatched[ i ] ) ) { if ( !filter || filter( elem, context, xml ) ) { newUnmatched.push( elem ); if ( mapped ) { @@ -2321,14 +2508,18 @@ function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postS if ( postFinder && !postFinder[ expando ] ) { postFinder = setMatcher( postFinder, postSelector ); } - return markFunction(function( seed, results, context, xml ) { + return markFunction( function( seed, results, context, xml ) { var temp, i, elem, preMap = [], postMap = [], preexisting = results.length, // Get initial elements from seed or context - elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), + elems = seed || multipleContexts( + selector || "*", + context.nodeType ? [ context ] : context, + [] + ), // Prefilter to get matcher input, preserving a map for seed-results synchronization matcherIn = preFilter && ( seed || !selector ) ? @@ -2336,6 +2527,7 @@ function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postS elems, matcherOut = matcher ? + // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, postFinder || ( seed ? preFilter : preexisting || postFilter ) ? @@ -2359,8 +2551,8 @@ function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postS // Un-match failing elements by moving them back to matcherIn i = temp.length; while ( i-- ) { - if ( (elem = temp[i]) ) { - matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); + if ( ( elem = temp[ i ] ) ) { + matcherOut[ postMap[ i ] ] = !( matcherIn[ postMap[ i ] ] = elem ); } } } @@ -2368,25 +2560,27 @@ function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postS if ( seed ) { if ( postFinder || preFilter ) { if ( postFinder ) { + // Get the final matcherOut by condensing this intermediate into postFinder contexts temp = []; i = matcherOut.length; while ( i-- ) { - if ( (elem = matcherOut[i]) ) { + if ( ( elem = matcherOut[ i ] ) ) { + // Restore matcherIn since elem is not yet a final match - temp.push( (matcherIn[i] = elem) ); + temp.push( ( matcherIn[ i ] = elem ) ); } } - postFinder( null, (matcherOut = []), temp, xml ); + postFinder( null, ( matcherOut = [] ), temp, xml ); } // Move matched elements from seed to results to keep them synchronized i = matcherOut.length; while ( i-- ) { - if ( (elem = matcherOut[i]) && - (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) { + if ( ( elem = matcherOut[ i ] ) && + ( temp = postFinder ? indexOf( seed, elem ) : preMap[ i ] ) > -1 ) { - seed[temp] = !(results[temp] = elem); + seed[ temp ] = !( results[ temp ] = elem ); } } } @@ -2404,14 +2598,14 @@ function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postS push.apply( results, matcherOut ); } } - }); + } ); } function matcherFromTokens( tokens ) { var checkContext, matcher, j, len = tokens.length, - leadingRelative = Expr.relative[ tokens[0].type ], - implicitRelative = leadingRelative || Expr.relative[" "], + leadingRelative = Expr.relative[ tokens[ 0 ].type ], + implicitRelative = leadingRelative || Expr.relative[ " " ], i = leadingRelative ? 1 : 0, // The foundational matcher ensures that elements are reachable from top-level context(s) @@ -2423,38 +2617,43 @@ function matcherFromTokens( tokens ) { }, implicitRelative, true ), matchers = [ function( elem, context, xml ) { var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( - (checkContext = context).nodeType ? + ( checkContext = context ).nodeType ? matchContext( elem, context, xml ) : matchAnyContext( elem, context, xml ) ); + // Avoid hanging onto element (issue #299) checkContext = null; return ret; } ]; for ( ; i < len; i++ ) { - if ( (matcher = Expr.relative[ tokens[i].type ]) ) { - matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; + if ( ( matcher = Expr.relative[ tokens[ i ].type ] ) ) { + matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ]; } else { - matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); + matcher = Expr.filter[ tokens[ i ].type ].apply( null, tokens[ i ].matches ); // Return special upon seeing a positional matcher if ( matcher[ expando ] ) { + // Find the next relative operator (if any) for proper handling j = ++i; for ( ; j < len; j++ ) { - if ( Expr.relative[ tokens[j].type ] ) { + if ( Expr.relative[ tokens[ j ].type ] ) { break; } } return setMatcher( i > 1 && elementMatcher( matchers ), i > 1 && toSelector( - // If the preceding token was a descendant combinator, insert an implicit any-element `*` - tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" }) + + // If the preceding token was a descendant combinator, insert an implicit any-element `*` + tokens + .slice( 0, i - 1 ) + .concat( { value: tokens[ i - 2 ].type === " " ? "*" : "" } ) ).replace( rtrim, "$1" ), matcher, i < j && matcherFromTokens( tokens.slice( i, j ) ), - j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), + j < len && matcherFromTokens( ( tokens = tokens.slice( j ) ) ), j < len && toSelector( tokens ) ); } @@ -2475,28 +2674,40 @@ function matcherFromGroupMatchers( elementMatchers, setMatchers ) { unmatched = seed && [], setMatched = [], contextBackup = outermostContext, + // We must always have either seed elements or outermost context - elems = seed || byElement && Expr.find["TAG"]( "*", outermost ), + elems = seed || byElement && Expr.find[ "TAG" ]( "*", outermost ), + // Use integer dirruns iff this is the outermost matcher - dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1), + dirrunsUnique = ( dirruns += contextBackup == null ? 1 : Math.random() || 0.1 ), len = elems.length; if ( outermost ) { - outermostContext = context === document || context || outermost; + + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + outermostContext = context == document || context || outermost; } // Add elements passing elementMatchers directly to results // Support: IE<9, Safari // Tolerate NodeList properties (IE: "length"; Safari: ) matching elements by id - for ( ; i !== len && (elem = elems[i]) != null; i++ ) { + for ( ; i !== len && ( elem = elems[ i ] ) != null; i++ ) { if ( byElement && elem ) { j = 0; - if ( !context && elem.ownerDocument !== document ) { + + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( !context && elem.ownerDocument != document ) { setDocument( elem ); xml = !documentIsHTML; } - while ( (matcher = elementMatchers[j++]) ) { - if ( matcher( elem, context || document, xml) ) { + while ( ( matcher = elementMatchers[ j++ ] ) ) { + if ( matcher( elem, context || document, xml ) ) { results.push( elem ); break; } @@ -2508,8 +2719,9 @@ function matcherFromGroupMatchers( elementMatchers, setMatchers ) { // Track unmatched elements for set filters if ( bySet ) { + // They will have gone through all possible matchers - if ( (elem = !matcher && elem) ) { + if ( ( elem = !matcher && elem ) ) { matchedCount--; } @@ -2533,16 +2745,17 @@ function matcherFromGroupMatchers( elementMatchers, setMatchers ) { // numerically zero. if ( bySet && i !== matchedCount ) { j = 0; - while ( (matcher = setMatchers[j++]) ) { + while ( ( matcher = setMatchers[ j++ ] ) ) { matcher( unmatched, setMatched, context, xml ); } if ( seed ) { + // Reintegrate element matches to eliminate the need for sorting if ( matchedCount > 0 ) { while ( i-- ) { - if ( !(unmatched[i] || setMatched[i]) ) { - setMatched[i] = pop.call( results ); + if ( !( unmatched[ i ] || setMatched[ i ] ) ) { + setMatched[ i ] = pop.call( results ); } } } @@ -2583,13 +2796,14 @@ compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) { cached = compilerCache[ selector + " " ]; if ( !cached ) { + // Generate a function of recursive functions that can be used to check each element if ( !match ) { match = tokenize( selector ); } i = match.length; while ( i-- ) { - cached = matcherFromTokens( match[i] ); + cached = matcherFromTokens( match[ i ] ); if ( cached[ expando ] ) { setMatchers.push( cached ); } else { @@ -2598,7 +2812,10 @@ compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) { } // Cache the compiled function - cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); + cached = compilerCache( + selector, + matcherFromGroupMatchers( elementMatchers, setMatchers ) + ); // Save selector and tokenization cached.selector = selector; @@ -2618,7 +2835,7 @@ compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) { select = Sizzle.select = function( selector, context, results, seed ) { var i, tokens, token, type, find, compiled = typeof selector === "function" && selector, - match = !seed && tokenize( (selector = compiled.selector || selector) ); + match = !seed && tokenize( ( selector = compiled.selector || selector ) ); results = results || []; @@ -2627,11 +2844,12 @@ select = Sizzle.select = function( selector, context, results, seed ) { if ( match.length === 1 ) { // Reduce context if the leading compound selector is an ID - tokens = match[0] = match[0].slice( 0 ); - if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && - context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) { + tokens = match[ 0 ] = match[ 0 ].slice( 0 ); + if ( tokens.length > 2 && ( token = tokens[ 0 ] ).type === "ID" && + context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[ 1 ].type ] ) { - context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0]; + context = ( Expr.find[ "ID" ]( token.matches[ 0 ] + .replace( runescape, funescape ), context ) || [] )[ 0 ]; if ( !context ) { return results; @@ -2644,20 +2862,22 @@ select = Sizzle.select = function( selector, context, results, seed ) { } // Fetch a seed set for right-to-left matching - i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; + i = matchExpr[ "needsContext" ].test( selector ) ? 0 : tokens.length; while ( i-- ) { - token = tokens[i]; + token = tokens[ i ]; // Abort if we hit a combinator - if ( Expr.relative[ (type = token.type) ] ) { + if ( Expr.relative[ ( type = token.type ) ] ) { break; } - if ( (find = Expr.find[ type ]) ) { + if ( ( find = Expr.find[ type ] ) ) { + // Search, expanding context for leading sibling combinators - if ( (seed = find( - token.matches[0].replace( runescape, funescape ), - rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context - )) ) { + if ( ( seed = find( + token.matches[ 0 ].replace( runescape, funescape ), + rsibling.test( tokens[ 0 ].type ) && testContext( context.parentNode ) || + context + ) ) ) { // If seed is empty or no tokens remain, we can return early tokens.splice( i, 1 ); @@ -2688,7 +2908,7 @@ select = Sizzle.select = function( selector, context, results, seed ) { // One-time assignments // Sort stability -support.sortStable = expando.split("").sort( sortOrder ).join("") === expando; +support.sortStable = expando.split( "" ).sort( sortOrder ).join( "" ) === expando; // Support: Chrome 14-35+ // Always assume duplicates if they aren't passed to the comparison function @@ -2699,58 +2919,59 @@ setDocument(); // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) // Detached nodes confoundingly follow *each other* -support.sortDetached = assert(function( el ) { +support.sortDetached = assert( function( el ) { + // Should return 1, but returns 4 (following) - return el.compareDocumentPosition( document.createElement("fieldset") ) & 1; -}); + return el.compareDocumentPosition( document.createElement( "fieldset" ) ) & 1; +} ); // Support: IE<8 // Prevent attribute/property "interpolation" // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx -if ( !assert(function( el ) { +if ( !assert( function( el ) { el.innerHTML = ""; - return el.firstChild.getAttribute("href") === "#" ; -}) ) { + return el.firstChild.getAttribute( "href" ) === "#"; +} ) ) { addHandle( "type|href|height|width", function( elem, name, isXML ) { if ( !isXML ) { return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); } - }); + } ); } // Support: IE<9 // Use defaultValue in place of getAttribute("value") -if ( !support.attributes || !assert(function( el ) { +if ( !support.attributes || !assert( function( el ) { el.innerHTML = ""; el.firstChild.setAttribute( "value", "" ); return el.firstChild.getAttribute( "value" ) === ""; -}) ) { - addHandle( "value", function( elem, name, isXML ) { +} ) ) { + addHandle( "value", function( elem, _name, isXML ) { if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { return elem.defaultValue; } - }); + } ); } // Support: IE<9 // Use getAttributeNode to fetch booleans when getAttribute lies -if ( !assert(function( el ) { - return el.getAttribute("disabled") == null; -}) ) { +if ( !assert( function( el ) { + return el.getAttribute( "disabled" ) == null; +} ) ) { addHandle( booleans, function( elem, name, isXML ) { var val; if ( !isXML ) { return elem[ name ] === true ? name.toLowerCase() : - (val = elem.getAttributeNode( name )) && val.specified ? + ( val = elem.getAttributeNode( name ) ) && val.specified ? val.value : - null; + null; } - }); + } ); } return Sizzle; -})( window ); +} )( window ); @@ -3119,7 +3340,7 @@ jQuery.each( { parents: function( elem ) { return dir( elem, "parentNode" ); }, - parentsUntil: function( elem, i, until ) { + parentsUntil: function( elem, _i, until ) { return dir( elem, "parentNode", until ); }, next: function( elem ) { @@ -3134,10 +3355,10 @@ jQuery.each( { prevAll: function( elem ) { return dir( elem, "previousSibling" ); }, - nextUntil: function( elem, i, until ) { + nextUntil: function( elem, _i, until ) { return dir( elem, "nextSibling", until ); }, - prevUntil: function( elem, i, until ) { + prevUntil: function( elem, _i, until ) { return dir( elem, "previousSibling", until ); }, siblings: function( elem ) { @@ -3147,18 +3368,24 @@ jQuery.each( { return siblings( elem.firstChild ); }, contents: function( elem ) { - if ( nodeName( elem, "iframe" ) ) { - return elem.contentDocument; - } + if ( elem.contentDocument != null && - // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only - // Treat the template element as a regular one in browsers that - // don't support it. - if ( nodeName( elem, "template" ) ) { - elem = elem.content || elem; - } + // Support: IE 11+ + // elements with no `data` attribute has an object + // `contentDocument` with a `null` prototype. + getProto( elem.contentDocument ) ) { - return jQuery.merge( [], elem.childNodes ); + return elem.contentDocument; + } + + // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only + // Treat the template element as a regular one in browsers that + // don't support it. + if ( nodeName( elem, "template" ) ) { + elem = elem.content || elem; + } + + return jQuery.merge( [], elem.childNodes ); } }, function( name, fn ) { jQuery.fn[ name ] = function( until, selector ) { @@ -3490,7 +3717,7 @@ jQuery.extend( { var fns = arguments; return jQuery.Deferred( function( newDefer ) { - jQuery.each( tuples, function( i, tuple ) { + jQuery.each( tuples, function( _i, tuple ) { // Map tuples (progress, done, fail) to arguments (done, fail, progress) var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ]; @@ -3943,7 +4170,7 @@ var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { // ...except when executing function values } else { bulk = fn; - fn = function( elem, key, value ) { + fn = function( elem, _key, value ) { return bulk.call( jQuery( elem ), value ); }; } @@ -3978,7 +4205,7 @@ var rmsPrefix = /^-ms-/, rdashAlpha = /-([a-z])/g; // Used by camelCase as callback to replace() -function fcamelCase( all, letter ) { +function fcamelCase( _all, letter ) { return letter.toUpperCase(); } @@ -4467,6 +4694,26 @@ var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ); var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; +var documentElement = document.documentElement; + + + + var isAttached = function( elem ) { + return jQuery.contains( elem.ownerDocument, elem ); + }, + composed = { composed: true }; + + // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only + // Check attachment across shadow DOM boundaries when possible (gh-3504) + // Support: iOS 10.0-10.2 only + // Early iOS 10 versions support `attachShadow` but not `getRootNode`, + // leading to errors. We need to check for `getRootNode`. + if ( documentElement.getRootNode ) { + isAttached = function( elem ) { + return jQuery.contains( elem.ownerDocument, elem ) || + elem.getRootNode( composed ) === elem.ownerDocument; + }; + } var isHiddenWithinTree = function( elem, el ) { // isHiddenWithinTree might be called from jQuery#filter function; @@ -4481,32 +4728,11 @@ var isHiddenWithinTree = function( elem, el ) { // Support: Firefox <=43 - 45 // Disconnected elements can have computed display: none, so first confirm that elem is // in the document. - jQuery.contains( elem.ownerDocument, elem ) && + isAttached( elem ) && jQuery.css( elem, "display" ) === "none"; }; -var swap = function( elem, options, callback, args ) { - var ret, name, - old = {}; - - // Remember the old values, and insert the new ones - for ( name in options ) { - old[ name ] = elem.style[ name ]; - elem.style[ name ] = options[ name ]; - } - - ret = callback.apply( elem, args || [] ); - - // Revert the old values - for ( name in options ) { - elem.style[ name ] = old[ name ]; - } - - return ret; -}; - - function adjustCSS( elem, prop, valueParts, tween ) { @@ -4523,7 +4749,8 @@ function adjustCSS( elem, prop, valueParts, tween ) { unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), // Starting value computation is required for potential unit mismatches - initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) && + initialInUnit = elem.nodeType && + ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) && rcssNum.exec( jQuery.css( elem, prop ) ); if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { @@ -4670,17 +4897,46 @@ jQuery.fn.extend( { } ); var rcheckableType = ( /^(?:checkbox|radio)$/i ); -var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]+)/i ); +var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i ); var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i ); -// We have to close these tags to support XHTML (#13200) -var wrapMap = { +( function() { + var fragment = document.createDocumentFragment(), + div = fragment.appendChild( document.createElement( "div" ) ), + input = document.createElement( "input" ); + + // Support: Android 4.0 - 4.3 only + // Check state lost if the name is set (#11217) + // Support: Windows Web Apps (WWA) + // `name` and `type` must use .setAttribute for WWA (#14901) + input.setAttribute( "type", "radio" ); + input.setAttribute( "checked", "checked" ); + input.setAttribute( "name", "t" ); + + div.appendChild( input ); + + // Support: Android <=4.1 only + // Older WebKit doesn't clone checked state correctly in fragments + support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; + + // Support: IE <=11 only + // Make sure textarea (and checkbox) defaultValue is properly cloned + div.innerHTML = ""; + support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; // Support: IE <=9 only - option: [ 1, "" ], + // IE <=9 replaces "; + support.option = !!div.lastChild; +} )(); + + +// We have to close these tags to support XHTML (#13200) +var wrapMap = { // XHTML parsers do not magically insert elements in the // same way that tag soup parsers do. So we cannot shorten @@ -4693,12 +4949,14 @@ var wrapMap = { _default: [ 0, "", "" ] }; -// Support: IE <=9 only -wrapMap.optgroup = wrapMap.option; - wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; wrapMap.th = wrapMap.td; +// Support: IE <=9 only +if ( !support.option ) { + wrapMap.optgroup = wrapMap.option = [ 1, "" ]; +} + function getAll( context, tag ) { @@ -4742,7 +5000,7 @@ function setGlobalEval( elems, refElements ) { var rhtml = /<|&#?\w+;/; function buildFragment( elems, context, scripts, selection, ignored ) { - var elem, tmp, tag, wrap, contains, j, + var elem, tmp, tag, wrap, attached, j, fragment = context.createDocumentFragment(), nodes = [], i = 0, @@ -4806,13 +5064,13 @@ function buildFragment( elems, context, scripts, selection, ignored ) { continue; } - contains = jQuery.contains( elem.ownerDocument, elem ); + attached = isAttached( elem ); // Append to fragment tmp = getAll( fragment.appendChild( elem ), "script" ); // Preserve script evaluation history - if ( contains ) { + if ( attached ) { setGlobalEval( tmp ); } @@ -4831,34 +5089,6 @@ function buildFragment( elems, context, scripts, selection, ignored ) { } -( function() { - var fragment = document.createDocumentFragment(), - div = fragment.appendChild( document.createElement( "div" ) ), - input = document.createElement( "input" ); - - // Support: Android 4.0 - 4.3 only - // Check state lost if the name is set (#11217) - // Support: Windows Web Apps (WWA) - // `name` and `type` must use .setAttribute for WWA (#14901) - input.setAttribute( "type", "radio" ); - input.setAttribute( "checked", "checked" ); - input.setAttribute( "name", "t" ); - - div.appendChild( input ); - - // Support: Android <=4.1 only - // Older WebKit doesn't clone checked state correctly in fragments - support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; - - // Support: IE <=11 only - // Make sure textarea (and checkbox) defaultValue is properly cloned - div.innerHTML = ""; - support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; -} )(); -var documentElement = document.documentElement; - - - var rkeyEvent = /^key/, rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/, @@ -4872,8 +5102,19 @@ function returnFalse() { return false; } +// Support: IE <=9 - 11+ +// focus() and blur() are asynchronous, except when they are no-op. +// So expect focus to be synchronous when the element is already active, +// and blur to be synchronous when the element is not already active. +// (focus and blur are always synchronous in other supported browsers, +// this just defines when we can count on it). +function expectSync( elem, type ) { + return ( elem === safeActiveElement() ) === ( type === "focus" ); +} + // Support: IE <=9 only -// See #13393 for more info +// Accessing document.activeElement can throw unexpectedly +// https://bugs.jquery.com/ticket/13393 function safeActiveElement() { try { return document.activeElement; @@ -4956,8 +5197,8 @@ jQuery.event = { special, handlers, type, namespaces, origType, elemData = dataPriv.get( elem ); - // Don't attach events to noData or text/comment nodes (but allow plain objects) - if ( !elemData ) { + // Only attach events to objects that accept data + if ( !acceptData( elem ) ) { return; } @@ -4981,7 +5222,7 @@ jQuery.event = { // Init the element's event structure and main handler, if this is the first if ( !( events = elemData.events ) ) { - events = elemData.events = {}; + events = elemData.events = Object.create( null ); } if ( !( eventHandle = elemData.handle ) ) { eventHandle = elemData.handle = function( e ) { @@ -5139,12 +5380,15 @@ jQuery.event = { dispatch: function( nativeEvent ) { - // Make a writable jQuery.Event from the native event object - var event = jQuery.event.fix( nativeEvent ); - var i, j, ret, matched, handleObj, handlerQueue, args = new Array( arguments.length ), - handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [], + + // Make a writable jQuery.Event from the native event object + event = jQuery.event.fix( nativeEvent ), + + handlers = ( + dataPriv.get( this, "events" ) || Object.create( null ) + )[ event.type ] || [], special = jQuery.event.special[ event.type ] || {}; // Use the fix-ed jQuery.Event rather than the (read-only) native event @@ -5173,9 +5417,10 @@ jQuery.event = { while ( ( handleObj = matched.handlers[ j++ ] ) && !event.isImmediatePropagationStopped() ) { - // Triggered event must either 1) have no namespace, or 2) have namespace(s) - // a subset or equal to those in the bound event (both can have no namespace). - if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) { + // If the event is namespaced, then each handler is only invoked if it is + // specially universal or its namespaces are a superset of the event's. + if ( !event.rnamespace || handleObj.namespace === false || + event.rnamespace.test( handleObj.namespace ) ) { event.handleObj = handleObj; event.data = handleObj.data; @@ -5299,39 +5544,51 @@ jQuery.event = { // Prevent triggered image.load events from bubbling to window.load noBubble: true }, - focus: { - - // Fire native event if possible so blur/focus sequence is correct - trigger: function() { - if ( this !== safeActiveElement() && this.focus ) { - this.focus(); - return false; - } - }, - delegateType: "focusin" - }, - blur: { - trigger: function() { - if ( this === safeActiveElement() && this.blur ) { - this.blur(); - return false; - } - }, - delegateType: "focusout" - }, click: { - // For checkbox, fire native event so checked state will be right - trigger: function() { - if ( this.type === "checkbox" && this.click && nodeName( this, "input" ) ) { - this.click(); - return false; + // Utilize native event to ensure correct state for checkable inputs + setup: function( data ) { + + // For mutual compressibility with _default, replace `this` access with a local var. + // `|| data` is dead code meant only to preserve the variable through minification. + var el = this || data; + + // Claim the first handler + if ( rcheckableType.test( el.type ) && + el.click && nodeName( el, "input" ) ) { + + // dataPriv.set( el, "click", ... ) + leverageNative( el, "click", returnTrue ); } + + // Return false to allow normal processing in the caller + return false; + }, + trigger: function( data ) { + + // For mutual compressibility with _default, replace `this` access with a local var. + // `|| data` is dead code meant only to preserve the variable through minification. + var el = this || data; + + // Force setup before triggering a click + if ( rcheckableType.test( el.type ) && + el.click && nodeName( el, "input" ) ) { + + leverageNative( el, "click" ); + } + + // Return non-false to allow normal event-path propagation + return true; }, - // For cross-browser consistency, don't fire native .click() on links + // For cross-browser consistency, suppress native .click() on links + // Also prevent it if we're currently inside a leveraged native-event stack _default: function( event ) { - return nodeName( event.target, "a" ); + var target = event.target; + return rcheckableType.test( target.type ) && + target.click && nodeName( target, "input" ) && + dataPriv.get( target, "click" ) || + nodeName( target, "a" ); } }, @@ -5348,6 +5605,93 @@ jQuery.event = { } }; +// Ensure the presence of an event listener that handles manually-triggered +// synthetic events by interrupting progress until reinvoked in response to +// *native* events that it fires directly, ensuring that state changes have +// already occurred before other listeners are invoked. +function leverageNative( el, type, expectSync ) { + + // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add + if ( !expectSync ) { + if ( dataPriv.get( el, type ) === undefined ) { + jQuery.event.add( el, type, returnTrue ); + } + return; + } + + // Register the controller as a special universal handler for all event namespaces + dataPriv.set( el, type, false ); + jQuery.event.add( el, type, { + namespace: false, + handler: function( event ) { + var notAsync, result, + saved = dataPriv.get( this, type ); + + if ( ( event.isTrigger & 1 ) && this[ type ] ) { + + // Interrupt processing of the outer synthetic .trigger()ed event + // Saved data should be false in such cases, but might be a leftover capture object + // from an async native handler (gh-4350) + if ( !saved.length ) { + + // Store arguments for use when handling the inner native event + // There will always be at least one argument (an event object), so this array + // will not be confused with a leftover capture object. + saved = slice.call( arguments ); + dataPriv.set( this, type, saved ); + + // Trigger the native event and capture its result + // Support: IE <=9 - 11+ + // focus() and blur() are asynchronous + notAsync = expectSync( this, type ); + this[ type ](); + result = dataPriv.get( this, type ); + if ( saved !== result || notAsync ) { + dataPriv.set( this, type, false ); + } else { + result = {}; + } + if ( saved !== result ) { + + // Cancel the outer synthetic event + event.stopImmediatePropagation(); + event.preventDefault(); + return result.value; + } + + // If this is an inner synthetic event for an event with a bubbling surrogate + // (focus or blur), assume that the surrogate already propagated from triggering the + // native event and prevent that from happening again here. + // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the + // bubbling surrogate propagates *after* the non-bubbling base), but that seems + // less bad than duplication. + } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) { + event.stopPropagation(); + } + + // If this is a native event triggered above, everything is now in order + // Fire an inner synthetic event with the original arguments + } else if ( saved.length ) { + + // ...and capture the result + dataPriv.set( this, type, { + value: jQuery.event.trigger( + + // Support: IE <=9 - 11+ + // Extend with the prototype to reset the above stopImmediatePropagation() + jQuery.extend( saved[ 0 ], jQuery.Event.prototype ), + saved.slice( 1 ), + this + ) + } ); + + // Abort handling of the native event + event.stopImmediatePropagation(); + } + } + } ); +} + jQuery.removeEvent = function( elem, type, handle ) { // This "if" is needed for plain objects @@ -5460,6 +5804,7 @@ jQuery.each( { shiftKey: true, view: true, "char": true, + code: true, charCode: true, key: true, keyCode: true, @@ -5506,6 +5851,33 @@ jQuery.each( { } }, jQuery.event.addProp ); +jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) { + jQuery.event.special[ type ] = { + + // Utilize native event if possible so blur/focus sequence is correct + setup: function() { + + // Claim the first handler + // dataPriv.set( this, "focus", ... ) + // dataPriv.set( this, "blur", ... ) + leverageNative( this, type, expectSync ); + + // Return false to allow normal processing in the caller + return false; + }, + trigger: function() { + + // Force setup before trigger + leverageNative( this, type ); + + // Return non-false to allow normal event-path propagation + return true; + }, + + delegateType: delegateType + }; +} ); + // Create mouseenter/leave events using mouseover/out and event-time checks // so that event delegation works in jQuery. // Do the same for pointerenter/pointerleave and pointerover/pointerout @@ -5591,13 +5963,6 @@ jQuery.fn.extend( { var - /* eslint-disable max-len */ - - // See https://github.com/eslint/eslint/issues/3229 - rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi, - - /* eslint-enable */ - // Support: IE <=10 - 11, Edge 12 - 13 only // In IE/Edge using regex groups here causes severe slowdowns. // See https://connect.microsoft.com/IE/feedback/details/1736512/ @@ -5634,7 +5999,7 @@ function restoreScript( elem ) { } function cloneCopyEvent( src, dest ) { - var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events; + var i, l, type, pdataOld, udataOld, udataCur, events; if ( dest.nodeType !== 1 ) { return; @@ -5642,13 +6007,11 @@ function cloneCopyEvent( src, dest ) { // 1. Copy private data: events, handlers, etc. if ( dataPriv.hasData( src ) ) { - pdataOld = dataPriv.access( src ); - pdataCur = dataPriv.set( dest, pdataOld ); + pdataOld = dataPriv.get( src ); events = pdataOld.events; if ( events ) { - delete pdataCur.handle; - pdataCur.events = {}; + dataPriv.remove( dest, "handle events" ); for ( type in events ) { for ( i = 0, l = events[ type ].length; i < l; i++ ) { @@ -5684,7 +6047,7 @@ function fixInput( src, dest ) { function domManip( collection, args, callback, ignored ) { // Flatten any nested arrays - args = concat.apply( [], args ); + args = flat( args ); var fragment, first, scripts, hasScripts, node, doc, i = 0, @@ -5756,11 +6119,13 @@ function domManip( collection, args, callback, ignored ) { if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) { // Optional AJAX dependency, but won't run scripts if not present - if ( jQuery._evalUrl ) { - jQuery._evalUrl( node.src ); + if ( jQuery._evalUrl && !node.noModule ) { + jQuery._evalUrl( node.src, { + nonce: node.nonce || node.getAttribute( "nonce" ) + }, doc ); } } else { - DOMEval( node.textContent.replace( rcleanScript, "" ), doc, node ); + DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc ); } } } @@ -5782,7 +6147,7 @@ function remove( elem, selector, keepData ) { } if ( node.parentNode ) { - if ( keepData && jQuery.contains( node.ownerDocument, node ) ) { + if ( keepData && isAttached( node ) ) { setGlobalEval( getAll( node, "script" ) ); } node.parentNode.removeChild( node ); @@ -5794,13 +6159,13 @@ function remove( elem, selector, keepData ) { jQuery.extend( { htmlPrefilter: function( html ) { - return html.replace( rxhtmlTag, "<$1>" ); + return html; }, clone: function( elem, dataAndEvents, deepDataAndEvents ) { var i, l, srcElements, destElements, clone = elem.cloneNode( true ), - inPage = jQuery.contains( elem.ownerDocument, elem ); + inPage = isAttached( elem ); // Fix IE cloning issues if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && @@ -6056,6 +6421,27 @@ var getStyles = function( elem ) { return view.getComputedStyle( elem ); }; +var swap = function( elem, options, callback ) { + var ret, name, + old = {}; + + // Remember the old values, and insert the new ones + for ( name in options ) { + old[ name ] = elem.style[ name ]; + elem.style[ name ] = options[ name ]; + } + + ret = callback.call( elem ); + + // Revert the old values + for ( name in options ) { + elem.style[ name ] = old[ name ]; + } + + return ret; +}; + + var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" ); @@ -6096,8 +6482,10 @@ var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" ); // Support: IE 9 only // Detect overflow:scroll screwiness (gh-3699) + // Support: Chrome <=64 + // Don't get tricked when zoom affects offsetWidth (gh-4029) div.style.position = "absolute"; - scrollboxSizeVal = div.offsetWidth === 36 || "absolute"; + scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12; documentElement.removeChild( container ); @@ -6111,7 +6499,7 @@ var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" ); } var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal, - reliableMarginLeftVal, + reliableTrDimensionsVal, reliableMarginLeftVal, container = document.createElement( "div" ), div = document.createElement( "div" ); @@ -6146,6 +6534,35 @@ var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" ); scrollboxSize: function() { computeStyleTests(); return scrollboxSizeVal; + }, + + // Support: IE 9 - 11+, Edge 15 - 18+ + // IE/Edge misreport `getComputedStyle` of table rows with width/height + // set in CSS while `offset*` properties report correct values. + // Behavior in IE 9 is more subtle than in newer versions & it passes + // some versions of this test; make sure not to make it pass there! + reliableTrDimensions: function() { + var table, tr, trChild, trStyle; + if ( reliableTrDimensionsVal == null ) { + table = document.createElement( "table" ); + tr = document.createElement( "tr" ); + trChild = document.createElement( "div" ); + + table.style.cssText = "position:absolute;left:-11111px"; + tr.style.height = "1px"; + trChild.style.height = "9px"; + + documentElement + .appendChild( table ) + .appendChild( tr ) + .appendChild( trChild ); + + trStyle = window.getComputedStyle( tr ); + reliableTrDimensionsVal = parseInt( trStyle.height ) > 3; + + documentElement.removeChild( table ); + } + return reliableTrDimensionsVal; } } ); } )(); @@ -6168,7 +6585,7 @@ function curCSS( elem, name, computed ) { if ( computed ) { ret = computed.getPropertyValue( name ) || computed[ name ]; - if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) { + if ( ret === "" && !isAttached( elem ) ) { ret = jQuery.style( elem, name ); } @@ -6224,30 +6641,13 @@ function addGetHookIf( conditionFn, hookFn ) { } -var +var cssPrefixes = [ "Webkit", "Moz", "ms" ], + emptyStyle = document.createElement( "div" ).style, + vendorProps = {}; - // Swappable if display is none or starts with table - // except "table", "table-cell", or "table-caption" - // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display - rdisplayswap = /^(none|table(?!-c[ea]).+)/, - rcustomProp = /^--/, - cssShow = { position: "absolute", visibility: "hidden", display: "block" }, - cssNormalTransform = { - letterSpacing: "0", - fontWeight: "400" - }, - - cssPrefixes = [ "Webkit", "Moz", "ms" ], - emptyStyle = document.createElement( "div" ).style; - -// Return a css property mapped to a potentially vendor prefixed property +// Return a vendor-prefixed property or undefined function vendorPropName( name ) { - // Shortcut for names that are not vendor prefixed - if ( name in emptyStyle ) { - return name; - } - // Check for vendor prefixed names var capName = name[ 0 ].toUpperCase() + name.slice( 1 ), i = cssPrefixes.length; @@ -6260,17 +6660,34 @@ function vendorPropName( name ) { } } -// Return a property mapped along what jQuery.cssProps suggests or to -// a vendor prefixed property. +// Return a potentially-mapped jQuery.cssProps or vendor prefixed property function finalPropName( name ) { - var ret = jQuery.cssProps[ name ]; - if ( !ret ) { - ret = jQuery.cssProps[ name ] = vendorPropName( name ) || name; + var final = jQuery.cssProps[ name ] || vendorProps[ name ]; + + if ( final ) { + return final; } - return ret; + if ( name in emptyStyle ) { + return name; + } + return vendorProps[ name ] = vendorPropName( name ) || name; } -function setPositiveNumber( elem, value, subtract ) { + +var + + // Swappable if display is none or starts with table + // except "table", "table-cell", or "table-caption" + // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display + rdisplayswap = /^(none|table(?!-c[ea]).+)/, + rcustomProp = /^--/, + cssShow = { position: "absolute", visibility: "hidden", display: "block" }, + cssNormalTransform = { + letterSpacing: "0", + fontWeight: "400" + }; + +function setPositiveNumber( _elem, value, subtract ) { // Any relative (+/-) values have already been // normalized at this point @@ -6341,7 +6758,10 @@ function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computed delta - extra - 0.5 - ) ); + + // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter + // Use an explicit zero to avoid NaN (gh-3964) + ) ) || 0; } return delta; @@ -6351,9 +6771,16 @@ function getWidthOrHeight( elem, dimension, extra ) { // Start with computed style var styles = getStyles( elem ), + + // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322). + // Fake content-box until we know it's needed to know the true value. + boxSizingNeeded = !support.boxSizingReliable() || extra, + isBorderBox = boxSizingNeeded && + jQuery.css( elem, "boxSizing", false, styles ) === "border-box", + valueIsBorderBox = isBorderBox, + val = curCSS( elem, dimension, styles ), - isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box", - valueIsBorderBox = isBorderBox; + offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ); // Support: Firefox <=54 // Return a confounding non-pixel value or feign ignorance, as appropriate. @@ -6364,22 +6791,38 @@ function getWidthOrHeight( elem, dimension, extra ) { val = "auto"; } - // Check for style in case a browser which returns unreliable values - // for getComputedStyle silently falls back to the reliable elem.style - valueIsBorderBox = valueIsBorderBox && - ( support.boxSizingReliable() || val === elem.style[ dimension ] ); - // Fall back to offsetWidth/offsetHeight when value is "auto" - // This happens for inline elements with no explicit setting (gh-3571) - // Support: Android <=4.1 - 4.3 only - // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602) - if ( val === "auto" || - !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) { + // Support: IE 9 - 11 only + // Use offsetWidth/offsetHeight for when box sizing is unreliable. + // In those cases, the computed value can be trusted to be border-box. + if ( ( !support.boxSizingReliable() && isBorderBox || - val = elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ]; + // Support: IE 10 - 11+, Edge 15 - 18+ + // IE/Edge misreport `getComputedStyle` of table rows with width/height + // set in CSS while `offset*` properties report correct values. + // Interestingly, in some cases IE 9 doesn't suffer from this issue. + !support.reliableTrDimensions() && nodeName( elem, "tr" ) || - // offsetWidth/offsetHeight provide border-box values - valueIsBorderBox = true; + // Fall back to offsetWidth/offsetHeight when value is "auto" + // This happens for inline elements with no explicit setting (gh-3571) + val === "auto" || + + // Support: Android <=4.1 - 4.3 only + // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602) + !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) && + + // Make sure the element is visible & connected + elem.getClientRects().length ) { + + isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; + + // Where available, offsetWidth/offsetHeight approximate border box dimensions. + // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the + // retrieved value as a content box dimension. + valueIsBorderBox = offsetProp in elem; + if ( valueIsBorderBox ) { + val = elem[ offsetProp ]; + } } // Normalize "" and auto @@ -6425,6 +6868,13 @@ jQuery.extend( { "flexGrow": true, "flexShrink": true, "fontWeight": true, + "gridArea": true, + "gridColumn": true, + "gridColumnEnd": true, + "gridColumnStart": true, + "gridRow": true, + "gridRowEnd": true, + "gridRowStart": true, "lineHeight": true, "opacity": true, "order": true, @@ -6480,7 +6930,9 @@ jQuery.extend( { } // If a number was passed in, add the unit (except for certain CSS properties) - if ( type === "number" ) { + // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append + // "px" to a few hardcoded values. + if ( type === "number" && !isCustomProp ) { value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" ); } @@ -6554,7 +7006,7 @@ jQuery.extend( { } } ); -jQuery.each( [ "height", "width" ], function( i, dimension ) { +jQuery.each( [ "height", "width" ], function( _i, dimension ) { jQuery.cssHooks[ dimension ] = { get: function( elem, computed, extra ) { if ( computed ) { @@ -6580,18 +7032,29 @@ jQuery.each( [ "height", "width" ], function( i, dimension ) { set: function( elem, value, extra ) { var matches, styles = getStyles( elem ), - isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box", - subtract = extra && boxModelAdjustment( - elem, - dimension, - extra, - isBorderBox, - styles - ); + + // Only read styles.position if the test has a chance to fail + // to avoid forcing a reflow. + scrollboxSizeBuggy = !support.scrollboxSize() && + styles.position === "absolute", + + // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991) + boxSizingNeeded = scrollboxSizeBuggy || extra, + isBorderBox = boxSizingNeeded && + jQuery.css( elem, "boxSizing", false, styles ) === "border-box", + subtract = extra ? + boxModelAdjustment( + elem, + dimension, + extra, + isBorderBox, + styles + ) : + 0; // Account for unreliable border-box dimensions by comparing offset* to computed and // faking a content-box to get border and padding (gh-3699) - if ( isBorderBox && support.scrollboxSize() === styles.position ) { + if ( isBorderBox && scrollboxSizeBuggy ) { subtract -= Math.ceil( elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - parseFloat( styles[ dimension ] ) - @@ -6759,9 +7222,9 @@ Tween.propHooks = { // Use .style if available and use plain properties where available. if ( jQuery.fx.step[ tween.prop ] ) { jQuery.fx.step[ tween.prop ]( tween ); - } else if ( tween.elem.nodeType === 1 && - ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || - jQuery.cssHooks[ tween.prop ] ) ) { + } else if ( tween.elem.nodeType === 1 && ( + jQuery.cssHooks[ tween.prop ] || + tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) { jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); } else { tween.elem[ tween.prop ] = tween.now; @@ -7316,7 +7779,7 @@ jQuery.fn.extend( { clearQueue = type; type = undefined; } - if ( clearQueue && type !== false ) { + if ( clearQueue ) { this.queue( type || "fx", [] ); } @@ -7399,7 +7862,7 @@ jQuery.fn.extend( { } } ); -jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) { +jQuery.each( [ "toggle", "show", "hide" ], function( _i, name ) { var cssFn = jQuery.fn[ name ]; jQuery.fn[ name ] = function( speed, easing, callback ) { return speed == null || typeof speed === "boolean" ? @@ -7620,7 +8083,7 @@ boolHook = { } }; -jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) { +jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( _i, name ) { var getter = attrHandle[ name ] || jQuery.find.attr; attrHandle[ name ] = function( elem, name, isXML ) { @@ -8244,7 +8707,9 @@ jQuery.extend( jQuery.event, { special.bindType || type; // jQuery handler - handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] && + handle = ( + dataPriv.get( cur, "events" ) || Object.create( null ) + )[ event.type ] && dataPriv.get( cur, "handle" ); if ( handle ) { handle.apply( cur, data ); @@ -8355,7 +8820,10 @@ if ( !support.focusin ) { jQuery.event.special[ fix ] = { setup: function() { - var doc = this.ownerDocument || this, + + // Handle: regular nodes (via `this.ownerDocument`), window + // (via `this.document`) & document (via `this`). + var doc = this.ownerDocument || this.document || this, attaches = dataPriv.access( doc, fix ); if ( !attaches ) { @@ -8364,7 +8832,7 @@ if ( !support.focusin ) { dataPriv.access( doc, fix, ( attaches || 0 ) + 1 ); }, teardown: function() { - var doc = this.ownerDocument || this, + var doc = this.ownerDocument || this.document || this, attaches = dataPriv.access( doc, fix ) - 1; if ( !attaches ) { @@ -8380,7 +8848,7 @@ if ( !support.focusin ) { } var location = window.location; -var nonce = Date.now(); +var nonce = { guid: Date.now() }; var rquery = ( /\?/ ); @@ -8468,6 +8936,10 @@ jQuery.param = function( a, traditional ) { encodeURIComponent( value == null ? "" : value ); }; + if ( a == null ) { + return ""; + } + // If an array was passed in, assume that it is an array of form elements. if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { @@ -8508,7 +8980,7 @@ jQuery.fn.extend( { rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) && ( this.checked || !rcheckableType.test( type ) ); } ) - .map( function( i, elem ) { + .map( function( _i, elem ) { var val = jQuery( this ).val(); if ( val == null ) { @@ -8970,12 +9442,14 @@ jQuery.extend( { if ( !responseHeaders ) { responseHeaders = {}; while ( ( match = rheaders.exec( responseHeadersString ) ) ) { - responseHeaders[ match[ 1 ].toLowerCase() ] = match[ 2 ]; + responseHeaders[ match[ 1 ].toLowerCase() + " " ] = + ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] ) + .concat( match[ 2 ] ); } } - match = responseHeaders[ key.toLowerCase() ]; + match = responseHeaders[ key.toLowerCase() + " " ]; } - return match == null ? null : match; + return match == null ? null : match.join( ", " ); }, // Raw string @@ -9119,7 +9593,8 @@ jQuery.extend( { // Add or update anti-cache param if needed if ( s.cache === false ) { cacheURL = cacheURL.replace( rantiCache, "$1" ); - uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached; + uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce.guid++ ) + + uncached; } // Put hash and anti-cache on the URL that will be requested (gh-1732) @@ -9252,6 +9727,11 @@ jQuery.extend( { response = ajaxHandleResponses( s, jqXHR, responses ); } + // Use a noop converter for missing script + if ( !isSuccess && jQuery.inArray( "script", s.dataTypes ) > -1 ) { + s.converters[ "text script" ] = function() {}; + } + // Convert no matter what (that way responseXXX fields are always set) response = ajaxConvert( s, response, jqXHR, isSuccess ); @@ -9342,7 +9822,7 @@ jQuery.extend( { } } ); -jQuery.each( [ "get", "post" ], function( i, method ) { +jQuery.each( [ "get", "post" ], function( _i, method ) { jQuery[ method ] = function( url, data, callback, type ) { // Shift arguments if data argument was omitted @@ -9363,8 +9843,17 @@ jQuery.each( [ "get", "post" ], function( i, method ) { }; } ); +jQuery.ajaxPrefilter( function( s ) { + var i; + for ( i in s.headers ) { + if ( i.toLowerCase() === "content-type" ) { + s.contentType = s.headers[ i ] || ""; + } + } +} ); -jQuery._evalUrl = function( url ) { + +jQuery._evalUrl = function( url, options, doc ) { return jQuery.ajax( { url: url, @@ -9374,7 +9863,16 @@ jQuery._evalUrl = function( url ) { cache: true, async: false, global: false, - "throws": true + + // Only evaluate the response if it is successful (gh-4126) + // dataFilter is not invoked for failure responses, so using it instead + // of the default converter is kludgy but it works. + converters: { + "text script": function() {} + }, + dataFilter: function( response ) { + jQuery.globalEval( response, options, doc ); + } } ); }; @@ -9657,24 +10155,21 @@ jQuery.ajaxPrefilter( "script", function( s ) { // Bind script tag hack transport jQuery.ajaxTransport( "script", function( s ) { - // This transport only deals with cross domain requests - if ( s.crossDomain ) { + // This transport only deals with cross domain or forced-by-attrs requests + if ( s.crossDomain || s.scriptAttrs ) { var script, callback; return { send: function( _, complete ) { - script = jQuery( " +{% endblock %} diff --git a/templates/member/club_tables.html b/templates/member/club_tables.html index e937fbe9..139d3abc 100644 --- a/templates/member/club_tables.html +++ b/templates/member/club_tables.html @@ -1,10 +1,23 @@ {% load render_table from django_tables2 %} {% load i18n %} +{% if managers.data %} +
+ + {% render_table managers %} +
+ +
+{% endif %} + {% if member_list.data %}
{% render_table member_list %} @@ -16,7 +29,7 @@ {% if history_list.data %}
diff --git a/templates/member/profile_tables.html b/templates/member/profile_tables.html index 9629ff14..4936cc26 100644 --- a/templates/member/profile_tables.html +++ b/templates/member/profile_tables.html @@ -11,7 +11,7 @@
@@ -22,7 +22,7 @@
+ {% trans "Registrations" %} + + {% endif %} {% endblock %} {% block extrajavascript %} @@ -34,7 +42,7 @@ if (pattern === old_pattern || pattern === "") return; - $("#user_table").load(location.href + "?search=" + pattern.replace(" ", "%20") + " #user_table", init); + $("#user_table").load(location.pathname + "?search=" + pattern.replace(" ", "%20") + " #user_table", init); } searchbar_obj.keyup(function() { diff --git a/templates/note/amount_input.html b/templates/note/amount_input.html index 6ef4a53a..cd8cd201 100644 --- a/templates/note/amount_input.html +++ b/templates/note/amount_input.html @@ -8,4 +8,5 @@
+

\ No newline at end of file diff --git a/templates/note/conso_form.html b/templates/note/conso_form.html index 451d8a27..e6335c6e 100644 --- a/templates/note/conso_form.html +++ b/templates/note/conso_form.html @@ -68,15 +68,15 @@

- {% trans "Most used buttons" %} + {% trans "Highlighted buttons" %}

-
- {% for button in most_used %} +
+ {% for button in highlighted %} {% if button.display %} {% endif %} @@ -86,7 +86,7 @@
{# Regroup buttons under categories #} - {% regroup transaction_templates by category as categories %} + {# {% regroup transaction_templates by category as categories %} #}
{# Tabs for button categories #} @@ -94,8 +94,8 @@
+
+
+ + {% trans "I am the emitter" %} + +
@@ -100,7 +102,8 @@ SPDX-License-Identifier: GPL-2.0-or-later
- + +

@@ -160,7 +163,7 @@ SPDX-License-Identifier: GPL-2.0-or-later TRANSFER_POLYMORPHIC_CTYPE = {{ polymorphic_ctype }}; SPECIAL_TRANSFER_POLYMORPHIC_CTYPE = {{ special_polymorphic_ctype }}; user_id = {{ user.note.pk }}; - username = "{{ user.username }}"; + username = "{{ user.username|escapejs }}"; {% endblock %} diff --git a/templates/note/transactiontemplate_list.html b/templates/note/transactiontemplate_list.html index 280f9faf..793b2278 100644 --- a/templates/note/transactiontemplate_list.html +++ b/templates/note/transactiontemplate_list.html @@ -5,18 +5,7 @@ {% block content %}
-

- {% trans "Search button" %} -

-
-
- -
-

{% trans "New button" %}
@@ -36,66 +25,39 @@ {% endblock %} {% block extrajavascript %} - {% endblock %} diff --git a/templates/permission/all_rights.html b/templates/permission/all_rights.html index 293e3386..9bb6faf5 100644 --- a/templates/permission/all_rights.html +++ b/templates/permission/all_rights.html @@ -15,15 +15,15 @@ {% regroup active_memberships by roles as memberships_per_role %} {% for role in roles %}
  • - {{ role }} {% if role.weirole %}(Pour le WEI){% endif %} + {{ role }} {% if role.weirole %}(Pour le WEI){% endif %} {% if role.for_club %}(Pour le club {{ role.for_club }} uniquement){% endif %} {% if role.clubs %}
    {% trans "Own this role in the clubs" %} {{ role.clubs|join:", " }}
    {% endif %}
      - {% for permission in role.permissions.permissions.all %} -
    • {{ permission }} ({{ permission.type }} {{ permission.model }}{% if permission.permanent %}, {% trans "permanent" %}{% endif %})
    • + {% for permission in role.permissions.all %} +
    • {{ permission }} ({{ permission.get_type_display }} {{ permission.model }}{% if permission.permanent %}, {% trans "permanent" %}{% endif %})
    • {% empty %} {% trans "No associated permission" %} {% endfor %} diff --git a/templates/registration/future_user_list.html b/templates/registration/future_user_list.html index 1e10dcbb..c2c888fd 100644 --- a/templates/registration/future_user_list.html +++ b/templates/registration/future_user_list.html @@ -32,7 +32,7 @@ if (pattern === old_pattern || pattern === "") return; - $("#user_table").load(location.href + "?search=" + pattern.replace(" ", "%20") + " #user_table", init); + $("#user_table").load(location.pathname + "?search=" + pattern.replace(" ", "%20") + " #user_table", init); $(".table-row").click(function() { window.document.location = $(this).data("href"); diff --git a/templates/registration/login.html b/templates/registration/login.html index 32e54e00..e624631f 100644 --- a/templates/registration/login.html +++ b/templates/registration/login.html @@ -10,12 +10,22 @@ SPDX-License-Identifier: GPL-2.0-or-later {% block content %} {% if user.is_authenticated %}

      - {% blocktrans trimmed %} + {% blocktrans trimmed with username=request.user.username %} You are authenticated as {{ username }}, but are not authorized to - access this page. Would you like to login to a different account? + access this page. Would you like to login to a different account, + or with a higher permission mask? {% endblocktrans %}

      {% endif %} + + {% if request.resolver_match.view_name == 'admin:login' %} +
      + {% blocktrans trimmed %} + You must be logged with a staff account with the higher mask to access Django Admin. + {% endblocktrans %} +
      + {% endif %} +
      {% csrf_token %} {{ form | crispy }} diff --git a/templates/treasury/remittance_list.html b/templates/treasury/remittance_list.html index 916c47d8..be8e806e 100644 --- a/templates/treasury/remittance_list.html +++ b/templates/treasury/remittance_list.html @@ -55,5 +55,11 @@

      {% trans "Closed remittances" %}

      - {% render_table closed_remittances %} + {% if closed_remittances.data %} + {% render_table closed_remittances %} + {% else %} +
      + {% trans "There is no closed remittance yet." %} +
      + {% endif %} {% endblock %} diff --git a/templates/wei/bus_tables.html b/templates/wei/bus_tables.html index 50eccf6a..f0df7e44 100644 --- a/templates/wei/bus_tables.html +++ b/templates/wei/bus_tables.html @@ -22,7 +22,7 @@ {% if teams.data %}
      @@ -35,7 +35,7 @@ {% if memberships.data %}
      diff --git a/templates/wei/busteam_tables.html b/templates/wei/busteam_tables.html index 3135158f..c3e53bf7 100644 --- a/templates/wei/busteam_tables.html +++ b/templates/wei/busteam_tables.html @@ -39,7 +39,7 @@ {% if memberships.data or True %}
      diff --git a/templates/wei/weiclub_list.html b/templates/wei/weiclub_list.html index 0ed8e0ac..2739e5bf 100644 --- a/templates/wei/weiclub_list.html +++ b/templates/wei/weiclub_list.html @@ -4,12 +4,11 @@ {% block content %}
      -

      - {% trans "search WEI" %} -

      -
      - {% trans "Create WEI" %} + {% if can_create_wei %} +
      + {% trans "Create WEI" %} + {% endif %}
      diff --git a/templates/wei/weiclub_tables.html b/templates/wei/weiclub_tables.html index d5a8ff01..b97f5736 100644 --- a/templates/wei/weiclub_tables.html +++ b/templates/wei/weiclub_tables.html @@ -75,7 +75,7 @@ {% if buses.data %}
      @@ -88,7 +88,7 @@ {% if member_list.data %}
      @@ -101,7 +101,7 @@ {% if history_list.data %}
      @@ -116,7 +116,7 @@ {% if pre_registrations.data %}
      diff --git a/templates/wei/weilist_sample.tex b/templates/wei/weilist_sample.tex index a2ff0755..09d3f6be 100644 --- a/templates/wei/weilist_sample.tex +++ b/templates/wei/weilist_sample.tex @@ -5,6 +5,7 @@ \usepackage[french]{babel} \usepackage[margin=1.5cm]{geometry} +\usepackage{lmodern} \usepackage{ltablex} \usepackage{tabularx} @@ -13,11 +14,11 @@ \huge{Liste des inscrits \og {{ wei.name }} \fg{}} {% if bus %} -\LARGE{Bus {{ bus.name }}} +\LARGE{Bus {{ bus.name|safe }}} {% if team %} -\Large{Équipe {{ team.name }}} +\Large{Équipe {{ team.name|safe }}} {% endif %} {% endif %} \end{center} diff --git a/templates/wei/weimembership_form.html b/templates/wei/weimembership_form.html index 995b6c1a..d33c3de7 100644 --- a/templates/wei/weimembership_form.html +++ b/templates/wei/weimembership_form.html @@ -59,6 +59,12 @@
      {% trans 'gender'|capfirst %}
      {{ registration.gender }}
      +
      {% trans 'clothing cut'|capfirst %}
      +
      {{ registration.clothing_cut }}
      + +
      {% trans 'clothing size'|capfirst %}
      +
      {{ registration.clothing_size }}
      +
      {% trans 'birth date'|capfirst %}
      {{ registration.birth_date }}
      diff --git a/tox.ini b/tox.ini index 48bc3286..eef83e31 100644 --- a/tox.ini +++ b/tox.ini @@ -2,6 +2,7 @@ envlist = py36-django22 py37-django22 + py38-django22 linters skipsdist = True