# Path: staticgen/conf.py
# class StaticgenConf(AppConf):
#     class Meta:
#     SITEMAP_URL = None
#     FAIL_SILENTLY = True
#     MULTITHREAD = True
#     BUCKET_NAME = getattr(settings, 'AWS_STORAGE_BUCKET_NAME', '')
#     STATIC_SITE_DOMAIN = None
# 
# Path: staticgen/models.py
# class LogEntry(models.Model):
#     site = models.ForeignKey(Site, verbose_name=_('Site'))
#     page = models.ForeignKey(Page, blank=True, null=True, on_delete=models.CASCADE)
#     change_message = models.TextField(_('change message'))
#     action_time = models.DateTimeField(_('action time'), auto_now=True)
# 
#     objects = LogEntryManager()
# 
#     class Meta:
#         verbose_name = _('log entry')
#         verbose_name_plural = _('log entries')
#         ordering = ('-action_time',)
# 
#     def __str__(self):
#         return self.change_message
# 
# class Page(models.Model):
#     PUBLISHER_STATE_DEFAULT = 0
#     PUBLISHER_STATE_CHANGED = 1
#     PUBLISHER_STATE_PUBLISHED = 2
#     PUBLISHER_STATE_ERROR = 3
#     PUBLISHER_STATE_DELETE = 4
# 
#     PUBLISHER_STATES = (
#         (PUBLISHER_STATE_DEFAULT, _('Pending')),
#         (PUBLISHER_STATE_CHANGED, _('Changed')),
#         (PUBLISHER_STATE_PUBLISHED, _('Published')),
#         (PUBLISHER_STATE_ERROR, _('Error')),
#         (PUBLISHER_STATE_DELETE, _('Deleted'))
#     )
# 
#     site = models.ForeignKey(Site, verbose_name=_('Site'))
#     path = models.CharField(_('URL'), max_length=255)
#     publisher_state = models.SmallIntegerField(
#         _('State'), choices=PUBLISHER_STATES, default=PUBLISHER_STATE_DEFAULT,
#         editable=False, db_index=True)
#     updated_at = models.DateTimeField(auto_now=True)
#     objects = PageManager()
# 
#     class Meta:
#         verbose_name = _('page')
#         verbose_name_plural = _('pages')
#         ordering = ('path', )
#         unique_together = ('site', 'path')
# 
#     def __str__(self):
#         return self.path
# 
#     @property
#     def has_changed(self):
#         return self.publisher_state == self.PUBLISHER_STATE_CHANGED
# 
# Path: staticgen/staticgen_pool.py
# class StaticgenPool(object):
#     def __init__(self):
#     def log_error(self, message):
#     def register(self, cls):
#     def autodiscover(self):
#     def get_urls(self):
# 
# Path: staticgen/tasks.py
# @shared_task
# def publish_pending():
#     message = _('Received task to publish all pending pages.')
#     log_action(message)
# 
#     start_time = time.time()
# 
#     publisher = StaticgenPublisher()
#     publisher.publish(pending=True)
# 
#     elapsed_time = time.time() - start_time
#     message = _('Published all pending pages successfully, '
#                 'in {elapsed_time:.2f} seconds.').format(elapsed_time=elapsed_time)
#     log_action(message)
# 
# @shared_task
# def publish_pages():
#     message = _('Received task to publish/update all registered pages.')
#     logger.info(force_text(message))
#     LogEntry.objects.log_action(message)
# 
#     start_time = time.time()
# 
#     publisher = StaticgenPublisher()
#     publisher.publish(sync=True)
# 
#     elapsed_time = time.time() - start_time
#     message = _('Published or updated all registered pages successfully, '
#                 'in {elapsed_time:.2f} seconds.').format(elapsed_time=elapsed_time)
#     logger.info(message)
# 
# @shared_task()
# def sync_pages():
#     message = _('Received task to sync all registered pages.')
#     log_action(message)
# 
#     start_time = time.time()
# 
#     Page.objects.sync()
# 
#     elapsed_time = time.time() - start_time
#     message = _('Synced all registered pages successfully, '
#                 'in {elapsed_time:.2f} seconds.').format(elapsed_time=elapsed_time)
#     log_action(message)
# 
# @shared_task
# def publish_changed():
#     message = _('Received task to publish all pages marked as changed.')
#     log_action(message)
# 
#     start_time = time.time()
# 
#     publisher = StaticgenPublisher()
#     publisher.publish(changed=True)
# 
#     elapsed_time = time.time() - start_time
#     message = _('Published all pages marked as changed successfully, '
#                 'in {elapsed_time:.2f} seconds.').format(elapsed_time=elapsed_time)
#     log_action(message)


from django.conf.urls import patterns, url
from django.contrib import admin, messages
from django.contrib.admin.templatetags.admin_urls import add_preserved_filters
from django.contrib.admin.utils import model_ngettext, unquote
from django.core.exceptions import PermissionDenied
from django.core.urlresolvers import reverse
from django.http import Http404, HttpResponseRedirect, HttpResponseBadRequest
from django.template.response import TemplateResponse
from django.utils.encoding import force_text
from django.utils.html import escape
from django.utils.text import capfirst
from django.utils.translation import ugettext_lazy as _
from .conf import settings
from .models import LogEntry, Page
from .staticgen_pool import staticgen_pool
from .tasks import publish_pending, publish_pages, sync_pages, publish_changed
# -*- coding: utf-8 -*-

from __future__ import unicode_literals



staticgen_pool.autodiscover()  # Piggyback off admin.autodiscover() to discover Staticgen views


class PageAdmin(admin.ModelAdmin):
    list_display = ('path', 'publisher_state', 'updated_at', )

