django-orchestra/orchestra/contrib/websites/backends/moodle.py

26 lines
770 B
Python
Raw Normal View History

2016-02-10 12:07:55 +00:00
import textwrap
from orchestra.contrib.orchestration import ServiceController
2016-03-08 10:16:49 +00:00
class MoodleWWWRootController(ServiceController):
2016-02-10 12:07:55 +00:00
"""
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(),
}