admin: set default host for outposts based on HTTP host
This commit is contained in:
parent
9d5d99290c
commit
316e6cb17f
|
@ -1,4 +1,7 @@
|
||||||
"""passbook Outpost administration"""
|
"""passbook Outpost administration"""
|
||||||
|
from dataclasses import asdict
|
||||||
|
from typing import Any, Dict
|
||||||
|
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from django.contrib.auth.mixins import (
|
from django.contrib.auth.mixins import (
|
||||||
PermissionRequiredMixin as DjangoPermissionRequiredMixin,
|
PermissionRequiredMixin as DjangoPermissionRequiredMixin,
|
||||||
|
@ -12,7 +15,7 @@ from guardian.mixins import PermissionListMixin, PermissionRequiredMixin
|
||||||
from passbook.admin.views.utils import DeleteMessageView
|
from passbook.admin.views.utils import DeleteMessageView
|
||||||
from passbook.lib.views import CreateAssignPermView
|
from passbook.lib.views import CreateAssignPermView
|
||||||
from passbook.outposts.forms import OutpostForm
|
from passbook.outposts.forms import OutpostForm
|
||||||
from passbook.outposts.models import Outpost
|
from passbook.outposts.models import Outpost, OutpostConfig
|
||||||
|
|
||||||
|
|
||||||
class OutpostListView(LoginRequiredMixin, PermissionListMixin, ListView):
|
class OutpostListView(LoginRequiredMixin, PermissionListMixin, ListView):
|
||||||
|
@ -41,6 +44,13 @@ class OutpostCreateView(
|
||||||
success_url = reverse_lazy("passbook_admin:outposts")
|
success_url = reverse_lazy("passbook_admin:outposts")
|
||||||
success_message = _("Successfully created Outpost")
|
success_message = _("Successfully created Outpost")
|
||||||
|
|
||||||
|
def get_initial(self) -> Dict[str, Any]:
|
||||||
|
return {
|
||||||
|
"_config": asdict(
|
||||||
|
OutpostConfig(passbook_host=self.request.build_absolute_uri("/"))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class OutpostUpdateView(
|
class OutpostUpdateView(
|
||||||
SuccessMessageMixin, LoginRequiredMixin, PermissionRequiredMixin, UpdateView
|
SuccessMessageMixin, LoginRequiredMixin, PermissionRequiredMixin, UpdateView
|
||||||
|
|
Reference in a new issue