Fix some activity errors

This commit is contained in:
Yohann D'ANELLO 2020-08-06 14:11:55 +02:00
parent 434a393f3b
commit de5e0c958e
4 changed files with 9 additions and 7 deletions

View File

@ -1,9 +1,11 @@
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
from datetime import timedelta, datetime
from datetime import timedelta
from django import forms
from django.contrib.contenttypes.models import ContentType
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from member.models import Club
from note.models import NoteUser, Note
@ -41,7 +43,7 @@ class GuestForm(forms.ModelForm):
def clean(self):
cleaned_data = super().clean()
if self.activity.date_start > datetime.now():
if self.activity.date_start > timezone.now():
self.add_error("inviter", _("You can't invite someone once the activity is started."))
if not self.activity.valid:

View File

@ -1,7 +1,7 @@
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
from datetime import timedelta, datetime
from datetime import timedelta
from threading import Thread
from django.conf import settings
@ -236,7 +236,7 @@ class Guest(models.Model):
one_year = timedelta(days=365)
if not force_insert:
if self.activity.date_start > datetime.now():
if self.activity.date_start > timezone.now():
raise ValidationError(_("You can't invite someone once the activity is started."))
if not self.activity.valid:

View File

@ -125,7 +125,7 @@ class ActivityEntryView(LoginRequiredMixin, TemplateView):
.filter(PermissionBackend.filter_queryset(self.request.user, Guest, "view"))\
.order_by('last_name', 'first_name').distinct()
if "search" in self.request.GET:
if "search" in self.request.GET and self.request.GET["search"]:
pattern = self.request.GET["search"]
if pattern[0] != "^":
pattern = "^" + pattern

View File

@ -484,7 +484,7 @@ class ClubAddMemberView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView):
additional_fee_renewal = 0
while c.parent_club is not None:
c = c.parent_club
if not Membership.objects.filter(
if c.membership_start and not Membership.objects.filter(
club=c,
user=user,
date_start__gte=c.membership_start,
@ -562,7 +562,7 @@ class ClubAddMemberView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView):
fee = 0
c = club
while c is not None:
while c is not None and c.membership_start:
if not Membership.objects.filter(
club=c,
user=user,