# Path: bot/plugins/stats/models.py
# class Download(models.Model):
#     title = models.CharField(_('title'), max_length=255)
#     file = models.FileField(upload_to='downloads/%Y/%m/')
#     created = models.DateTimeField(auto_now_add=True)
# 
#     class Meta:
#         verbose_name = _('download')
#         verbose_name_plural = _('downloads')
# 
#     def __str__(self):
#         return self.title
# 
# class GameSession(models.Model):
#     member = models.ForeignKey('users.Member', on_delete=models.PROTECT)
#     server = models.BigIntegerField(_("server"))
#     game = models.ForeignKey('games.Game', on_delete=models.CASCADE)
#     start = models.DateTimeField(_('start'))
#     stop = models.DateTimeField(_('stop'), null=True, blank=True)
#     duration = models.DurationField(null=True, blank=True)
# 
#     objects = GameSessionQuerySet.as_manager()
# 
#     class Meta:
#         verbose_name = _('game session')
#         verbose_name_plural = _('game sessions')
# 
#     def __str__(self):
#         return self.game.name
# 
#     def save(self, *args, **kwargs):
#         if self.stop and not self.duration:
#             self.duration = self.stop - self.start
#         super().save(*args, **kwargs)
# 
#     def stop_session(self):
#         self.stop = timezone.now()
#         self.save()
# 
# class LoggedMessage(models.Model):
# 
#     discord_id = models.BigIntegerField(unique=True)
#     server = models.BigIntegerField(_("server"))
# 
#     member = models.ForeignKey('users.Member', related_name='messages_authored', on_delete=models.PROTECT)
#     member_username = models.CharField(max_length=255)  # this can change, only the member.discord_id is a constant
# 
#     channel = models.ForeignKey('channels.Channel', on_delete=models.PROTECT)
# 
#     content = models.TextField()
#     num_lines = models.PositiveSmallIntegerField(default=1)
#     timestamp = models.DateTimeField(auto_now_add=True)
#     edited_timestamp = models.DateTimeField(null=True, blank=True)
# 
#     mentions = models.ManyToManyField('users.Member', related_name='messages_mentioned_in', blank=True)
# 
#     class Meta:
#         verbose_name = _('message')
#         verbose_name_plural = _('messages')
#         ordering = ['-timestamp']
# 
#     def __str__(self):
#         return self.discord_id


from django.contrib import admin
from .models import Download, GameSession, LoggedMessage



@admin.register(LoggedMessage)
class LoggedMessageAdmin(admin.ModelAdmin):
    list_display = ['member_username', 'num_lines']
    list_filter = ['channel', 'member_username', 'server']
    ordering = ['-timestamp']

# Path: bot/plugins/stats/models.py
# class Download(models.Model):
#     title = models.CharField(_('title'), max_length=255)
#     file = models.FileField(upload_to='downloads/%Y/%m/')
#     created = models.DateTimeField(auto_now_add=True)
# 
#     class Meta:
#         verbose_name = _('download')
#         verbose_name_plural = _('downloads')
# 
#     def __str__(self):
#         return self.title
# 
# class GameSession(models.Model):
#     member = models.ForeignKey('users.Member', on_delete=models.PROTECT)
#     server = models.BigIntegerField(_("server"))
#     game = models.ForeignKey('games.Game', on_delete=models.CASCADE)
#     start = models.DateTimeField(_('start'))
#     stop = models.DateTimeField(_('stop'), null=True, blank=True)
#     duration = models.DurationField(null=True, blank=True)
# 
#     objects = GameSessionQuerySet.as_manager()
# 
#     class Meta:
#         verbose_name = _('game session')
#         verbose_name_plural = _('game sessions')
# 
#     def __str__(self):
#         return self.game.name
# 
#     def save(self, *args, **kwargs):
#         if self.stop and not self.duration:
#             self.duration = self.stop - self.start
#         super().save(*args, **kwargs)
# 
#     def stop_session(self):
#         self.stop = timezone.now()
#         self.save()
# 
# class LoggedMessage(models.Model):
# 
#     discord_id = models.BigIntegerField(unique=True)
#     server = models.BigIntegerField(_("server"))
# 
#     member = models.ForeignKey('users.Member', related_name='messages_authored', on_delete=models.PROTECT)
#     member_username = models.CharField(max_length=255)  # this can change, only the member.discord_id is a constant
# 
#     channel = models.ForeignKey('channels.Channel', on_delete=models.PROTECT)
# 
#     content = models.TextField()
#     num_lines = models.PositiveSmallIntegerField(default=1)
#     timestamp = models.DateTimeField(auto_now_add=True)
#     edited_timestamp = models.DateTimeField(null=True, blank=True)
# 
#     mentions = models.ManyToManyField('users.Member', related_name='messages_mentioned_in', blank=True)
# 
#     class Meta:
#         verbose_name = _('message')
#         verbose_name_plural = _('messages')
#         ordering = ['-timestamp']
# 
#     def __str__(self):
#         return self.discord_id


# Path: bot/plugins/stats/admin.py
from django.contrib import admin
from .models import Download, GameSession, LoggedMessage




@admin.register(LoggedMessage)
class LoggedMessageAdmin(admin.ModelAdmin):
    list_display = ['member_username', 'num_lines']
    list_filter = ['channel', 'member_username', 'server']
    ordering = ['-timestamp']

    readonly_fields = [field.name for field in LoggedMessage._meta.get_fields()]