Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set name for events cookie and update backend deps 20240528 #2310

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions ESSArch_Core/auth/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,30 @@
logger.info(f"User '{request.user}' attempts to delete the group type '{object}' with msg: '{message}'.")


@admin.action(permissions=["change"], description=_("Duplicate selected items"))
def duplicate(modeladmin, request, queryset):
import copy

Check warning on line 301 in ESSArch_Core/auth/admin.py

View check run for this annotation

Codecov / codecov/patch

ESSArch_Core/auth/admin.py#L301

Added line #L301 was not covered by tests

from django.db import IntegrityError
from django.utils.text import slugify

Check warning on line 304 in ESSArch_Core/auth/admin.py

View check run for this annotation

Codecov / codecov/patch

ESSArch_Core/auth/admin.py#L303-L304

Added lines #L303 - L304 were not covered by tests
for obj in queryset:
obj_copy = copy.copy(obj)
obj_copy.id = None
obj_copy.label = '{} ***'.format(obj_copy.label)
obj_copy.codename = slugify(obj_copy.label)
try:
obj_copy.save()
except IntegrityError:
obj_copy.codename = obj_copy.label
obj_copy.save()
obj_copy.permissions.add(*obj.permissions.all())

Check warning on line 315 in ESSArch_Core/auth/admin.py

View check run for this annotation

Codecov / codecov/patch

ESSArch_Core/auth/admin.py#L306-L315

Added lines #L306 - L315 were not covered by tests


class GroupMemberRoleAdmin(admin.ModelAdmin):
list_display = ('__str__', 'external_id', 'codename')
search_fields = ['codename', 'label', 'external_id']
filter_horizontal = ['permissions']
actions = [duplicate]

def log_addition(self, request, object, message):
logger.info(f"User '{request.user}' attempts to create role '{object}' with msg: '{message}'.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,9 @@ export default class EventCtrl {
const vm = this;
$scope.$translate = $translate;

vm.getCookieName = function () {
let name;
switch ($rootScope.app) {
case 'ESSArch Preservation Platform':
name = 'epp-events-per-page';
break;
case 'ESSArch Tools For Producer':
name = 'etp-events-per-page';
break;
case 'ESSArch Tools Archive':
name = 'eta-events-per-page';
break;
default:
name = 'etp-events-per-page';
break;
}
return name;
};

vm.itemsPerPage = $cookies.get(vm.getCookieName) || 10;
vm.itemsPerPage = $cookies.get('essarch-events-per-page') || 10;
$scope.updateEventsPerPage = function (items) {
$cookies.put(vm.getCookieName, items);
$cookies.put('essarch-events-per-page', items);
};
$scope.selected = [];
vm.displayed = [];
Expand Down
11 changes: 9 additions & 2 deletions ESSArch_Core/frontend/tests/test_login.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from time import sleep

from django.contrib.auth import get_user_model
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait

Expand All @@ -22,12 +25,16 @@ def test_login(self):

old_url = self.selenium.current_url
self.selenium.find_element("xpath", '//button[@type="submit"]').click()
WebDriverWait(self.selenium, 25).until(EC.title_is('Info | ESSArch'))
try:
WebDriverWait(self.selenium, 15).until(EC.title_is('Info | ESSArch'))
except TimeoutException:
sleep(10)
WebDriverWait(self.selenium, 15).until(EC.title_is('Info | ESSArch'))
self.assertTrue(EC.url_changes(old_url))

# logout
old_url = self.selenium.current_url
self.selenium.find_element("class name", 'dropdown-toggle').click()
self.selenium.find_element("xpath", '//*[contains(text(), "Logout")]').click()
WebDriverWait(self.selenium, 25).until(EC.title_is('Login | ESSArch'))
WebDriverWait(self.selenium, 15).until(EC.title_is('Login | ESSArch'))
self.assertTrue(EC.url_changes(old_url))
8 changes: 4 additions & 4 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
asgiref==3.7.2
boto3==1.34.106
boto3==1.34.113
celery[tblib]==5.4.0
cffi==1.16.0
channels==4.1.0
Expand Down Expand Up @@ -29,7 +29,7 @@ django-json-widget==1.1.1
django-proxy==1.2.2
django-rest-knox==4.2.0
distro==1.9.0
docker==6.0.1
docker==7.1.0
drf-dynamic-fields==0.4.0
drf-extensions==0.7.1
drf-proxy-pagination==0.2.0
Expand All @@ -40,15 +40,15 @@ gevent==24.2.1 ; platform_system=='Windows'
glob2==0.7
jsonfield==3.1.0
lxml==5.2.2
msoffcrypto-tool==5.4.0
msoffcrypto-tool==5.4.1
natsort==8.4.0
opf-fido==1.6.1
pyfakefs==5.5.0
python-dateutil==2.8.2
pywin32==306 ; platform_system=='Windows'
redis==5.0.4
regex==2024.5.15
requests==2.31.0
requests==2.32.2
requests_toolbelt==1.0.0
tenacity==8.3.0
wand==0.6.13
Expand Down
2 changes: 1 addition & 1 deletion requirements/tests.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
coverage==7.4.4
coverage==7.5.2
django-test-without-migrations==0.6
selenium==3.141.0
Loading