from __future__ import unicode_literals

from django.db import models


class Room(models.Model):
    """
    A room for people to chat in.
    """

    # Room title
    title = models.CharField(max_length=255)

    # If only "staff" users are allowed (is_staff on django's User)
    staff_only = models.BooleanField(default=False)

    def __str__(self):
        return self.title

    @property
    def group_name(self):
        """
        Returns the Channels Group name that sockets should subscribe to to get sent
        messages as they are generated.
        """
        return "room-%s" % self.id


class Channel(models.Model):
    name = models.CharField(max_length=255)
    teleboy_id = models.IntegerField()

    def __str__(self):
        return self.name


class Logo(models.Model):
    status = models.BooleanField()
    timestamp = models.IntegerField(default=0)
    channel = models.ForeignKey(Channel, on_delete=models.CASCADE)
