Skip to content

Commit

Permalink
Merge pull request #8038 from 4teamwork/amo/TI-1086/remove_inactive_u…
Browse files Browse the repository at this point in the history
…sers_from_teamraus_excel

Exclude inactive users from teamraum participation excel export
  • Loading branch information
Abdu-moustafa authored Sep 10, 2024
2 parents 861fea8 + 33b00a2 commit 5fb08e0
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 2 deletions.
1 change: 1 addition & 0 deletions changes/TI-1086.other
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Exclude inactive (users / group users) from teamraum participation excel export. [amo]
4 changes: 2 additions & 2 deletions opengever/workspace/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ def fetch_users(self):
for user_id in user_ids:
group_members = ogds_service().fetch_group(user_id)
if group_members:
users.update(group_members.users)
users.update([user for user in group_members.users if user.active])
else:
user = ogds_service().fetch_user(user_id)
if user:
if user and user.active:
users.add(user)

return list(users)
101 changes: 101 additions & 0 deletions opengever/workspace/tests/test_workspace_participation_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,104 @@ def test_download_users_xlsx(self, browser):
]
]
self.assertItemsEqual(expected_values, cell_values)

@browsing
def test_exclude_inactive_user_from_users_xlsx_download(self, browser):
"""Only active users and active group_users will be included in the Excel file
"""
self.login(self.administrator, browser=browser)

group_user = ogds_service().find_user(self.regular_user.id)

# group inactive user should not be included in the excel
group_inactive_user = create(
Builder('ogds_user')
.having(active=False, userid="inactive_group_user")

)
# inactive user should not be included in the excel
inactive_user = create(
Builder('ogds_user')
.having(active=False, userid="inactive_user")
)

group = create(Builder('ogds_group')
.having(groupid='group1',
title='Group 1', users=[group_user, group_inactive_user]))
user_ids = {
'user_ids': [
self.regular_user.id,
self.administrator.id,
inactive_user.userid,
group.groupid
]
}

browser.open(view='workspace_participants_report', data=user_ids)
self.assertEqual(browser.status_code, 200)
with NamedTemporaryFile(delete=False, suffix='.xlsx') as tmpfile:
tmpfile.write(browser.contents)
tmpfile.flush()
workbook = load_workbook(tmpfile.name)

task_cells = list(workbook.active.rows)

# if row_num != 0 will remove the table header
cell_values = [[cell.value for cell in row] for row_num, row in enumerate(task_cells) if row_num != 0]
expected_values = [
[
u'kathi.barfuss',
True,
u'K\xe4thi',
u'B\xe4rfuss',
u'B\xe4rfuss K\xe4thi',
u'Staatsarchiv',
u'Arch',
u'Staatskanzlei',
u'SK',
None,
u'foo@example.com',
u'bar@example.com',
u'http://www.example.com',
u'012 34 56 78',
u'012 34 56 77',
u'012 34 56 76',
u'Frau',
u'Gesch\xe4ftsf\xfchrerin',
u'nix',
u'Kappelenweg 13',
u'Postfach 1234',
u'1234',
u'Vorkappelen',
u'Schweiz',
None
],
[
u'nicole.kohler',
True,
u'Nicole',
u'Kohler',
u'Kohler Nicole',
None,
None,
None,
None,
None,
u'nicole.kohler@gever.local',
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None
]
]
self.assertItemsEqual(expected_values, cell_values)

0 comments on commit 5fb08e0

Please sign in to comment.