2014-09-26 15:05:20 +00:00
|
|
|
import os
|
|
|
|
|
2014-05-08 16:59:35 +00:00
|
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
|
2015-04-05 18:02:36 +00:00
|
|
|
from orchestra.contrib.orchestration import ServiceController, replace
|
2014-05-08 16:59:35 +00:00
|
|
|
|
|
|
|
from .. import settings
|
|
|
|
|
2014-07-09 16:17:43 +00:00
|
|
|
|
2014-11-27 19:17:26 +00:00
|
|
|
class DokuWikiMuBackend(ServiceController):
|
2015-04-24 11:39:20 +00:00
|
|
|
"""
|
|
|
|
Creates a DokuWiki site on a DokuWiki multisite installation.
|
|
|
|
"""
|
2014-05-08 16:59:35 +00:00
|
|
|
verbose_name = _("DokuWiki multisite")
|
2014-11-27 19:17:26 +00:00
|
|
|
model = 'webapps.WebApp'
|
2015-04-24 11:39:20 +00:00
|
|
|
doc_settings = (settings,
|
|
|
|
('SAAS_DOKUWIKI_TEMPLATE_PATH', 'SAAS_DOKUWIKI_FARM_PATH')
|
|
|
|
)
|
2014-05-08 16:59:35 +00:00
|
|
|
|
|
|
|
def save(self, webapp):
|
|
|
|
context = self.get_context(webapp)
|
|
|
|
self.append("mkdir %(app_path)" % context)
|
|
|
|
self.append("tar xfz %(template)s -C %(app_path)s" % context)
|
|
|
|
self.append("chown -R www-data %(app_path)s" % context)
|
|
|
|
# TODO move dokuwiki to user directory
|
|
|
|
|
|
|
|
def delete(self, webapp):
|
|
|
|
context = self.get_context(webapp)
|
|
|
|
self.append("rm -fr %(app_path)s" % context)
|
|
|
|
|
|
|
|
def get_context(self, webapp):
|
2014-09-26 15:05:20 +00:00
|
|
|
context = super(DokuWikiMuBackend, self).get_context(webapp)
|
2014-05-08 16:59:35 +00:00
|
|
|
context.update({
|
2015-04-24 11:39:20 +00:00
|
|
|
'template': settings.SAAS_DOKUWIKI_TEMPLATE_PATH,
|
|
|
|
'app_path': os.path.join(settings.SAAS_DOKUWIKI_FARM_PATH, webapp.name)
|
2014-05-08 16:59:35 +00:00
|
|
|
})
|
2015-04-05 18:02:36 +00:00
|
|
|
return replace(context, "'", '"')
|