# Path: Blog/posts/models.py
# class Post(models.Model):
#     user = models.ForeignKey(settings.AUTH_USER_MODEL, default=1)
#     title = models.CharField(max_length=120)
#     slug = models.SlugField(unique=True, null=True)
#     image = models.ImageField(null=True, blank=True,
#                               upload_to=upload_location,
#                               width_field="width_field",
#                               height_field="height_field")
#     width_field = models.IntegerField(default=0)
#     height_field = models.IntegerField(default=0)
#     content = models.TextField()
#     draft = models.BooleanField(default=False)
#     published = models.DateField(auto_now=False, auto_now_add=False)
#     updated = models.DateTimeField(auto_now=True, auto_now_add=False)  # auto_now triggered when model.save() called
#     timestamp = models.DateTimeField(auto_now=False, auto_now_add=True)  # auto_now_add triggered when object first created
#     num_chinese = models.IntegerField(default=0)
#     num_english = models.IntegerField(default=0)
#     objects = ActivePostManager()
# 
#     def __str__(self):  # __unicode__ for py2
#         return self.title
# 
#     def get_absolute_url(self):
#         return reverse("posts:detail", kwargs={"slug": self.slug})
# 
#     def get_api_url(self):
#         return reverse("posts-api:detail", kwargs={"slug": self.slug})
# 
#     def get_markdown(self):
#         content = self.content
#         return mark_safe(markdown(content))
# 
#     @property
#     def comments(self):
#         from comments.models import Comment
#         instance = self
#         return Comment.objects.filter_by_instance(instance)
# 
#     @property
#     def get_content_type(self):
#         instance = self
#         content_type = ContentType.objects.get_for_model(instance.__class__)
#         return content_type
# 
#     class Meta:
#         ordering= ['-published', '-updated']


from django.contrib import admin
from .models import Post
# Register your models here.

class PostModelAdmin(admin.ModelAdmin):
    class Meta:
        model = Post

    list_display = ['title', 'updated', 'timestamp']
    list_display_links = ['updated']
    list_filter = ['updated', 'timestamp']
    search_fields = ['title', 'content']
    list_editable = ['title']


# Path: Blog/posts/models.py
# class Post(models.Model):
#     user = models.ForeignKey(settings.AUTH_USER_MODEL, default=1)
#     title = models.CharField(max_length=120)
#     slug = models.SlugField(unique=True, null=True)
#     image = models.ImageField(null=True, blank=True,
#                               upload_to=upload_location,
#                               width_field="width_field",
#                               height_field="height_field")
#     width_field = models.IntegerField(default=0)
#     height_field = models.IntegerField(default=0)
#     content = models.TextField()
#     draft = models.BooleanField(default=False)
#     published = models.DateField(auto_now=False, auto_now_add=False)
#     updated = models.DateTimeField(auto_now=True, auto_now_add=False)  # auto_now triggered when model.save() called
#     timestamp = models.DateTimeField(auto_now=False, auto_now_add=True)  # auto_now_add triggered when object first created
#     num_chinese = models.IntegerField(default=0)
#     num_english = models.IntegerField(default=0)
#     objects = ActivePostManager()
# 
#     def __str__(self):  # __unicode__ for py2
#         return self.title
# 
#     def get_absolute_url(self):
#         return reverse("posts:detail", kwargs={"slug": self.slug})
# 
#     def get_api_url(self):
#         return reverse("posts-api:detail", kwargs={"slug": self.slug})
# 
#     def get_markdown(self):
#         content = self.content
#         return mark_safe(markdown(content))
# 
#     @property
#     def comments(self):
#         from comments.models import Comment
#         instance = self
#         return Comment.objects.filter_by_instance(instance)
# 
#     @property
#     def get_content_type(self):
#         instance = self
#         content_type = ContentType.objects.get_for_model(instance.__class__)
#         return content_type
# 
#     class Meta:
#         ordering= ['-published', '-updated']


# Path: Blog/posts/admin.py
from django.contrib import admin
from .models import Post

# Register your models here.

class PostModelAdmin(admin.ModelAdmin):
    class Meta:
        model = Post

    list_display = ['title', 'updated', 'timestamp']
    list_display_links = ['updated']
    list_filter = ['updated', 'timestamp']
    search_fields = ['title', 'content']
    list_editable = ['title']


admin.site.register(Post, PostModelAdmin)