# Path: herring/puzzles/models.py
# class Round(models.Model,JSONMixin):
#     # shell model for defining rounds
#     number = models.IntegerField(default=1)
#     name = models.CharField(max_length=200)
#     hunt_url = models.CharField(max_length=1000, default='', **optional)
# 
#     def __str__(self):
#         return 'R' + str(self.number)
# 
#     class Meta:
#         ordering = ['number', 'id']
#     class Json:
#         include_fields = ['id', 'name', 'number', 'puzzle_set', 'hunt_url']
# 
# class Puzzle(models.Model,JSONMixin):
#     # class for all puzzles, including metas
#     parent = models.ForeignKey(Round)
#     name = models.CharField(max_length=200)
#     slug = AutoSlugField(
#         populate_from=puzzle_to_slug,
#         unique=True,
#         db_index=True
#     )
#     number = models.IntegerField(**optional)
#     answer = models.CharField(max_length=200, default='', **optional)
#     note = models.CharField(max_length=200, default='', **optional)
#     tags = models.CharField(max_length=200, default='', **optional)
#     is_meta = models.BooleanField(default=False)
#     url = models.CharField(max_length=1000, default='', **optional)
#     hunt_url = models.CharField(max_length=1000, default='', **optional)
# 
#     tracker = FieldTracker()
# 
#     class Meta:
#         ordering = ['parent', '-is_meta', 'number', 'id']
# 
#     class Json:
#         include_fields = ['id', 'name', 'number', 'answer', 'note', 'tags', 'is_meta', 'url', 'hunt_url', 'slug']
# 
#     def identifier(self):
#         child_type = 'P'
#         if self.is_meta:
#             child_type = 'M'
#         num = str(self.number) if self.number is not None else 'x'
#         return str(self.parent) + child_type + num
#     
#     def __str__(self):
#         return '#%s %s' % (self.slug, self.name)
# 
#     def is_answered(self):
#         return bool(self.answer)
# 
# class UserProfile(models.Model):
#     user = models.OneToOneField(
#             settings.AUTH_USER_MODEL,
#             on_delete=models.CASCADE,
#             related_name='profile',
#     )
#     avatar_url = models.CharField(max_length=200)
# 
#     def __str__(self):
#         return "profile for " + self.user.__str__()


from django.contrib import admin
from .models import Round, Puzzle, UserProfile



class PuzzleInline(admin.TabularInline):
    model = Puzzle
    extra = 1
    exclude = ('answer', 'note', 'tags', 'url')


class RoundAdmin(admin.ModelAdmin):
    inlines = [PuzzleInline]
    list_display = ('__str__', 'name',)
    search_fields = ['name']


class PuzzleAdmin(admin.ModelAdmin):
    exclude = ('answer', 'note', 'tags', 'url')
    search_fields = ['name']

class UserProfileAdmin(admin.ModelAdmin):
    pass

admin.site.register(Round, RoundAdmin)

# Path: herring/puzzles/models.py
# class Round(models.Model,JSONMixin):
#     # shell model for defining rounds
#     number = models.IntegerField(default=1)
#     name = models.CharField(max_length=200)
#     hunt_url = models.CharField(max_length=1000, default='', **optional)
# 
#     def __str__(self):
#         return 'R' + str(self.number)
# 
#     class Meta:
#         ordering = ['number', 'id']
#     class Json:
#         include_fields = ['id', 'name', 'number', 'puzzle_set', 'hunt_url']
# 
# class Puzzle(models.Model,JSONMixin):
#     # class for all puzzles, including metas
#     parent = models.ForeignKey(Round)
#     name = models.CharField(max_length=200)
#     slug = AutoSlugField(
#         populate_from=puzzle_to_slug,
#         unique=True,
#         db_index=True
#     )
#     number = models.IntegerField(**optional)
#     answer = models.CharField(max_length=200, default='', **optional)
#     note = models.CharField(max_length=200, default='', **optional)
#     tags = models.CharField(max_length=200, default='', **optional)
#     is_meta = models.BooleanField(default=False)
#     url = models.CharField(max_length=1000, default='', **optional)
#     hunt_url = models.CharField(max_length=1000, default='', **optional)
# 
#     tracker = FieldTracker()
# 
#     class Meta:
#         ordering = ['parent', '-is_meta', 'number', 'id']
# 
#     class Json:
#         include_fields = ['id', 'name', 'number', 'answer', 'note', 'tags', 'is_meta', 'url', 'hunt_url', 'slug']
# 
#     def identifier(self):
#         child_type = 'P'
#         if self.is_meta:
#             child_type = 'M'
#         num = str(self.number) if self.number is not None else 'x'
#         return str(self.parent) + child_type + num
#     
#     def __str__(self):
#         return '#%s %s' % (self.slug, self.name)
# 
#     def is_answered(self):
#         return bool(self.answer)
# 
# class UserProfile(models.Model):
#     user = models.OneToOneField(
#             settings.AUTH_USER_MODEL,
#             on_delete=models.CASCADE,
#             related_name='profile',
#     )
#     avatar_url = models.CharField(max_length=200)
# 
#     def __str__(self):
#         return "profile for " + self.user.__str__()


# Path: herring/puzzles/admin.py
from django.contrib import admin
from .models import Round, Puzzle, UserProfile




class PuzzleInline(admin.TabularInline):
    model = Puzzle
    extra = 1
    exclude = ('answer', 'note', 'tags', 'url')


class RoundAdmin(admin.ModelAdmin):
    inlines = [PuzzleInline]
    list_display = ('__str__', 'name',)
    search_fields = ['name']


class PuzzleAdmin(admin.ModelAdmin):
    exclude = ('answer', 'note', 'tags', 'url')
    search_fields = ['name']

class UserProfileAdmin(admin.ModelAdmin):
    pass

admin.site.register(Round, RoundAdmin)

admin.site.register(Puzzle, PuzzleAdmin)