# Path: staticgen/conf.py
# class StaticgenConf(AppConf):
#     class Meta:
#     SITEMAP_URL = None
#     FAIL_SILENTLY = True
#     MULTITHREAD = True
#     BUCKET_NAME = getattr(settings, 'AWS_STORAGE_BUCKET_NAME', '')
#     STATIC_SITE_DOMAIN = None
# 
# Path: staticgen/models.py
# class LogEntry(models.Model):
#     site = models.ForeignKey(Site, verbose_name=_('Site'))
#     page = models.ForeignKey(Page, blank=True, null=True, on_delete=models.CASCADE)
#     change_message = models.TextField(_('change message'))
#     action_time = models.DateTimeField(_('action time'), auto_now=True)
# 
#     objects = LogEntryManager()
# 
#     class Meta:
#         verbose_name = _('log entry')
#         verbose_name_plural = _('log entries')
#         ordering = ('-action_time',)
# 
#     def __str__(self):
#         return self.change_message
# 
# class Page(models.Model):
#     PUBLISHER_STATE_DEFAULT = 0
#     PUBLISHER_STATE_CHANGED = 1
#     PUBLISHER_STATE_PUBLISHED = 2
#     PUBLISHER_STATE_ERROR = 3
#     PUBLISHER_STATE_DELETE = 4
# 
#     PUBLISHER_STATES = (
#         (PUBLISHER_STATE_DEFAULT, _('Pending')),
#         (PUBLISHER_STATE_CHANGED, _('Changed')),
#         (PUBLISHER_STATE_PUBLISHED, _('Published')),
#         (PUBLISHER_STATE_ERROR, _('Error')),
#         (PUBLISHER_STATE_DELETE, _('Deleted'))
#     )
# 
#     site = models.ForeignKey(Site, verbose_name=_('Site'))
#     path = models.CharField(_('URL'), max_length=255)
#     publisher_state = models.SmallIntegerField(
#         _('State'), choices=PUBLISHER_STATES, default=PUBLISHER_STATE_DEFAULT,
#         editable=False, db_index=True)
#     updated_at = models.DateTimeField(auto_now=True)
#     objects = PageManager()
# 
#     class Meta:
#         verbose_name = _('page')
#         verbose_name_plural = _('pages')
#         ordering = ('path', )
#         unique_together = ('site', 'path')
# 
#     def __str__(self):
#         return self.path
# 
#     @property
#     def has_changed(self):
#         return self.publisher_state == self.PUBLISHER_STATE_CHANGED
# 
# Path: staticgen/staticgen_pool.py
# class StaticgenPool(object):
#     def __init__(self):
#     def log_error(self, message):
#     def register(self, cls):
#     def autodiscover(self):
#     def get_urls(self):
# 
# Path: staticgen/tasks.py
# @shared_task
# def publish_pending():
#     message = _('Received task to publish all pending pages.')
#     log_action(message)
# 
#     start_time = time.time()
# 
#     publisher = StaticgenPublisher()
#     publisher.publish(pending=True)
# 
#     elapsed_time = time.time() - start_time
#     message = _('Published all pending pages successfully, '
#                 'in {elapsed_time:.2f} seconds.').format(elapsed_time=elapsed_time)
#     log_action(message)
# 
# @shared_task
# def publish_pages():
#     message = _('Received task to publish/update all registered pages.')
#     logger.info(force_text(message))
#     LogEntry.objects.log_action(message)
# 
#     start_time = time.time()
# 
#     publisher = StaticgenPublisher()
#     publisher.publish(sync=True)
# 
#     elapsed_time = time.time() - start_time
#     message = _('Published or updated all registered pages successfully, '
#                 'in {elapsed_time:.2f} seconds.').format(elapsed_time=elapsed_time)
#     logger.info(message)
# 
# @shared_task()
# def sync_pages():
#     message = _('Received task to sync all registered pages.')
#     log_action(message)
# 
#     start_time = time.time()
# 
#     Page.objects.sync()
# 
#     elapsed_time = time.time() - start_time
#     message = _('Synced all registered pages successfully, '
#                 'in {elapsed_time:.2f} seconds.').format(elapsed_time=elapsed_time)
#     log_action(message)
# 
# @shared_task
# def publish_changed():
#     message = _('Received task to publish all pages marked as changed.')
#     log_action(message)
# 
#     start_time = time.time()
# 
#     publisher = StaticgenPublisher()
#     publisher.publish(changed=True)
# 
#     elapsed_time = time.time() - start_time
#     message = _('Published all pages marked as changed successfully, '
#                 'in {elapsed_time:.2f} seconds.').format(elapsed_time=elapsed_time)
#     log_action(message)


# Path: staticgen/admin.py
from django.conf.urls import patterns, url
from django.contrib import admin, messages
from django.contrib.admin.templatetags.admin_urls import add_preserved_filters
from django.contrib.admin.utils import model_ngettext, unquote
from django.core.exceptions import PermissionDenied
from django.core.urlresolvers import reverse
from django.http import Http404, HttpResponseRedirect, HttpResponseBadRequest
from django.template.response import TemplateResponse
from django.utils.encoding import force_text
from django.utils.html import escape
from django.utils.text import capfirst
from django.utils.translation import ugettext_lazy as _
from .conf import settings
from .models import LogEntry, Page
from .staticgen_pool import staticgen_pool
from .tasks import publish_pending, publish_pages, sync_pages, publish_changed

# -*- coding: utf-8 -*-

from __future__ import unicode_literals



staticgen_pool.autodiscover()  # Piggyback off admin.autodiscover() to discover Staticgen views


class PageAdmin(admin.ModelAdmin):
    list_display = ('path', 'publisher_state', 'updated_at', )

    actions = ('make_dirty', )