# 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
        return self.gender == self.GENDER_FEMALE

    @property
    def is_readcomment(self):
        return self.remote.get("is_rc", True)

    @property
    def is_readonly(self):
        return self.remote.get("is_readonly", True)

    @property
    def has_badge(self):
        badges = self.remote.get("badges")
        if not badges:
            return False
        for badge in badges:
            # Временный хак, пока разрабы Хабра не пофиксят свой API:
            if isinstance(badge, str):
                badge = badges[badge]
            if badge.get("id") == self.BADGE_ID:
                return True
        return False

    @property
    def can_participate(self):
        invited = not self.is_readonly and not self.is_readcomment
        good_guy = self.is_oldfag or self.has_badge
        return not self.is_banned and invited and (good_guy or
            self.karma >= settings.CLUBADM_KARMA_LIMIT)


# 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

        return self.gender == self.GENDER_FEMALE

    @property
    def is_readcomment(self):
        return self.remote.get("is_rc", True)

    @property
    def is_readonly(self):
        return self.remote.get("is_readonly", True)

    @property
    def has_badge(self):
        badges = self.remote.get("badges")
        if not badges:
            return False
        for badge in badges:
            # Временный хак, пока разрабы Хабра не пофиксят свой API:
            if isinstance(badge, str):
                badge = badges[badge]
            if badge.get("id") == self.BADGE_ID:
                return True
        return False

    @property
    def can_participate(self):
        invited = not self.is_readonly and not self.is_readcomment
        good_guy = self.is_oldfag or self.has_badge
        return not self.is_banned and invited and (good_guy or
            self.karma >= settings.CLUBADM_KARMA_LIMIT)


    def send_notification(self, title, template_name, context=None):