# Path: hackday/common.py
# def common_env():
#     env = {
#         'nav_pages': get_nav_pages(),
#     }
#     return env
# 
# Path: hackday/wiki/models.py
# class Page(models.Model):
#     title = models.CharField('title of page', max_length=255)
#     path = models.CharField('path of page', max_length=255, db_index=True,
#             unique=True)
#     content = models.TextField('page content')
#     status = models.CharField(max_length=1, choices=STATUS.CHOICES)
#     format = models.CharField(max_length=5, choices=FORMAT.CHOICES)
#     navigable = models.BooleanField('in site navigation')
#     order = models.IntegerField(null=True, blank=True)
# 
#     attachments = models.ManyToManyField(Attachment,
#             related_name="%(app_label)s_%(class)s_attachments",
#             blank=True)
#     images = models.ManyToManyField(ImageAttachment,
#             related_name="%(app_label)s_%(class)s_images",
#             blank=True)
#     links = models.ManyToManyField(Link,
#             related_name="%(app_label)s_%(class)s_links",
#             blank=True)
# 
#     author = models.ForeignKey(User)
# 
#     create_date = models.DateTimeField('date created', auto_now_add=True,
#             editable=False)
#     mod_date = models.DateTimeField('date modified', auto_now=True,
#             editable=False)
#     pub_date = models.DateTimeField('date published', null=True, blank=True)
# 
#     def get_absolute_url(self):
#         return reverse('wiki-page', args=[self.path])
# 
#     def __unicode__(self):
#         return self.path
# 
# class STATUS(object):
#     DRAFT = 'D'
#     PUBLISHED = 'P'
#     DELETED = 'X'
# 
#     CHOICES = (
#         (DRAFT, 'Draft'),
#         (PUBLISHED, 'Published'),
#         (DELETED, 'Deleted'),
#     )


from hackday.common import common_env
from hackday.wiki.models import Page, STATUS
from django.http import HttpResponse
from django.shortcuts import get_object_or_404, render
from django.template import Context, loader


def page(request, path):
    if request.user.has_perms('wiki.add_page'):
        page = get_object_or_404(Page, path=path)
    else:

# Path: hackday/common.py
# def common_env():
#     env = {
#         'nav_pages': get_nav_pages(),
#     }
#     return env
# 
# Path: hackday/wiki/models.py
# class Page(models.Model):
#     title = models.CharField('title of page', max_length=255)
#     path = models.CharField('path of page', max_length=255, db_index=True,
#             unique=True)
#     content = models.TextField('page content')
#     status = models.CharField(max_length=1, choices=STATUS.CHOICES)
#     format = models.CharField(max_length=5, choices=FORMAT.CHOICES)
#     navigable = models.BooleanField('in site navigation')
#     order = models.IntegerField(null=True, blank=True)
# 
#     attachments = models.ManyToManyField(Attachment,
#             related_name="%(app_label)s_%(class)s_attachments",
#             blank=True)
#     images = models.ManyToManyField(ImageAttachment,
#             related_name="%(app_label)s_%(class)s_images",
#             blank=True)
#     links = models.ManyToManyField(Link,
#             related_name="%(app_label)s_%(class)s_links",
#             blank=True)
# 
#     author = models.ForeignKey(User)
# 
#     create_date = models.DateTimeField('date created', auto_now_add=True,
#             editable=False)
#     mod_date = models.DateTimeField('date modified', auto_now=True,
#             editable=False)
#     pub_date = models.DateTimeField('date published', null=True, blank=True)
# 
#     def get_absolute_url(self):
#         return reverse('wiki-page', args=[self.path])
# 
#     def __unicode__(self):
#         return self.path
# 
# class STATUS(object):
#     DRAFT = 'D'
#     PUBLISHED = 'P'
#     DELETED = 'X'
# 
#     CHOICES = (
#         (DRAFT, 'Draft'),
#         (PUBLISHED, 'Published'),
#         (DELETED, 'Deleted'),
#     )


# Path: hackday/wiki/views.py
from hackday.common import common_env
from hackday.wiki.models import Page, STATUS
from django.http import HttpResponse
from django.shortcuts import get_object_or_404, render
from django.template import Context, loader



def page(request, path):
    if request.user.has_perms('wiki.add_page'):
        page = get_object_or_404(Page, path=path)
    else:

        page = get_object_or_404(Page, path=path, status=STATUS.PUBLISHED)