Skip to content

Commit

Permalink
Update deprecated escape sequence (#8879)
Browse files Browse the repository at this point in the history
* avoid deprecation warning wth reg exp

* fix tests

* fix filter params in search

* fix validator

* remove unnecesary tag

* added backtick to symbol validator

---------

Co-authored-by: Felix Hernandez <[email protected]>
  • Loading branch information
FelixHernandez and felixhernandez15 authored Oct 30, 2023
1 parent 7ddf97e commit 24313e6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
29 changes: 29 additions & 0 deletions dojo/templates/dojo/filter_snippet.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,32 @@
</form>

</div>
<script>
$(document).ready(function() {
$(".filter-set>form").first().submit(function(event) {
var formData = $(".filter-set>form").first().serializeArray();
var filteredFormData = formData.filter(function(item) {
// Remove null or empty values
return item.value !== "" && item.value !== null && item.value !== 'unknown';
});
// Construct the query parameters from the filtered data
var queryParams = filteredFormData.map(function(item) {
return encodeURIComponent(item.name) + "=" + encodeURIComponent(item.value);
});

// Get the current page's URL
var currentPageURL = window.location.href;

// Remove existing query parameters from the current URL
var baseUrl = currentPageURL.split('?')[0];

// Append the new query parameters to the base URL
var newAction = baseUrl + "?" + queryParams.join("&");

// Append the query parameters to the action URL
var newAction = baseUrl + "?" + queryParams.join("&");
window.location.href = newAction;
event.preventDefault();
});
});
</script>
6 changes: 3 additions & 3 deletions dojo/user/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def get_help_text(self):

class NumberValidator(object):
def validate(self, password, user=None):
if not re.findall('\d', password) and get_system_setting('number_character_required'): # noqa W605
if not re.findall(r'\d', password) and get_system_setting('number_character_required'):
raise ValidationError(
self.get_help_text(),
code='password_no_number')
Expand Down Expand Up @@ -75,7 +75,7 @@ def get_help_text(self):

class SymbolValidator(object):
def validate(self, password, user=None):
contains_special_character = re.findall('[()[\]{}|\\`~!@#$%^&*_\-+=;:\'\",<>./?]', password) # noqa W605
contains_special_character = re.findall(r'[(){}\[\]|~!@#$%^&*_\-+=;:\'",\`<>\./?]', password)
if not contains_special_character and get_system_setting('special_character_required'):
raise ValidationError(
self.get_help_text(),
Expand All @@ -85,7 +85,7 @@ def validate(self, password, user=None):

def get_help_text(self):
return gettext('The password must contain at least 1 special character, ' +
'()[]{}|\`~!@#$%^&*_-+=;:\'\",<>./?.') # noqa W605
'''()[]{}|`~!@#$%^&*_-+=;:'",<>./?.''')


class DojoCommonPasswordValidator(CommonPasswordValidator):
Expand Down
2 changes: 1 addition & 1 deletion unittests/test_user_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def test_validator_special_character_required(self):
self.assertFalse(form.is_valid())
self.assertEqual(
form.errors['new_password'][0],
'The password must contain at least 1 special character, ()[]{}|\\`~!@#$%^&*_-+=;:\'",<>./?.')
'''The password must contain at least 1 special character, ()[]{}|`~!@#$%^&*_-+=;:'",<>./?.''')

def test_validator_lowercase_character_required(self):
with self.subTest(policy='lowercase_character_required=False'):
Expand Down

0 comments on commit 24313e6

Please sign in to comment.