# Path: gitcms/tagging/models.py
# class Tag(models.Model):
#     name = models.CharField(u'tag', max_length=255)
#     slug = models.SlugField(u'slug')
#     def __unicode__(self):
#         return self.slug
#     class Meta:
#         verbose_name_plural = tr(u'Tags')
# 
# Path: gitcms/blog/models.py
# class BlogPost(models.Model):
#     title = models.CharField(u'title', max_length=255)
#     slug = models.CharField(u'slug', max_length=255)
#     timestamp = models.DateTimeField(u'timestamp')
#     tags = models.ManyToManyField(Tag)
#     content = models.TextField(u'content')
#     status = models.CharField(u'status', max_length=255)
#     author = models.CharField(u'author', max_length=255)
#     keywords = models.CharField(u'keywords', max_length=255)
#     description = models.CharField(u'description', max_length=255)
# 
#     def __unicode__(self):
#         return '%s (%s)' % (self.slug, self.title)
# 
#     @models.permalink
#     def get_absolute_url(self):
#         return ('blog-post', [self.timestamp.year, self.timestamp.month, self.slug])


from gitcms.tagging.models import Tag
from django.template import RequestContext
from django.shortcuts import get_object_or_404, render_to_response
from gitcms.blog.models import BlogPost


def bytag(request, tag):
    tag = get_object_or_404(Tag, slug=tag)
    posts = BlogPost.objects.exclude(status='draft').filter(tags=tag).order_by('-timestamp')
    return render_to_response(
                'blog/tag_list.html',
                RequestContext(request, {
                    'tag' : tag,
                    'posts' : posts,
                }))

def post(request, year, month, slug):

# Path: gitcms/tagging/models.py
# class Tag(models.Model):
#     name = models.CharField(u'tag', max_length=255)
#     slug = models.SlugField(u'slug')
#     def __unicode__(self):
#         return self.slug
#     class Meta:
#         verbose_name_plural = tr(u'Tags')
# 
# Path: gitcms/blog/models.py
# class BlogPost(models.Model):
#     title = models.CharField(u'title', max_length=255)
#     slug = models.CharField(u'slug', max_length=255)
#     timestamp = models.DateTimeField(u'timestamp')
#     tags = models.ManyToManyField(Tag)
#     content = models.TextField(u'content')
#     status = models.CharField(u'status', max_length=255)
#     author = models.CharField(u'author', max_length=255)
#     keywords = models.CharField(u'keywords', max_length=255)
#     description = models.CharField(u'description', max_length=255)
# 
#     def __unicode__(self):
#         return '%s (%s)' % (self.slug, self.title)
# 
#     @models.permalink
#     def get_absolute_url(self):
#         return ('blog-post', [self.timestamp.year, self.timestamp.month, self.slug])


# Path: gitcms/blog/views.py
from gitcms.tagging.models import Tag
from django.template import RequestContext
from django.shortcuts import get_object_or_404, render_to_response
from gitcms.blog.models import BlogPost



def bytag(request, tag):
    tag = get_object_or_404(Tag, slug=tag)
    posts = BlogPost.objects.exclude(status='draft').filter(tags=tag).order_by('-timestamp')
    return render_to_response(
                'blog/tag_list.html',
                RequestContext(request, {
                    'tag' : tag,
                    'posts' : posts,
                }))

def post(request, year, month, slug):

    post = get_object_or_404(BlogPost, slug=slug)