django-orchestra-test/orchestra/contrib/websites/backends/moodle.py
2016-03-08 10:16:49 +00:00

26 lines
770 B
Python

import textwrap
from orchestra.contrib.orchestration import ServiceController
class MoodleWWWRootController(ServiceController):
"""
Configures Moodle site WWWRoot, without it Moodle refuses to work.
"""
verbose_name = "Moodle WWWRoot (required)"
model = 'websites.Content'
default_route_match = "content.webapp.type == 'moodle-php'"
def save(self, content):
context = self.get_context(content)
self.append(textwrap.dedent("""\
sed -i "s#wwwroot\s*= '.*#wwwroot = '%(url)s';#" %(app_path)s/config.php
""") % context
)
def get_context(self, content):
return {
'url': content.get_absolute_url(),
'app_path': content.webapp.get_path(),
}