# Path: micro_blog/models.py
# class Post(models.Model):
#     STATUS_CHOICE = (
#                     ('D', 'Draft'),
#                     ('P', 'Published'),
#                     ('T', 'Rejected'),
#                     ('R', 'Review'),
#                     )
# 
#     title = models.CharField(max_length=100)
#     created_on = models.DateTimeField(auto_now_add=True)
#     updated_on = models.DateField(auto_now=True)
#     user = models.ForeignKey(settings.AUTH_USER_MODEL)
#     content = models.TextField()
#     excerpt = models.CharField(max_length=500, default="")
#     category = models.ForeignKey(Category, related_name='blog_posts')
#     tags = models.ManyToManyField(Tags, related_name='rel_posts', blank=True)
#     status = models.CharField(max_length=2, choices=STATUS_CHOICE, blank=True)
#     published_on = models.DateField(blank=True, null=True)
#     meta_description = models.TextField(max_length=500, default='')
#     old_slugs = models.TextField()
# 
#     def __unicode__(self):
#         return self.title
# 
#     def create_blog_slug(self, slugs):
#         for each_slug in list(set(slugs)):
#             blog_slugs = self.slugs.filter(slug=each_slug)
#             if not blog_slugs:
#                 actual_slug = get_blog_slug(each_slug)
#                 Post_Slugs.objects.create(
#                     blog=self, slug=actual_slug, is_active=False
#                 )
# 
#     def check_and_activate_slug(self):
#         # Check whether active slug is their for blog-post or not
#         blog_slugs = self.slugs.all().order_by("id")
#         if not blog_slugs.filter(is_active=True):
#             active_slug = blog_slugs.last()
#             active_slug.is_active = True
#             active_slug.save()
# 
#     @property
#     def slug(self):
#         blog_slug = self.slugs.filter(is_active=True).first()
#         if blog_slug:
#             return str(blog_slug.slug)
#         return ""
# 
#     @property
#     def author(self):
#         return self.user.first_name + ' ' + self.user.last_name
# 
#     def save(self, *args, **kwargs):
#         if self.status == 'P':
#             if not self.published_on:
#                 self.published_on = datetime.datetime.today()
#         super(Post, self).save(*args, **kwargs)
# 
#     @property
#     def get_url(self):
#         return settings.SITE_BLOG_URL + self.slug
# 
#     def is_editable_by(self, user):
#         if self.user == user or user.is_superuser:
#             return True
#         return False
# 
#     def is_deletable_by(self, user):
#         if self.user == user or user.is_superuser:
#             return True
#         return False
# 
#     def get_content(self):
#         table = html.fromstring(self.content)
#         content = ''
#         for item in table:
#             if item.text:
#                 content += item.text.strip()
#         return content[:350]
# 
# class Country(models.Model):
#     name = models.CharField(max_length=50, unique=True)
#     code = models.CharField(max_length=50)
#     slug = models.CharField(max_length=50, unique=True)
# 
#     def __str__(self):
#         return self.name


from django import template
from micro_blog.models import Post, Country
from django.core.urlresolvers import reverse
from django.conf import settings
import datetime
import re
import datetime
    return value.__class__.__name__


@register.filter
def get_object_list_class(object_list, class_name):
    for c in object_list:
        if c.__class__.__name__ == class_name:
            return True
    return False


@register.filter
def get_slugs(value):
    if value:
        return value.split(',')
    return ''


@register.simple_tag
def get_countries():
    return Country.objects.filter().order_by('id')


@register.filter
def get_value(value):
    return str(value)


@register.filter
def get_country_name(value):

# Path: micro_blog/models.py
# class Post(models.Model):
#     STATUS_CHOICE = (
#                     ('D', 'Draft'),
#                     ('P', 'Published'),
#                     ('T', 'Rejected'),
#                     ('R', 'Review'),
#                     )
# 
#     title = models.CharField(max_length=100)
#     created_on = models.DateTimeField(auto_now_add=True)
#     updated_on = models.DateField(auto_now=True)
#     user = models.ForeignKey(settings.AUTH_USER_MODEL)
#     content = models.TextField()
#     excerpt = models.CharField(max_length=500, default="")
#     category = models.ForeignKey(Category, related_name='blog_posts')
#     tags = models.ManyToManyField(Tags, related_name='rel_posts', blank=True)
#     status = models.CharField(max_length=2, choices=STATUS_CHOICE, blank=True)
#     published_on = models.DateField(blank=True, null=True)
#     meta_description = models.TextField(max_length=500, default='')
#     old_slugs = models.TextField()
# 
#     def __unicode__(self):
#         return self.title
# 
#     def create_blog_slug(self, slugs):
#         for each_slug in list(set(slugs)):
#             blog_slugs = self.slugs.filter(slug=each_slug)
#             if not blog_slugs:
#                 actual_slug = get_blog_slug(each_slug)
#                 Post_Slugs.objects.create(
#                     blog=self, slug=actual_slug, is_active=False
#                 )
# 
#     def check_and_activate_slug(self):
#         # Check whether active slug is their for blog-post or not
#         blog_slugs = self.slugs.all().order_by("id")
#         if not blog_slugs.filter(is_active=True):
#             active_slug = blog_slugs.last()
#             active_slug.is_active = True
#             active_slug.save()
# 
#     @property
#     def slug(self):
#         blog_slug = self.slugs.filter(is_active=True).first()
#         if blog_slug:
#             return str(blog_slug.slug)
#         return ""
# 
#     @property
#     def author(self):
#         return self.user.first_name + ' ' + self.user.last_name
# 
#     def save(self, *args, **kwargs):
#         if self.status == 'P':
#             if not self.published_on:
#                 self.published_on = datetime.datetime.today()
#         super(Post, self).save(*args, **kwargs)
# 
#     @property
#     def get_url(self):
#         return settings.SITE_BLOG_URL + self.slug
# 
#     def is_editable_by(self, user):
#         if self.user == user or user.is_superuser:
#             return True
#         return False
# 
#     def is_deletable_by(self, user):
#         if self.user == user or user.is_superuser:
#             return True
#         return False
# 
#     def get_content(self):
#         table = html.fromstring(self.content)
#         content = ''
#         for item in table:
#             if item.text:
#                 content += item.text.strip()
#         return content[:350]
# 
# class Country(models.Model):
#     name = models.CharField(max_length=50, unique=True)
#     code = models.CharField(max_length=50)
#     slug = models.CharField(max_length=50, unique=True)
# 
#     def __str__(self):
#         return self.name


# Path: micro_blog/templatetags/blog_tags.py
from django import template
from micro_blog.models import Post, Country
from django.core.urlresolvers import reverse
from django.conf import settings
import datetime
import re
import datetime

    return value.__class__.__name__


@register.filter
def get_object_list_class(object_list, class_name):
    for c in object_list:
        if c.__class__.__name__ == class_name:
            return True
    return False


@register.filter
def get_slugs(value):
    if value:
        return value.split(',')
    return ''


@register.simple_tag
def get_countries():
    return Country.objects.filter().order_by('id')


@register.filter
def get_value(value):
    return str(value)


@register.filter
def get_country_name(value):

    return Country.objects.filter(code=value).first().name