chore(dgsi/view): Random improvements
This commit is contained in:
parent
adfd7b27a8
commit
aad8984678
1 changed files with 11 additions and 12 deletions
|
@ -59,15 +59,12 @@ ADMIN_LINKS: list[Link] = [
|
||||||
|
|
||||||
class IndexView(TemplateView):
|
class IndexView(TemplateView):
|
||||||
template_name = "dgsi/index.html"
|
template_name = "dgsi/index.html"
|
||||||
|
extra_context = {
|
||||||
def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
|
"links": {
|
||||||
return super().get_context_data(
|
|
||||||
links={
|
|
||||||
"authenticated": AUTHENTICATED_LINKS,
|
"authenticated": AUTHENTICATED_LINKS,
|
||||||
"admin": ADMIN_LINKS,
|
"admin": ADMIN_LINKS,
|
||||||
},
|
}
|
||||||
**kwargs,
|
}
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class ProfileView(LoginRequiredMixin, TemplateView):
|
class ProfileView(LoginRequiredMixin, TemplateView):
|
||||||
|
@ -125,10 +122,14 @@ class GenerateWiFiPasswordView(LoginRequiredMixin, RedirectView):
|
||||||
else:
|
else:
|
||||||
# Give access to the wifi network when the user creates its first password
|
# Give access to the wifi network when the user creates its first password
|
||||||
if not user.kanidm.radius_secret:
|
if not user.kanidm.radius_secret:
|
||||||
|
message = _("Mot de passe Wi-Fi généré avec succès.")
|
||||||
async_to_sync(klient.group_add_members)(
|
async_to_sync(klient.group_add_members)(
|
||||||
"radius_access", [user.username]
|
"radius_access", [user.username]
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
message = _("Mot de passe Wi-Fi reinitialisé avec succès.")
|
||||||
async_to_sync(klient.call_post)(f"/v1/person/{user.username}/_radius")
|
async_to_sync(klient.call_post)(f"/v1/person/{user.username}/_radius")
|
||||||
|
messages.add_message(request, messages.SUCCESS, message)
|
||||||
|
|
||||||
return super().get(request, *args, **kwargs)
|
return super().get(request, *args, **kwargs)
|
||||||
|
|
||||||
|
@ -140,6 +141,7 @@ class CreateSelfAccountView(AccessMixin, SuccessMessageMixin, FormView):
|
||||||
form_class = CreateSelfAccountForm
|
form_class = CreateSelfAccountForm
|
||||||
success_message = _("Compte DGNum créé avec succès")
|
success_message = _("Compte DGNum créé avec succès")
|
||||||
success_url = reverse_lazy("dgsi:dgn-profile")
|
success_url = reverse_lazy("dgsi:dgn-profile")
|
||||||
|
extra_context = {"backlink": "dgsi:dgn-profile"}
|
||||||
|
|
||||||
def dispatch(
|
def dispatch(
|
||||||
self, request: HttpRequest, *args: Any, **kwargs: Any
|
self, request: HttpRequest, *args: Any, **kwargs: Any
|
||||||
|
@ -209,9 +211,6 @@ class CreateSelfAccountView(AccessMixin, SuccessMessageMixin, FormView):
|
||||||
|
|
||||||
return super().form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|
||||||
def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
|
|
||||||
return super().get_context_data(backlink="dgsi:dgn-profile", **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
class ArchiveListView(LoginRequiredMixin, TemplateView):
|
class ArchiveListView(LoginRequiredMixin, TemplateView):
|
||||||
template_name = "dgsi/archive_list.html"
|
template_name = "dgsi/archive_list.html"
|
||||||
|
|
Loading…
Add table
Reference in a new issue