# Path: clubadm/tasks.py
# @shared_task
# def send_notification(access_token, title, text):
#     url = "%s/tracker" % settings.TMAUTH_ENDPOINT_URL
#     headers = {
#         "client": settings.TMAUTH_CLIENT,
#         "token": access_token
#     }
#     data = {
#         "title": title,
#         "text": text
#     }
#     response = requests.put(url, headers=headers, data=data)
#     response.raise_for_status()


import datetime
import logging
from django.conf import settings
from django.contrib import auth
from django.core.cache import cache
from django.db import models, connection
from django.http import Http404
from django.template.loader import render_to_string
from django.utils import timezone
from django.utils.functional import cached_property
from clubadm.tasks import send_notification
    class Meta:
        ordering = ["year"]
        get_latest_by = "year"
        verbose_name = "сезон"
        verbose_name_plural = "сезоны"

    def __str__(self):
        return "АДМ-%d" % self.year

    @property
    def cache_key(self):
        return "season:%d" % self.pk

    def save(self, *args, **kwargs):
        super(Season, self).save(*args, **kwargs)
        cache.set(self.cache_key, self, timeout=None)

    def delete(self, *args, **kwargs):
        super(Season, self).delete(*args, **kwargs)
        cache.delete(self.cache_key)

    def get_absolute_url(self):
        return '/%d/' % self.year

    @property
    def is_closed(self):
        return timezone.now().date() > self.ship_by

    @property
    def is_participatable(self):

# Path: clubadm/tasks.py
# @shared_task
# def send_notification(access_token, title, text):
#     url = "%s/tracker" % settings.TMAUTH_ENDPOINT_URL
#     headers = {
#         "client": settings.TMAUTH_CLIENT,
#         "token": access_token
#     }
#     data = {
#         "title": title,
#         "text": text
#     }
#     response = requests.put(url, headers=headers, data=data)
#     response.raise_for_status()


# Path: clubadm/models.py
import datetime
import logging
from django.conf import settings
from django.contrib import auth
from django.core.cache import cache
from django.db import models, connection
from django.http import Http404
from django.template.loader import render_to_string
from django.utils import timezone
from django.utils.functional import cached_property
from clubadm.tasks import send_notification

    class Meta:
        ordering = ["year"]
        get_latest_by = "year"
        verbose_name = "сезон"
        verbose_name_plural = "сезоны"

    def __str__(self):
        return "АДМ-%d" % self.year

    @property
    def cache_key(self):
        return "season:%d" % self.pk

    def save(self, *args, **kwargs):
        super(Season, self).save(*args, **kwargs)
        cache.set(self.cache_key, self, timeout=None)

    def delete(self, *args, **kwargs):
        super(Season, self).delete(*args, **kwargs)
        cache.delete(self.cache_key)

    def get_absolute_url(self):
        return '/%d/' % self.year

    @property
    def is_closed(self):
        return timezone.now().date() > self.ship_by

    @property
    def is_participatable(self):

        today = timezone.now().date()