django-orchestra/orchestra/contrib/webapps/backends/static.py

31 lines
1 KiB
Python
Raw Normal View History

2023-07-09 07:51:51 +00:00
from django.utils.translation import gettext_lazy as _
from orchestra.contrib.orchestration import ServiceController
from . import WebAppServiceMixin
2023-08-01 14:41:03 +00:00
from orchestra.settings import NEW_SERVERS
2023-07-09 07:51:51 +00:00
class StaticController(WebAppServiceMixin, ServiceController):
"""
Static web pages.
Only creates the webapp dir and leaves the web server the decision to execute CGIs or not.
"""
verbose_name = _("Static")
default_route_match = "webapp.type == 'static'"
def save(self, webapp):
context = self.get_context(webapp)
2023-08-01 14:41:03 +00:00
if context.get('target_server').name in NEW_SERVERS:
2023-07-25 14:59:58 +00:00
self.check_webapp_dir(context)
self.set_under_construction(context)
else:
self.create_webapp_dir(context)
self.set_under_construction(context)
2023-07-25 20:16:38 +00:00
2023-07-09 07:51:51 +00:00
def delete(self, webapp):
context = self.get_context(webapp)
2023-08-01 14:41:03 +00:00
if context.get('target_server').name in NEW_SERVERS:
2023-07-25 20:16:38 +00:00
webapp.sftpuser.delete()
2023-07-25 14:59:58 +00:00
else:
2023-07-25 20:16:38 +00:00
self.delete_webapp_dir(context)