# Path: shiori/bookmark/models.py
# class Bookmark(BaseObject):
#     """ Bookmark model """
#     url = models.URLField()
#     title = models.CharField(max_length=255)
#     category = models.ForeignKey(Category)
#     tags = models.ManyToManyField(Tag, through='BookmarkTag')
#     registered_datetime = models.DateTimeField(auto_now=True,
#                                                auto_now_add=True)
#     description = models.TextField(blank=True)
#     owner = models.ForeignKey(User)
#     is_hide = models.BooleanField(default=False)
# 
#     class Meta(object):
#         """ meta class """
#         db_table = 'bookmark'
#         unique_together = ('url', 'owner')
# 
#     def __unicode__(self):
#         return self.title
# 
#     def get_absolute_url(self):
#         """ bookmark permalink path """
#         return "/shiori/b/%s" % self.id
# 
# class Category(BaseObject):
#     """ Category model """
#     category = models.CharField(max_length=255, unique=True)
# 
#     class Meta(object):
#         """ meta class """
#         db_table = 'category'
# 
#     def __unicode__(self):
#         return self.category
# 
# class Tag(BaseObject):
#     """ Tag model """
#     tag = models.CharField(max_length=255, unique=True)
# 
#     class Meta(object):
#         """ meta class """
#         db_table = 'tag'
# 
#     def __unicode__(self):
#         return self.tag
# 
# class BookmarkTag(models.Model):
#     """ BookmarkTag model """
#     id = models.AutoField(primary_key=True)
#     bookmark = models.ForeignKey(Bookmark,
#                                  db_column='bookmark_id',
#                                  to_field='id')
#     tag = models.ForeignKey(Tag,
#                             db_column='tag_id',
#                             to_field='id')
# 
#     class Meta(object):
#         """ meta class """
#         db_table = 'bookmark_tag'
#         unique_together = ('bookmark', 'tag')
# 
# class FeedSubscription(BaseObject):
#     """ FeedSubsscription model """
#     url = models.URLField()
#     name = models.CharField(max_length=255, editable=False)
#     owner = models.ForeignKey(User)
#     default_category = models.ForeignKey(Category)
# 
#     class Meta(object):
#         """ meta class """
#         db_table = 'feed_subscription'
#         unique_together = ('url', 'owner')
# 
#     def __unicode__(self):
#         return self.url
# 
# class CrawlingHistory(BaseObject):
#     """ Crawling History model """
#     feed = models.ForeignKey(FeedSubscription)
#     result = jsonfield.JSONField()
#     update_datetime = models.DateTimeField(auto_now=True,
#                                            auto_now_add=True)
# 
#     class Meta(object):
#         """ meta class """
#         db_table = 'crawling_history'
# 
#     def __unicode__(self):
#         return self.id


from django.contrib import admin
from shiori.bookmark.models import (Bookmark,
                                    Category,
                                    Tag,
                                    BookmarkTag,
                                    FeedSubscription,
                                    CrawlingHistory)
                    'owner', 'is_hide')


class BookmarkTagAdmin(admin.ModelAdmin):
    """ Customizing list display for BookmarkTag model """
    list_display = ('bookmark', 'tag')


class FeedSubscriptionAdmin(admin.ModelAdmin):
    """ Customizing list display for FeedSubscription model """
    list_display = ('name', 'owner', 'default_category')


class CrawlingHistoryAdmin(admin.ModelAdmin):
    """ Customizing list display for CrawlingHistory model """
    list_display = ('get_name', 'update_datetime', 'result')

    def get_name(self, obj):
        """ get feed name.
        Argument:
            obj: CrawlingHistory object
        Return:
            obj.feed.name
        """
        return obj.feed.name


admin.site.register(Bookmark, BookmarkAdmin)
admin.site.register(Category)
admin.site.register(Tag)

# Path: shiori/bookmark/models.py
# class Bookmark(BaseObject):
#     """ Bookmark model """
#     url = models.URLField()
#     title = models.CharField(max_length=255)
#     category = models.ForeignKey(Category)
#     tags = models.ManyToManyField(Tag, through='BookmarkTag')
#     registered_datetime = models.DateTimeField(auto_now=True,
#                                                auto_now_add=True)
#     description = models.TextField(blank=True)
#     owner = models.ForeignKey(User)
#     is_hide = models.BooleanField(default=False)
# 
#     class Meta(object):
#         """ meta class """
#         db_table = 'bookmark'
#         unique_together = ('url', 'owner')
# 
#     def __unicode__(self):
#         return self.title
# 
#     def get_absolute_url(self):
#         """ bookmark permalink path """
#         return "/shiori/b/%s" % self.id
# 
# class Category(BaseObject):
#     """ Category model """
#     category = models.CharField(max_length=255, unique=True)
# 
#     class Meta(object):
#         """ meta class """
#         db_table = 'category'
# 
#     def __unicode__(self):
#         return self.category
# 
# class Tag(BaseObject):
#     """ Tag model """
#     tag = models.CharField(max_length=255, unique=True)
# 
#     class Meta(object):
#         """ meta class """
#         db_table = 'tag'
# 
#     def __unicode__(self):
#         return self.tag
# 
# class BookmarkTag(models.Model):
#     """ BookmarkTag model """
#     id = models.AutoField(primary_key=True)
#     bookmark = models.ForeignKey(Bookmark,
#                                  db_column='bookmark_id',
#                                  to_field='id')
#     tag = models.ForeignKey(Tag,
#                             db_column='tag_id',
#                             to_field='id')
# 
#     class Meta(object):
#         """ meta class """
#         db_table = 'bookmark_tag'
#         unique_together = ('bookmark', 'tag')
# 
# class FeedSubscription(BaseObject):
#     """ FeedSubsscription model """
#     url = models.URLField()
#     name = models.CharField(max_length=255, editable=False)
#     owner = models.ForeignKey(User)
#     default_category = models.ForeignKey(Category)
# 
#     class Meta(object):
#         """ meta class """
#         db_table = 'feed_subscription'
#         unique_together = ('url', 'owner')
# 
#     def __unicode__(self):
#         return self.url
# 
# class CrawlingHistory(BaseObject):
#     """ Crawling History model """
#     feed = models.ForeignKey(FeedSubscription)
#     result = jsonfield.JSONField()
#     update_datetime = models.DateTimeField(auto_now=True,
#                                            auto_now_add=True)
# 
#     class Meta(object):
#         """ meta class """
#         db_table = 'crawling_history'
# 
#     def __unicode__(self):
#         return self.id


# Path: shiori/bookmark/admin.py
from django.contrib import admin
from shiori.bookmark.models import (Bookmark,
                                    Category,
                                    Tag,
                                    BookmarkTag,
                                    FeedSubscription,
                                    CrawlingHistory)

                    'owner', 'is_hide')


class BookmarkTagAdmin(admin.ModelAdmin):
    """ Customizing list display for BookmarkTag model """
    list_display = ('bookmark', 'tag')


class FeedSubscriptionAdmin(admin.ModelAdmin):
    """ Customizing list display for FeedSubscription model """
    list_display = ('name', 'owner', 'default_category')


class CrawlingHistoryAdmin(admin.ModelAdmin):
    """ Customizing list display for CrawlingHistory model """
    list_display = ('get_name', 'update_datetime', 'result')

    def get_name(self, obj):
        """ get feed name.
        Argument:
            obj: CrawlingHistory object
        Return:
            obj.feed.name
        """
        return obj.feed.name


admin.site.register(Bookmark, BookmarkAdmin)
admin.site.register(Category)
admin.site.register(Tag)

admin.site.register(BookmarkTag, BookmarkTagAdmin)