# Path: src/presenters/models.py
# class Presenter(models.Model):
#     game = models.ForeignKey('Game', default=get_default_game)
#     platform = models.ForeignKey('Platform')
#     id_in_platform = models.IntegerField(default=0)
#     tag = models.ManyToManyField('Tag', blank=True)
#     nickname = models.CharField(max_length=50)
#     introduce = models.TextField()
#     room_url = models.CharField(max_length=255, blank=True)
#     gender = models.CharField(max_length=1, choices=GENDER_CHOICES, default='M')
#     avatar_url = models.CharField(max_length=255, blank=True)
# 
#     join_date = models.DateField(auto_now_add=True)
# 
#     invalid = models.BooleanField(default=True)
# 
#     def __unicode__(self):
#         return self.nickname
# 
# class PresenterDetail(models.Model):
#     presenter = models.OneToOneField('Presenter')
# 
#     showing = models.BooleanField(default=False)
#     room_title = models.CharField(max_length=255, blank=True)
#     audience_count = models.IntegerField(default=0)
# 
#     start = models.DateTimeField(null=True, blank=True)
#     last_show_end = models.DateTimeField(null=True, blank=True)
# 
#     def save(self, *args, **kwargs):
#         if self.showing and not self.start:     # 开始直播
#             self.start = timezone.now()
#             self.last_show_end = None
#         elif not self.showing and self.start:   # 结束直播
#             self.auto_create_showhistory()
#             self.last_show_end = timezone.now()
#             self.start = None
# 
#         super(PresenterDetail, self).save()
# 
#     # 结束直播时记录本次直播信息
#     def auto_create_showhistory(self):
#         history = ShowHistory(presenter=self.presenter, start=self.start, stop=timezone.now())
#         history.duration = (history.stop - history.start).total_seconds() / 60
#         history.save()
# 
#     def __unicode__(self):
#         return self.presenter.nickname
# 
# class Platform(models.Model):
#     name = models.CharField(max_length=50)
#     url = models.CharField(max_length=50)
#     intro = models.TextField()
#     logo = models.ImageField(upload_to='platform_logos', blank=True)
# 
#     login_param = models.TextField()
#     fetch_status = models.BooleanField(default=False)
# 
#     def __unicode__(self):
#         return self.name
# 
# class Tag(models.Model):
#     name = models.CharField(max_length=50)
# 
#     def __unicode__(self):
#         return self.name


from django.contrib import admin
from .models import Presenter, PresenterDetail, Platform, Tag

admin.site.register(Presenter)
admin.site.register(PresenterDetail)
admin.site.register(Platform)

# Path: src/presenters/models.py
# class Presenter(models.Model):
#     game = models.ForeignKey('Game', default=get_default_game)
#     platform = models.ForeignKey('Platform')
#     id_in_platform = models.IntegerField(default=0)
#     tag = models.ManyToManyField('Tag', blank=True)
#     nickname = models.CharField(max_length=50)
#     introduce = models.TextField()
#     room_url = models.CharField(max_length=255, blank=True)
#     gender = models.CharField(max_length=1, choices=GENDER_CHOICES, default='M')
#     avatar_url = models.CharField(max_length=255, blank=True)
# 
#     join_date = models.DateField(auto_now_add=True)
# 
#     invalid = models.BooleanField(default=True)
# 
#     def __unicode__(self):
#         return self.nickname
# 
# class PresenterDetail(models.Model):
#     presenter = models.OneToOneField('Presenter')
# 
#     showing = models.BooleanField(default=False)
#     room_title = models.CharField(max_length=255, blank=True)
#     audience_count = models.IntegerField(default=0)
# 
#     start = models.DateTimeField(null=True, blank=True)
#     last_show_end = models.DateTimeField(null=True, blank=True)
# 
#     def save(self, *args, **kwargs):
#         if self.showing and not self.start:     # 开始直播
#             self.start = timezone.now()
#             self.last_show_end = None
#         elif not self.showing and self.start:   # 结束直播
#             self.auto_create_showhistory()
#             self.last_show_end = timezone.now()
#             self.start = None
# 
#         super(PresenterDetail, self).save()
# 
#     # 结束直播时记录本次直播信息
#     def auto_create_showhistory(self):
#         history = ShowHistory(presenter=self.presenter, start=self.start, stop=timezone.now())
#         history.duration = (history.stop - history.start).total_seconds() / 60
#         history.save()
# 
#     def __unicode__(self):
#         return self.presenter.nickname
# 
# class Platform(models.Model):
#     name = models.CharField(max_length=50)
#     url = models.CharField(max_length=50)
#     intro = models.TextField()
#     logo = models.ImageField(upload_to='platform_logos', blank=True)
# 
#     login_param = models.TextField()
#     fetch_status = models.BooleanField(default=False)
# 
#     def __unicode__(self):
#         return self.name
# 
# class Tag(models.Model):
#     name = models.CharField(max_length=50)
# 
#     def __unicode__(self):
#         return self.name


# Path: src/presenters/admin.py
from django.contrib import admin
from .models import Presenter, PresenterDetail, Platform, Tag


admin.site.register(Presenter)
admin.site.register(PresenterDetail)
admin.site.register(Platform)

admin.site.register(Tag)