forked from Fediversity/Fediversity
Convert configuration form to json
WIP: Get nix in scope
This commit is contained in:
parent
e79c974969
commit
25e16fed7a
4 changed files with 15 additions and 6 deletions
panel
|
@ -22,6 +22,7 @@ in
|
||||||
packages = [
|
packages = [
|
||||||
pkgs.npins
|
pkgs.npins
|
||||||
manage
|
manage
|
||||||
|
pkgs.nix
|
||||||
];
|
];
|
||||||
env = {
|
env = {
|
||||||
NPINS_DIRECTORY = toString ../npins;
|
NPINS_DIRECTORY = toString ../npins;
|
||||||
|
|
|
@ -37,6 +37,7 @@ let
|
||||||
django-libsass
|
django-libsass
|
||||||
django_4
|
django_4
|
||||||
setuptools
|
setuptools
|
||||||
|
pkgs.nix
|
||||||
]
|
]
|
||||||
++ cfg.package.propagatedBuildInputs
|
++ cfg.package.propagatedBuildInputs
|
||||||
);
|
);
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
lib,
|
lib,
|
||||||
sqlite,
|
sqlite,
|
||||||
python3,
|
python3,
|
||||||
|
nix,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
src =
|
src =
|
||||||
|
@ -50,6 +51,7 @@ python3.pkgs.buildPythonPackage {
|
||||||
in
|
in
|
||||||
[
|
[
|
||||||
sqlite
|
sqlite
|
||||||
|
nix
|
||||||
]
|
]
|
||||||
++ pythonPackages;
|
++ pythonPackages;
|
||||||
|
|
||||||
|
|
|
@ -11,18 +11,23 @@ from django.views.generic.edit import FormView
|
||||||
from panel import models
|
from panel import models
|
||||||
from panel.configuration import Version
|
from panel.configuration import Version
|
||||||
|
|
||||||
|
|
||||||
class Index(TemplateView):
|
class Index(TemplateView):
|
||||||
template_name = 'index.html'
|
template_name = 'index.html'
|
||||||
|
|
||||||
|
|
||||||
class AccountDetail(LoginRequiredMixin, DetailView):
|
class AccountDetail(LoginRequiredMixin, DetailView):
|
||||||
model = User
|
model = User
|
||||||
template_name = 'account_detail.html'
|
template_name = 'account_detail.html'
|
||||||
|
|
||||||
def get_object(self):
|
def get_object(self):
|
||||||
return self.request.user
|
return self.request.user
|
||||||
|
|
||||||
|
|
||||||
class ServiceList(TemplateView):
|
class ServiceList(TemplateView):
|
||||||
template_name = 'service_list.html'
|
template_name = 'service_list.html'
|
||||||
|
|
||||||
|
|
||||||
class ConfigurationForm(LoginRequiredMixin, FormView):
|
class ConfigurationForm(LoginRequiredMixin, FormView):
|
||||||
template_name = 'configuration_form.html'
|
template_name = 'configuration_form.html'
|
||||||
success_url = reverse_lazy('configuration_form')
|
success_url = reverse_lazy('configuration_form')
|
||||||
|
@ -42,14 +47,14 @@ class ConfigurationForm(LoginRequiredMixin, FormView):
|
||||||
operator=self.request.user,
|
operator=self.request.user,
|
||||||
)
|
)
|
||||||
|
|
||||||
button_name = self.request.POST.get('save_draft') or self.request.POST.get('publish')
|
# Check for deploy button
|
||||||
print(f"self.request.POST: {self.request.POST}")
|
if "deploy" in self.request.POST.keys():
|
||||||
print(f"button_name: {button_name}")
|
|
||||||
if button_name == 'deploy':
|
|
||||||
print("DEPLOYING:")
|
print("DEPLOYING:")
|
||||||
print(os.getenv("REPO_DIR"))
|
print(os.getenv("REPO_DIR"))
|
||||||
print(obj)
|
config_dict = obj.parsed_value.model_dump_json()
|
||||||
subprocess.run(["nix", "develop", "--command", "nixops4", "apply", "test"], cwd=os.getenv("REPO_DIR"), env={"DEPLOYMENT": obj})
|
print(f"config_dict: {config_dict}")
|
||||||
|
subprocess.run(["nix", "develop", "--command", "nixops4", "apply",
|
||||||
|
"test"], cwd=os.getenv("REPO_DIR"), env={"DEPLOYMENT": config_dict})
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
# TODO(@fricklerhandwerk):
|
# TODO(@fricklerhandwerk):
|
||||||
|
|
Loading…
Add table
Reference in a new issue