X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/967eed676fc83d15b26149047f353ac61faa8217..48a8d1d73adefae7f0c58015494ce956d7cd70df:/src/club/models.py?ds=sidebyside diff --git a/src/club/models.py b/src/club/models.py index 17771742c..ede1a8d30 100644 --- a/src/club/models.py +++ b/src/club/models.py @@ -88,7 +88,6 @@ class Schedule(models.Model): def get_payment_method(self): return method_by_slug[self.method] - def is_expired(self): return self.expires_at is not None and self.expires_at < now() @@ -125,6 +124,16 @@ class Membership(models.Model): def __str__(self): return u'tow. ' + str(self.user) + @classmethod + def is_active_for(self, user): + if user.is_anonymous: + return False + return Schedule.objects.filter( + models.Q(expires_at=None) | models.Q(expires_at__lt=now()), + membership__user=user, + is_active=True, + ).exists() + class ReminderEmail(models.Model): days_before = models.SmallIntegerField(_('days before'))