Skip to content

Commit

Permalink
Merge branch 'dev' into standalone-ors
Browse files Browse the repository at this point in the history
  • Loading branch information
Raruto committed Jan 24, 2025
2 parents cd2aa59 + 71d793a commit 09441cc
Show file tree
Hide file tree
Showing 20 changed files with 376 additions and 335 deletions.
1 change: 1 addition & 0 deletions g3w-admin/base/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
THIRD_PARTY_APPS = [
'django_file_form',
'django_file_form.ajaxuploader',
'django_filters',
'model_utils',
'formtools',
'crispy_forms',
Expand Down
2 changes: 1 addition & 1 deletion g3w-admin/client/static/client/app.min.css

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions g3w-admin/client/static/client/app.min.css.map

Large diffs are not rendered by default.

359 changes: 174 additions & 185 deletions g3w-admin/client/static/client/app.min.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions g3w-admin/client/static/client/app.min.js.map

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
219 changes: 101 additions & 118 deletions g3w-admin/client/static/client/vendor.min.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions g3w-admin/client/static/client/vendor.min.js.map

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions g3w-admin/editing/static/editing/js/plugin.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions g3w-admin/editing/static/editing/js/plugin.js.map

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions g3w-admin/templates/bootstrap3/layout/prepended_appended_text.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% load crispy_forms_field %}

{% if field.is_hidden %}
{{ field }}
{% else %}
<div id="div_{{ field.auto_id }}" class="form-group{% if wrapper_class %} {{ wrapper_class }}{% endif %}{% if form_show_errors and field.errors %} has-error{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">

{% if field.label and form_show_labels %}
<label for="{{ field.id_for_label }}" class="control-label {{ label_class }}{% if field.field.required %} requiredField{% endif %}">
{{ field.label }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
</label>
{% endif %}

<div class="controls {{ field_class }}">
<div class="input-group">
{% if crispy_prepended_text %}<span class="input-group-addon{% if active %} active{% endif %}{% if input_size %} {{ input_size }}{% endif %}">{{ crispy_prepended_text|safe }}</span>{% endif %}
{% crispy_field field 'class' 'form-control' %}
{% if crispy_appended_text %}<span class="input-group-addon{% if active %} active{% endif %}{% if input_size %} {{ input_size }}{% endif %}">{{ crispy_appended_text|safe }}</span>{% endif %}
</div>

{% include 'bootstrap3/layout/help_text_and_errors.html' %}
</div>
</div>
{% endif %}
32 changes: 27 additions & 5 deletions g3w-admin/usersmanage/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,12 +538,32 @@ def filterFieldsByRoles(self, **kwargs):


def save(self, commit=True):
user = super(UserCreationForm, self).save(commit=False)

# Not inherit from ancestor for new Django 4.2 UserCreationForm
if self.errors:
raise ValueError(
"The %s could not be %s because the data didn't validate."
% (
self.instance._meta.object_name,
"created" if self.instance._state.adding else "changed",
)
)
# If not committing, add a method to the form to allow deferred
# saving of m2m data.
self.save_m2m = self._save_m2m

user = self.instance

# if editor maps groups user add viewer maps groups group to the user saved
if commit:

user.save()
if hasattr(self, "save_m2m"):
self.save_m2m()

if self.cleaned_data['password1']:
user.set_password(self.cleaned_data['password1'])
user.save()
user.save()

# for save groups
if 'groups' not in self.cleaned_data:
Expand Down Expand Up @@ -722,10 +742,12 @@ class G3WUserUpdateForm(G3WUserForm):
widget=forms.PasswordInput, required=False,
help_text=_("Enter the same password as above, for verification."))

password = ReadOnlyPasswordHashField()
def clean_username(self):
"""Reject usernames that differ only in case."""
username = self.cleaned_data.get("username")

return username

def clean_password(self):
return self.initial['password']

def clean_password2(self):
password1 = self.cleaned_data.get("password1")
Expand Down
22 changes: 22 additions & 0 deletions g3w-admin/usersmanage/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def test_user_form_crud(self):
'username': 'admin01_test',
'password1': self.users_password,
'password2': self.users_password,
'is_active': True,
'is_superuser': True,
'is_staff': True,
'groups': [self.main_roles[G3W_EDITOR1].pk], # required also fro admin1 and admin2
Expand All @@ -65,6 +66,13 @@ def test_user_form_crud(self):
u = User.objects.get(username='admin01_test')
self.assertTrue(u.is_superuser)
self.assertTrue(u.is_staff)
self.assertTrue(u.is_active)

# Check password is not changed making a login
self.client.logout()
login = self.client.login(username='admin01_test', password=self.users_password)
self.assertTrue(login)
self.client.logout()

u.delete()
del(u)
Expand All @@ -74,6 +82,7 @@ def test_user_form_crud(self):
'username': 'admin01_test',
'password1': self.users_password,
'password2': self.users_password,
'is_active': True,
'is_superuser': True,
'is_staff': True,
'groups': [self.main_roles[G3W_EDITOR1].pk], # required also for admin1 and admin2
Expand Down Expand Up @@ -109,6 +118,11 @@ def test_user_form_crud(self):
self.assertTrue(u.is_superuser)
self.assertTrue(u.is_staff)

# Check password is not changed making a login
login = self.client.login(username='admin01_test_updated', password=self.users_password)
self.assertTrue(login)
self.client.logout()

u.delete()
del(u)

Expand Down Expand Up @@ -138,6 +152,7 @@ def test_user_form_crud(self):
'username': 'admin02_test',
'password1': self.users_password,
'password2': self.users_password,
'is_active': True,
'is_superuser': True,
'is_staff': True,
'groups': [self.main_roles[G3W_EDITOR1].pk],
Expand Down Expand Up @@ -171,6 +186,7 @@ def test_user_form_crud(self):
'username': 'editor1_test',
'password1': self.users_password,
'password2': self.users_password,
'is_active': True,
'is_superuser': False,
'is_staff': True,
'groups': [self.main_roles[G3W_EDITOR1].pk, self.main_roles[G3W_VIEWER1].pk], # required also for admin1 and admin2
Expand Down Expand Up @@ -208,6 +224,7 @@ def test_user_form_crud(self):
'username': 'editor2_test',
'password1': self.users_password,
'password2': self.users_password,
'is_active': True,
'is_superuser': True,
'is_staff': True,
'groups': [self.main_roles[G3W_EDITOR2].pk],
Expand Down Expand Up @@ -253,6 +270,7 @@ def test_user_form_constraints(self):
'password1': self.users_password,
'password2': self.users_password,
'username': 'editor1_test_constraint',
'is_active': True,
'is_superuser': False,
'is_staff': False,
'groups': [],
Expand All @@ -272,6 +290,7 @@ def test_user_form_constraints(self):
'password1': self.users_password,
'password2': self.users_password,
'username': 'editor1_test_constraint',
'is_active': 'on',
'is_superuser': 'on',
'is_staff': 'off',
'groups': [],
Expand All @@ -286,6 +305,7 @@ def test_user_form_constraints(self):
'password1': self.users_password,
'password2': self.users_password,
'username': 'editor1_test_constraint',
'is_active': 'on',
'is_superuser': 'off',
'is_staff': 'on',
'groups': [],
Expand All @@ -300,6 +320,7 @@ def test_user_form_constraints(self):
'password1': self.users_password,
'password2': self.users_password,
'username': 'editor1_test_constraint',
'is_active': 'on',
'is_superuser': 'on',
'is_staff': 'on',
'groups': [],
Expand All @@ -319,6 +340,7 @@ def test_user_form_constraints(self):
'password1': self.users_password,
'password2': self.users_password,
'username': 'editor1_test_constraint',
'is_active': True,
'is_superuser': False,
'is_staff': False,
'groups': [self.main_roles[G3W_EDITOR1].pk, self.main_roles[G3W_EDITOR2].pk],
Expand Down

0 comments on commit 09441cc

Please sign in to comment.