import logging

from django.conf import settings
from django.contrib.auth.models import User
from django.db import models
from django.utils.translation import gettext_lazy
from django_celery_beat.models import PeriodicTask
from rest_framework.authtoken.models import Token
from solo.models import SingletonModel

from users.constants import PRETTY_TIMEZONE_CHOICES

_log = logging.getLogger(__name__)


class UserInfo(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True)
    comment = models.CharField(max_length=200, blank=True, null=True, verbose_name=gettext_lazy('Comment'))
    timezone = models.CharField(max_length=255,
                                choices=PRETTY_TIMEZONE_CHOICES,
                                default=settings.DEFAULT_CURRENT_TIMEZONE,
                                verbose_name=gettext_lazy('Timezone'))
    expire_date = models.DateField(blank=True,
                                   null=True,
                                   verbose_name=gettext_lazy('Expiry date'),
                                   help_text=gettext_lazy('User will not be able to log in after the date expires'))

    modified = models.DateTimeField(blank=True, null=True, auto_now=True,
                                    verbose_name=gettext_lazy('Modified datetime'),
                                    help_text=gettext_lazy("Date and time of the last change"))

    last_seen = models.DateTimeField(gettext_lazy('Last seen date'), blank=True, null=True)

    channel_name = models.CharField(max_length=255,
                                    blank=True,
                                    help_text='Channel that uniquely identifies the user',
                                    default='')
