Commit 1c268592 authored by Mark Caglienzi's avatar Mark Caglienzi
Browse files

Merge branch 't14151'

parents 7735a5a4 ac162b8b
octonet (10.0.0-1) testing; urgency=medium
* Version bump to 10.x.x
* The 'Force password change' button is removed and the function is
done via a boolean field in the form.
-- Mark Caglienzi <mark@truelite.it> Thu, 12 Mar 2020 16:27:42 +0100
octonet (0.2.62-1) testing; urgency=medium
* Temporarily hide the lock and unlock desktop buttons in the cluster
......
......@@ -13,7 +13,7 @@ def list_locale_files():
setup(
name='octonet',
description='OctoNet',
version='0.2.62',
version='10.0.0',
license='GPL3',
author='Truelite S.r.l.',
author_email='info@truelite.it',
......
{% load i18n %}
{% comment %}
{# refs #14151 Hide this action #}
<div class="row">
<div class="col-md-12">
<form method="post" action="{% url 'users:user_force_password_change' uid=octofuss_user.uid %}">
......@@ -10,6 +12,7 @@
</form>
</div>
</div>
{% endcomment %}
<div class="row">
<div class="col-md-12">
<form method="post"
......
......@@ -9,7 +9,8 @@ urlpatterns = [
url(r"^user/(?P<uid>[^/]+)/edit$", views.UserEdit.as_view(), name="user_edit"),
url(r"^user/(?P<uid>[^/]+)/set-enabled$", views.UserSetEnabled.as_view(), name="user_set_enabled"),
# refs #12559
url(r"^user/(?P<uid>[^/]+)/force-password-change$", views.UserForcePasswordChange.as_view(), name="user_force_password_change"),
# refs #14151: Hide the button that made POST to this view
# url(r"^user/(?P<uid>[^/]+)/force-password-change$", views.UserForcePasswordChange.as_view(), name="user_force_password_change"),
url(r"^user/(?P<uid>[^/]+)/add-group$", views.UserAddGroup.as_view(), name="user_add_group"),
# refs #213
url(r"^user/(?P<uid>[^/]+)/delete$", views.UserDelete.as_view(), name="user_delete"),
......
......@@ -332,6 +332,8 @@ class UserForm(FormControlClassMixin, forms.Form):
)
groups = forms.MultipleChoiceField(label=_("Groups"), required=False)
netperms = forms.MultipleChoiceField(label=_("Permissions"), required=False)
# refs #14151
force_password_change = forms.BooleanField(label=_("Force password change"), required=False)
# refs #13094
def clean_gecos(self):
......@@ -476,6 +478,7 @@ class UserFormMixin:
self.has_quota = self.root_tree.lhas(["quota"])
self.all_groups = self.root_tree.lget(["users", "groups"])
self.all_groups = sorted(self.all_groups, key=lambda x: x.get("cn"))
def _get_custom_user_form(self):
shells = self.root_tree.llist(["users", "shells"])
......@@ -578,6 +581,10 @@ class UserEdit(UserFormMixin, UserMixin, FormView):
if self.root_tree.lhas(path):
self.root_tree.lset(path, f.cleaned_data)
# refs #14151
if user_form.cleaned_data.get('force_password_change', False):
self.root_tree.lset(["users", "users", self.user["uid"], "shadowLastChange"], 0)
messages.info(self.request, _("Password change forced for user {}").format(self.user['uid']))
return super().form_valid(form)
......@@ -720,13 +727,14 @@ class UserSetEnabled(OctonetMixin, FormView):
# refs #12559
class UserForcePasswordChange(OctonetMixin, FormView):
http_method_names = ['post']
def post(self, request, *args, **kwargs):
self.root_tree.lset(["users", "users", self.kwargs["uid"], "shadowLastChange"], 0)
messages.info(request, _("Password change forced for user {}").format(self.kwargs['uid']))
return redirect("users:detail", uid=self.kwargs["uid"])
# refs #14151: Hide the button that made POST to this view
# class UserForcePasswordChange(OctonetMixin, FormView):
# http_method_names = ['post']
# def post(self, request, *args, **kwargs):
# self.root_tree.lset(["users", "users", self.kwargs["uid"], "shadowLastChange"], 0)
# messages.info(request, _("Password change forced for user {}").format(self.kwargs['uid']))
# return redirect("users:detail", uid=self.kwargs["uid"])
class UserAddGroup(OctonetMixin, FormView):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment