15 Commits

Author SHA1 Message Date
lizerk
df2377431d feat: expand documents tasks and procurement workflows 2026-07-17 14:09:06 +03:00
lizerk
786987efe5 Stabilize Celery background jobs 2026-07-16 13:59:50 +03:00
lizerk
01490aa20b Improve employee stats and task card text 2026-07-12 21:22:55 +03:00
lizerk
32500e3037 chore: checkpoint current project changes 2026-06-20 10:47:00 +03:00
lizerk
92fb845b70 Fix birthday event sync lifecycle 2026-05-14 16:32:27 +03:00
lizerk
3a20c3d86a Normalize personnel events and attendance state 2026-04-29 09:54:11 +03:00
lizerk
78b8615871 feat: refine department calendar behavior and UI 2026-04-16 17:22:06 +03:00
lizerk
5700b53f13 feat: add department calendar bindings and cleanup dept permissions 2026-04-16 15:18:43 +03:00
lizerk
8d22156b36 feat(admin): add department role ldap sync action 2026-04-14 01:49:30 +03:00
lizerk
21db7f61a2 test(ldap): expand department role sync coverage 2026-04-14 01:33:24 +03:00
lizerk
2d00699831 fix(ldap): nest department role groups into department group 2026-04-14 01:07:13 +03:00
lizerk
81b8d29b38 Refactor department LDAP sync around canonical service flows 2026-04-10 20:54:09 +03:00
lizerk
f15e8aca3f feat(ldap): add LDAP sync retry queue with Celery
- Add LdapSyncQueue model for deferred LDAP operations
- Add Celery tasks: process_ldap_queue_item, process_ldap_queue
- Refactor all LDAP signals (employee, department, group, position)
  to enqueue operations on DirectoryLdapError/DirectoryServiceError
- Add _queue.py helper for enqueuing with automatic Celery dispatch
- Add Celery Beat periodic task (every 60s) for queue processing
- Add management command: ldap_queue (status/retry/cleanup)
- Add migration 0043_ldap_sync_queue
- Add 18 tests covering model, tasks, signals, and enqueue logic
- Include LDAP services refactoring (base_service, constants,
  user_login_service, user_mapper_service, user_password_service,
  phone_utils)
2026-03-19 15:07:34 +03:00
81cdf7fb24 fix: add is_active check to PositionRoleBackend and fix tests
Changes:
1. auth_backends.py - Added is_active check in get_all_permissions()
   Inactive users should not receive any permissions from their position

2. test_position_permissions.py - Multiple test fixes:
   - Moved fixtures to module level (accessible to all test classes)
   - Changed Permission creation to filter().first() pattern (no IntegrityError)
   - Fixed permission cache issues (use fresh User.objects.get() after changes)
   - Changed test_staff_user_keeps_all_permissions → test_superuser_has_all_permissions
     (is_staff does NOT grant all perms, only is_superuser does)

Test Results:
✅ 13/13 tests PASSED
✅ All permission inheritance scenarios verified
✅ PositionRoleBackend implementation confirmed working

Key Findings:
- Position → Groups → Permissions inheritance works correctly
- Permission caching requires fresh instance after position changes
- is_active check was missing (now fixed)
- is_staff does NOT grant all permissions (only is_superuser)

Next Steps:
- Check production environment for permission caching issues
- Verify LDAP group sync is working
- Test UI button visibility with real user accounts
2025-12-08 14:02:09 +03:00
b9e24dd841 test: add comprehensive position permissions tests
Created pytest test suite to verify permission inheritance through positions:

Test Coverage:
1. User without position has no permissions (PASS)
2. User with position gets all group permissions (needs fix)
3. Position change updates permissions dynamically
4. Remove position removes all permissions
5. Multiple users with same position get same permissions
6. Staff users keep all permissions regardless
7. Multiple groups' permissions are additive
8. get_all_permissions() includes position perms
9. Position without groups grants no permissions (PASS)
10. Inactive users have no permissions
11. Direct user permissions + position permissions combine
12. Feed/Documents integration tests

Current Results:
- 3 tests PASSED (basic cases)
- 10 tests need fixing (fixture scope issues)

Purpose:
These tests will validate that PositionRoleBackend correctly
grants permissions from Position.groups to users, which is
needed for features like:
- Show 'Create Post' button for users with publishing rights
- Show 'Create Document' button for users with document rights
- Consistent permission checks across frontend and backend

Next Steps:
1. Fix IntegrityError in permission creation (use filter first)
2. Make fixtures work across test classes
3. Run tests to verify PositionRoleBackend implementation
4. If tests fail, fix the backend implementation
2025-12-08 13:54:28 +03:00