Initial commit of the backup/restore app

This commit is contained in:
Roberto Rosario
2012-08-10 13:51:33 -04:00
parent 82eb31e4ec
commit fd3eed6bd1
10 changed files with 100 additions and 0 deletions

9
apps/backups/__init__.py Normal file
View File

@@ -0,0 +1,9 @@
from __future__ import absolute_import
from project_tools.api import register_tool
from navigation.api import bind_links
from .links import backup_tool_link, restore_tool_link
register_tool(backup_tool_link)
register_tool(restore_tool_link)

42
apps/backups/api.py Normal file
View File

@@ -0,0 +1,42 @@
from django.utils.translation import ugettext_lazy as _
class ModuleBackup(object):
_registry = {}
STATE_BACKING_UP = 'backing_up'
STATE_RESTORING = 'restoring'
STATE_IDLE = 'idle'
STATE_CHOICES = (
(STATE_BACKING_UP, _(u'backing up')),
(STATE_RESTORING, _(u'restoring')),
(STATE_IDLE, _(u'idle')),
)
@classmethod
def get(cls, name):
return cls._registry[name]
@classmethod
def get_all(cls):
return cls._registry.values()
def __init__(self, name, label):
self.label = label
self.name = name
self.state = self.__class__.STATE_IDLE
self.__class__._registry[name] = self
def backup(self, storage_module=None):
self.state = self.__class__.STATE_BACKING_UP
# call storage_module
self.state = self.__class__.STATE_IDLE
def restore(self, storage_module=None):
self.state = self.__class__.STATE_RESTORING
# call storage_module
self.state = self.__class__.STATE_IDLE
def __unicode__(self):
return unicode(self.label)

10
apps/backups/links.py Normal file
View File

@@ -0,0 +1,10 @@
from __future__ import absolute_import
from django.utils.translation import ugettext_lazy as _
from navigation.api import Link
#from .permissions import
backup_tool_link = Link(text=_(u'backup'), view='backup_view', icon='cd_burn.png')#, permissions=[])
restore_tool_link = Link(text=_(u'restore'), view='restore_view', icon='cd_eject.png')#, permissions=[])

3
apps/backups/models.py Normal file
View File

@@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

5
apps/backups/urls.py Normal file
View File

@@ -0,0 +1,5 @@
from django.conf.urls.defaults import patterns, url
urlpatterns = patterns('backups.views',
url(r'^backup/$', 'backup_view', (), 'backup_view'),
)

29
apps/backups/views.py Normal file
View File

@@ -0,0 +1,29 @@
from __future__ import absolute_import
from django.utils.translation import ugettext_lazy as _
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.contrib import messages
from django.core.urlresolvers import reverse
from permissions.models import Permission
from .api import ModuleBackup
#from .permissions import
def backup_view(request):
#Permission.objects.check_permissions(request.user, [])
context = {
'object_list': ModuleBackup.get_all(),
'title': _(u'apps registered for backup'),
'hide_link': True,
#'extra_columns': [
# {'name': _(u'description'), 'attribute': 'description'},
#],
}
return render_to_response('generic_list.html', context,
context_instance=RequestContext(request))

View File

@@ -166,6 +166,7 @@ INSTALLED_APPS = (
'clustering',
'scheduler',
'job_processor',
'backups',
# Mayan EDMS
'diagnostics',
'maintenance',

View File

@@ -43,6 +43,7 @@ urlpatterns = patterns('',
(r'^statistics/', include('statistics.urls')),
(r'^clustering/', include('clustering.urls')),
(r'^trash/', include('trash.urls')),
(r'^backups/', include('backups.urls')),
)