micro-users 1.0.3__tar.gz → 1.9.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. micro_users-1.9.0/PKG-INFO +224 -0
  2. micro_users-1.9.0/README.md +192 -0
  3. micro_users-1.9.0/micro_users.egg-info/PKG-INFO +224 -0
  4. micro_users-1.9.0/micro_users.egg-info/SOURCES.txt +49 -0
  5. {micro_users-1.0.3 → micro_users-1.9.0}/pyproject.toml +7 -2
  6. {micro_users-1.0.3 → micro_users-1.9.0}/setup.py +3 -1
  7. micro_users-1.9.0/users/admin.py +37 -0
  8. micro_users-1.9.0/users/apps.py +44 -0
  9. micro_users-1.9.0/users/context_processors.py +9 -0
  10. micro_users-1.9.0/users/filters.py +143 -0
  11. micro_users-1.9.0/users/forms.py +491 -0
  12. micro_users-1.9.0/users/middleware.py +32 -0
  13. micro_users-1.9.0/users/migrations/0001_initial.py +63 -0
  14. micro_users-1.9.0/users/migrations/0002_alter_useractivitylog_action.py +18 -0
  15. micro_users-1.9.0/users/migrations/0003_scope_scopesettings_alter_customuser_options_and_more.py +58 -0
  16. {micro_users-1.0.3 → micro_users-1.9.0}/users/models.py +42 -1
  17. micro_users-1.9.0/users/signals.py +139 -0
  18. micro_users-1.9.0/users/static/img/default_profile.webp +0 -0
  19. micro_users-1.9.0/users/static/img/login_logo.webp +0 -0
  20. micro_users-1.9.0/users/static/users/css/detail.css +47 -0
  21. micro_users-1.9.0/users/static/users/css/login.css +273 -0
  22. micro_users-1.9.0/users/static/users/css/permissions.css +105 -0
  23. micro_users-1.9.0/users/static/users/css/profile.css +123 -0
  24. micro_users-1.9.0/users/static/users/css/style.css +83 -0
  25. micro_users-1.9.0/users/static/users/js/login.js +28 -0
  26. micro_users-1.9.0/users/static/users/js/manage_users.js +189 -0
  27. micro_users-1.9.0/users/static/users/js/permissions.js +92 -0
  28. micro_users-1.9.0/users/tables.py +76 -0
  29. micro_users-1.9.0/users/templates/registration/login.html +62 -0
  30. micro_users-1.9.0/users/templates/users/manage_users.html +133 -0
  31. micro_users-1.9.0/users/templates/users/partials/scope_actions.html +9 -0
  32. micro_users-1.9.0/users/templates/users/partials/scope_form.html +19 -0
  33. micro_users-1.9.0/users/templates/users/partials/scope_manager.html +12 -0
  34. {micro_users-1.0.3/users/templates/users → micro_users-1.9.0/users/templates/users/partials}/user_actions.html +14 -9
  35. micro_users-1.9.0/users/templates/users/profile/profile.html +114 -0
  36. micro_users-1.9.0/users/templates/users/profile/profile_edit.html +100 -0
  37. micro_users-1.9.0/users/templates/users/user_activity_log.html +28 -0
  38. micro_users-1.9.0/users/templates/users/user_detail.html +108 -0
  39. micro_users-1.9.0/users/templates/users/widgets/grouped_permissions.html +75 -0
  40. micro_users-1.9.0/users/urls.py +28 -0
  41. micro_users-1.9.0/users/utils.py +14 -0
  42. micro_users-1.9.0/users/views.py +422 -0
  43. micro_users-1.0.3/PKG-INFO +0 -106
  44. micro_users-1.0.3/README.md +0 -77
  45. micro_users-1.0.3/micro_users.egg-info/PKG-INFO +0 -106
  46. micro_users-1.0.3/micro_users.egg-info/SOURCES.txt +0 -29
  47. micro_users-1.0.3/users/admin.py +0 -18
  48. micro_users-1.0.3/users/apps.py +0 -30
  49. micro_users-1.0.3/users/filters.py +0 -120
  50. micro_users-1.0.3/users/forms.py +0 -364
  51. micro_users-1.0.3/users/signals.py +0 -41
  52. micro_users-1.0.3/users/static/css/login.css +0 -134
  53. micro_users-1.0.3/users/tables.py +0 -40
  54. micro_users-1.0.3/users/templates/registration/login.html +0 -115
  55. micro_users-1.0.3/users/templates/user_activity_log.html +0 -22
  56. micro_users-1.0.3/users/templates/users/manage_users.html +0 -73
  57. micro_users-1.0.3/users/templates/users/profile.html +0 -63
  58. micro_users-1.0.3/users/templates/users/profile_edit.html +0 -77
  59. micro_users-1.0.3/users/urls.py +0 -18
  60. micro_users-1.0.3/users/views.py +0 -198
  61. {micro_users-1.0.3 → micro_users-1.9.0}/LICENSE +0 -0
  62. {micro_users-1.0.3 → micro_users-1.9.0}/MANIFEST.in +0 -0
  63. {micro_users-1.0.3 → micro_users-1.9.0}/micro_users.egg-info/dependency_links.txt +0 -0
  64. {micro_users-1.0.3 → micro_users-1.9.0}/micro_users.egg-info/requires.txt +0 -0
  65. {micro_users-1.0.3 → micro_users-1.9.0}/micro_users.egg-info/top_level.txt +0 -0
  66. {micro_users-1.0.3 → micro_users-1.9.0}/setup.cfg +0 -0
  67. {micro_users-1.0.3 → micro_users-1.9.0}/users/__init__.py +0 -0
  68. {micro_users-1.0.3 → micro_users-1.9.0}/users/migrations/__init__.py +0 -0
  69. {micro_users-1.0.3 → micro_users-1.9.0}/users/templates/users/user_form.html +0 -0
@@ -0,0 +1,224 @@
1
+ Metadata-Version: 2.1
2
+ Name: micro_users
3
+ Version: 1.9.0
4
+ Summary: Arabic Django user management app with abstract user, permissions, and activity logging
5
+ Home-page: https://github.com/debeski/micro-users
6
+ Author: DeBeski
7
+ Author-email: DeBeski <debeski1@gmail.com>
8
+ License: MIT
9
+ Project-URL: Homepage, https://github.com/debeski/micro-users
10
+ Keywords: django,users,permissions,authentication
11
+ Classifier: Framework :: Django
12
+ Classifier: Framework :: Django :: 5
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: License :: OSI Approved :: MIT License
22
+ Classifier: Operating System :: OS Independent
23
+ Requires-Python: >=3.9
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: Django>=5.1
27
+ Requires-Dist: django-crispy-forms>=2.4
28
+ Requires-Dist: django-tables2>=2.7
29
+ Requires-Dist: django-filter>=24.3
30
+ Requires-Dist: pillow>=11.0
31
+ Requires-Dist: babel>=2.1
32
+
33
+ # Micro Users - Arabic Django User Management App
34
+
35
+ [![PyPI version](https://badge.fury.io/py/micro-users.svg)](https://pypi.org/project/micro-users/)
36
+
37
+ <p align="center">
38
+ <img src="https://raw.githubusercontent.com/debeski/micro-users/main/users/static/img/login_logo.webp" alt="Micro Users Login Logo" width="450"/>
39
+ </p>
40
+
41
+ **Arabic** lightweight, reusable Django app providing user management with abstract user, permissions, localization, and activity logging.
42
+
43
+ ## Requirements
44
+ - **Must be installed on a fresh database.**
45
+ - Python 3.11+
46
+ - Django 5.1+
47
+ - django-crispy-forms 2.4+
48
+ - django-tables2 2.7+
49
+ - django-filter 24.3+
50
+ - pillow 11.0+
51
+ - babel 2.1+
52
+
53
+ ## Features
54
+ - Custom AbstractUser model
55
+ - Scope Management System (Optional)
56
+ - Custom Grouped User permissions system
57
+ - Automatic Activity logging (login/logout, CRUD for all models)
58
+ - Specific User detail and log view
59
+ - Localization support
60
+ - Admin interface integration
61
+ - CRUD views and templates
62
+ - Filtering and tabulation
63
+ > *Future updates are planned to support dynamic language switching between RTL and LTR.*
64
+
65
+ ## Installation
66
+
67
+ ```bash
68
+ pip install git+https://github.com/debeski/micro-users.git
69
+ # OR
70
+ pip install micro-users
71
+ ```
72
+
73
+ ## Configuration
74
+
75
+ 1. Add to `INSTALLED_APPS`:
76
+ ```python
77
+ INSTALLED_APPS = [
78
+ 'users', # Preferably on top
79
+ 'django.contrib.admin',
80
+ 'django.contrib.auth',
81
+ ...
82
+ ]
83
+ ```
84
+
85
+ 2. Add Middleware in `settings.py` (Required for logging):
86
+ ```python
87
+ MIDDLEWARE = [
88
+ # ...
89
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
90
+ # ...
91
+ 'users.middleware.ActivityLogMiddleware', # Add this line
92
+ ]
93
+ ```
94
+
95
+ 3. Add Context Processor in `settings.py` (Optional, for `scope_enabled` variable in templates):
96
+ ```python
97
+ TEMPLATES = [
98
+ {
99
+ # ...
100
+ 'OPTIONS': {
101
+ 'context_processors': [
102
+ # ...
103
+ 'users.context_processors.scope_settings', # Add this line
104
+ ],
105
+ },
106
+ },
107
+ ]
108
+ ```
109
+
110
+ 4. Set custom user model in `settings.py`:
111
+ ```python
112
+ AUTH_USER_MODEL = 'users.CustomUser'
113
+ ```
114
+
115
+ 5. Include URLs in your main project folder `urls.py`:
116
+ ```python
117
+ urlpatterns = [
118
+ ...
119
+ path('manage/', include('users.urls')),
120
+ ]
121
+ ```
122
+
123
+ 6. Run migrations:
124
+ ```bash
125
+ python manage.py migrate users
126
+ ```
127
+
128
+ ## How to Use
129
+
130
+ Once configured, the app automatically handles user management and activity logging. Ensure your project has a `base.html` template in the root templates directory, as all user management templates extend it.
131
+
132
+ ### Activity Logging
133
+
134
+ The app provides a fully **automated** activity logging system. No manual configuration is required in your views.
135
+
136
+ - **Login/Logout**: Automatically tracked.
137
+ - **Create/Update/Delete**: Any change to any model in your app (including `Scope` and `User`) is automatically logged via Django Signals.
138
+ - **Log content**: Tracks the user, action type, model name, object ID, and timestamp.
139
+ - *Note*: `last_login` field updates are automatically filtered out to prevent redundant "Update" logs on login.
140
+
141
+ To view logs, navigate to `manage/logs/` or use the Django Admin interface ("حركات السجل").
142
+
143
+ ## Available URLs
144
+
145
+ All user management URLs are prefixed with `manage/` as configured above. Below is the complete list:
146
+
147
+ | URL Pattern | View/Function | Description |
148
+ |-------------|---------------|-------------|
149
+ | `manage/login/` | `auth_views.LoginView.as_view()` | User login |
150
+ | `manage/logout/` | `auth_views.LogoutView.as_view()` | User logout |
151
+ | `manage/users/` | `views.UserListView.as_view()` | List all users |
152
+ | `manage/users/create/` | `views.create_user` | Create new user |
153
+ | `manage/users/edit/<int:pk>/` | `views.edit_user` | Edit existing user |
154
+ | `manage/users/delete/<int:pk>/` | `views.delete_user` | Delete user |
155
+ | `manage/users/<int:pk>/` | `views.UserDetailView.as_view()` | View user details |
156
+ | `manage/profile` | `views.user_profile` | View current user profile |
157
+ | `manage/profile/edit/` | `views.edit_profile` | Edit current profile |
158
+ | `manage/logs/` | `views.UserActivityLogView.as_view()` | View activity logs |
159
+ | `manage/reset_password/<int:pk>/` | `views.reset_password` | Reset user password |
160
+ | `manage/scopes/manage/` | `views.manage_scopes` | Scope Manager (Modal) |
161
+
162
+ ## Structure
163
+ ```
164
+ users/
165
+ ├── views.py # CRUD operations
166
+ ├── urls.py # URL routing
167
+ ├── tables.py # User and Activity Log tables
168
+ ├── signals.py # Logging signals
169
+ ├── middleware.py # Request capture for signals
170
+ ├── models.py # User model, permissions, activity logs
171
+ ├── forms.py # Creation, edit,. etc.
172
+ ├── filter.py # Search filters
173
+ ├── apps.py # Permissions Localization
174
+ ├── admin.py # Admin UI integration
175
+ ├── __init__.py # Python init
176
+ ├── templates/ # HTML templates (includes partials)
177
+ ├── static/ # CSS classes
178
+ └── migrations/ # Database migrations
179
+ ```
180
+
181
+ ## Customization
182
+
183
+ ### Replacing Login Logo
184
+ To replace the default login logo, simply place your own `login_logo.webp` image in your project's static directory at `static/img/login_logo.webp`.
185
+
186
+
187
+ ## Version History
188
+
189
+ | Version | Changes |
190
+ |----------|---------|
191
+ | v1.0.0 | • Initial release as pip package |
192
+ | v1.0.1 | • Fixed a couple of new issues as a pip package |
193
+ | v1.0.2 | • Fixed the readme and building files |
194
+ | v1.0.3 | • Still getting the hang of this pip publish thing |
195
+ | v1.0.4 | • Honestly still messing with and trying settings and stuff out |
196
+ | v1.1.0 | • OK, finally a working seamless micro-users app |
197
+ | v1.1.1 | • Fixed an expolit where a staff member could disable the ADMIN user |
198
+ | v1.2.0 | • Added User Details view with specific user activity log |
199
+ | v1.2.1 | • Fixed a minor import bug |
200
+ | v1.2.2 | • Separated user detail view from table for consistency<br> • Optimized the new detail + log view for optimal compatibiliyy with users |
201
+ | v1.2.3 | • Fixed a couple of visual inconsistencies |
202
+ | v1.3.0 | • Patched a critical security permission issue<br> • Disabled ADMIN from being viewed/edited from all other members<br> • Fixed a crash when sorting with full_name<br> • Enabled Logging for all actions |
203
+ | v1.3.1 | • Corrected a misplaced code that caused a crash when editing profile |
204
+ | v1.3.2 | • Minor table modifications |
205
+ | v1.4.0 | • Redesigned Permissions UI (Grouped by App/Action) <br> • Added Global Bulk Permission Selectors <br> • Improved Arabic Localization for Permissions <br> • Optimized printing (hidden forms/buttons) <br> • Fixed various bugs and crashes |
206
+ | v1.4.1 | • Changed "Administrative User" translation to "Responsible User" (مستخدم مسؤول) <br> • Enforced custom sorting order for Permissions (View -> Add -> Change -> Other) |
207
+ | v1.5.0 | • Department Management (Modal-based CRUD)<br> • Department field implementation<br> • Template refactoring (partials/, profile/, users/ for logs)<br> • Verbose names for models |
208
+ | v1.6.0 | • **Automated Activity Logging**: dynamic logging for all CREATE/UPDATE/DELETE actions via Middleware & Signals<br> • **Refactor**: Renamed `Department` model to `Scope` (Scope Management)<br> • Removed manual logging requirement<br> • **Architecture**: Decoupled models, forms, and tables using dynamic imports and `apps.get_model` <br> • **Soft Delete**: Users are now marked as inactive with a timestamp instead of being permanently deleted<br> • **Activity Log**: Deleted users appear with a strikethrough<br> • **CSS Refactor**: Extracted and cleaned up styling with CSS variables<br> • **Login**: Refactored login page with separated JS/CSS and a new modern default logo |
209
+ | v1.6.1 | • **Theme Configuration**: Added `MICRO_USERS_THEME` setting for easy color customization <br> • **Bug Fixes**: Explicitly excluded unwanted columns (id, ip_address, user_agent) from Activity Log table <br> • **UI**: Improved Scope Manager button visibility |
210
+ | v1.6.2 | • **UI**: Improved some tooltips for buttons and descriptions |
211
+ | v1.6.3 | • **Bug Fixes**: Fixed a crash with table tooltips "disabled" |
212
+ | v1.7.0 | • **New Theme**: Complete visual overhaul with modern, consistent styling <br> • **Refactor**: Updated Login, Profile, and Detail templates for better UX <br> • **Feature**: Added Scope filter to Activity Logs (superuser only) <br> • **UX**: Clear button in filters now preserves current sort order |
213
+ | v1.7.1 | • **Bug Fixes**: Fixed login/next url was not being passed correctly |
214
+ | v1.8.0 | • **Permissions UI**: Complete redesign with App/Model-based grouping and hierarchical checkboxes<br>• **Aesthetics**: Applied modern glassmorphism theme to permission cards with interactive toggles<br>• **Security**: Implemented 3-level security logic (GM, SM, User) and "invisible" Superuser protection<br>• **Foolproofing**: Added self-editing protection for staff and scope enforcement for managers<br>• **Localization**: Fully translated system auth labels and metadata to Arabic |
215
+ | v1.8.1 | • **UI Refinement**: Swapped `Email` and `Phone` positions across all forms, tables, and detail views<br>• **Field Logic**: Set `Email` and `Phone` as optional (not required) for all users<br>• **Security**: Added `manage_staff` custom permission to restrict `is_staff` management to authorized managers only<br>• **Bug Fix**: Reserved `manage_staff` assignment power strictly for Superusers and fixed UI grouping for custom permissions |
216
+ | v1.8.2 | • **Login UX**: Enhanced login flow with auto-focus on username and improved "Enter to Submit" handling |
217
+ | v1.8.3 | • **CSP Compliance**: Added `nonce` attribute support to all inline and external script tags (Login, Permissions, Manage Users) for Content Security Policy compliance |
218
+ | v1.8.4 | • **Strict CSP**: Refactored inline JS event handlers to use Event Listeners, fully resolving CSP violation errors |
219
+ | v1.8.5 | • **Optional Scopes**: Added ability for Superusers to toggle Scope system ON/OFF via User Management interface |
220
+ | v1.8.6 | • **Strict CSP Repair**: Fixed remaining inline event handlers in User Management pages (`manage_users`, `scope_form`) that were violating CSP directives, moving all logic to external `manage_users.js` |
221
+ | v1.8.7 | • Fixed a couple of template tab title mismatches |
222
+ | v1.8.8 | • Fixed a couple of template content title mismatches and classes |
223
+ | v1.8.9 | • Fixed migrations |
224
+ | v1.9.0 | • **UI Overhaul**: Unified all buttons, and clssses to conform to themes, rounded corners, and improved spacing |
@@ -0,0 +1,192 @@
1
+ # Micro Users - Arabic Django User Management App
2
+
3
+ [![PyPI version](https://badge.fury.io/py/micro-users.svg)](https://pypi.org/project/micro-users/)
4
+
5
+ <p align="center">
6
+ <img src="https://raw.githubusercontent.com/debeski/micro-users/main/users/static/img/login_logo.webp" alt="Micro Users Login Logo" width="450"/>
7
+ </p>
8
+
9
+ **Arabic** lightweight, reusable Django app providing user management with abstract user, permissions, localization, and activity logging.
10
+
11
+ ## Requirements
12
+ - **Must be installed on a fresh database.**
13
+ - Python 3.11+
14
+ - Django 5.1+
15
+ - django-crispy-forms 2.4+
16
+ - django-tables2 2.7+
17
+ - django-filter 24.3+
18
+ - pillow 11.0+
19
+ - babel 2.1+
20
+
21
+ ## Features
22
+ - Custom AbstractUser model
23
+ - Scope Management System (Optional)
24
+ - Custom Grouped User permissions system
25
+ - Automatic Activity logging (login/logout, CRUD for all models)
26
+ - Specific User detail and log view
27
+ - Localization support
28
+ - Admin interface integration
29
+ - CRUD views and templates
30
+ - Filtering and tabulation
31
+ > *Future updates are planned to support dynamic language switching between RTL and LTR.*
32
+
33
+ ## Installation
34
+
35
+ ```bash
36
+ pip install git+https://github.com/debeski/micro-users.git
37
+ # OR
38
+ pip install micro-users
39
+ ```
40
+
41
+ ## Configuration
42
+
43
+ 1. Add to `INSTALLED_APPS`:
44
+ ```python
45
+ INSTALLED_APPS = [
46
+ 'users', # Preferably on top
47
+ 'django.contrib.admin',
48
+ 'django.contrib.auth',
49
+ ...
50
+ ]
51
+ ```
52
+
53
+ 2. Add Middleware in `settings.py` (Required for logging):
54
+ ```python
55
+ MIDDLEWARE = [
56
+ # ...
57
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
58
+ # ...
59
+ 'users.middleware.ActivityLogMiddleware', # Add this line
60
+ ]
61
+ ```
62
+
63
+ 3. Add Context Processor in `settings.py` (Optional, for `scope_enabled` variable in templates):
64
+ ```python
65
+ TEMPLATES = [
66
+ {
67
+ # ...
68
+ 'OPTIONS': {
69
+ 'context_processors': [
70
+ # ...
71
+ 'users.context_processors.scope_settings', # Add this line
72
+ ],
73
+ },
74
+ },
75
+ ]
76
+ ```
77
+
78
+ 4. Set custom user model in `settings.py`:
79
+ ```python
80
+ AUTH_USER_MODEL = 'users.CustomUser'
81
+ ```
82
+
83
+ 5. Include URLs in your main project folder `urls.py`:
84
+ ```python
85
+ urlpatterns = [
86
+ ...
87
+ path('manage/', include('users.urls')),
88
+ ]
89
+ ```
90
+
91
+ 6. Run migrations:
92
+ ```bash
93
+ python manage.py migrate users
94
+ ```
95
+
96
+ ## How to Use
97
+
98
+ Once configured, the app automatically handles user management and activity logging. Ensure your project has a `base.html` template in the root templates directory, as all user management templates extend it.
99
+
100
+ ### Activity Logging
101
+
102
+ The app provides a fully **automated** activity logging system. No manual configuration is required in your views.
103
+
104
+ - **Login/Logout**: Automatically tracked.
105
+ - **Create/Update/Delete**: Any change to any model in your app (including `Scope` and `User`) is automatically logged via Django Signals.
106
+ - **Log content**: Tracks the user, action type, model name, object ID, and timestamp.
107
+ - *Note*: `last_login` field updates are automatically filtered out to prevent redundant "Update" logs on login.
108
+
109
+ To view logs, navigate to `manage/logs/` or use the Django Admin interface ("حركات السجل").
110
+
111
+ ## Available URLs
112
+
113
+ All user management URLs are prefixed with `manage/` as configured above. Below is the complete list:
114
+
115
+ | URL Pattern | View/Function | Description |
116
+ |-------------|---------------|-------------|
117
+ | `manage/login/` | `auth_views.LoginView.as_view()` | User login |
118
+ | `manage/logout/` | `auth_views.LogoutView.as_view()` | User logout |
119
+ | `manage/users/` | `views.UserListView.as_view()` | List all users |
120
+ | `manage/users/create/` | `views.create_user` | Create new user |
121
+ | `manage/users/edit/<int:pk>/` | `views.edit_user` | Edit existing user |
122
+ | `manage/users/delete/<int:pk>/` | `views.delete_user` | Delete user |
123
+ | `manage/users/<int:pk>/` | `views.UserDetailView.as_view()` | View user details |
124
+ | `manage/profile` | `views.user_profile` | View current user profile |
125
+ | `manage/profile/edit/` | `views.edit_profile` | Edit current profile |
126
+ | `manage/logs/` | `views.UserActivityLogView.as_view()` | View activity logs |
127
+ | `manage/reset_password/<int:pk>/` | `views.reset_password` | Reset user password |
128
+ | `manage/scopes/manage/` | `views.manage_scopes` | Scope Manager (Modal) |
129
+
130
+ ## Structure
131
+ ```
132
+ users/
133
+ ├── views.py # CRUD operations
134
+ ├── urls.py # URL routing
135
+ ├── tables.py # User and Activity Log tables
136
+ ├── signals.py # Logging signals
137
+ ├── middleware.py # Request capture for signals
138
+ ├── models.py # User model, permissions, activity logs
139
+ ├── forms.py # Creation, edit,. etc.
140
+ ├── filter.py # Search filters
141
+ ├── apps.py # Permissions Localization
142
+ ├── admin.py # Admin UI integration
143
+ ├── __init__.py # Python init
144
+ ├── templates/ # HTML templates (includes partials)
145
+ ├── static/ # CSS classes
146
+ └── migrations/ # Database migrations
147
+ ```
148
+
149
+ ## Customization
150
+
151
+ ### Replacing Login Logo
152
+ To replace the default login logo, simply place your own `login_logo.webp` image in your project's static directory at `static/img/login_logo.webp`.
153
+
154
+
155
+ ## Version History
156
+
157
+ | Version | Changes |
158
+ |----------|---------|
159
+ | v1.0.0 | • Initial release as pip package |
160
+ | v1.0.1 | • Fixed a couple of new issues as a pip package |
161
+ | v1.0.2 | • Fixed the readme and building files |
162
+ | v1.0.3 | • Still getting the hang of this pip publish thing |
163
+ | v1.0.4 | • Honestly still messing with and trying settings and stuff out |
164
+ | v1.1.0 | • OK, finally a working seamless micro-users app |
165
+ | v1.1.1 | • Fixed an expolit where a staff member could disable the ADMIN user |
166
+ | v1.2.0 | • Added User Details view with specific user activity log |
167
+ | v1.2.1 | • Fixed a minor import bug |
168
+ | v1.2.2 | • Separated user detail view from table for consistency<br> • Optimized the new detail + log view for optimal compatibiliyy with users |
169
+ | v1.2.3 | • Fixed a couple of visual inconsistencies |
170
+ | v1.3.0 | • Patched a critical security permission issue<br> • Disabled ADMIN from being viewed/edited from all other members<br> • Fixed a crash when sorting with full_name<br> • Enabled Logging for all actions |
171
+ | v1.3.1 | • Corrected a misplaced code that caused a crash when editing profile |
172
+ | v1.3.2 | • Minor table modifications |
173
+ | v1.4.0 | • Redesigned Permissions UI (Grouped by App/Action) <br> • Added Global Bulk Permission Selectors <br> • Improved Arabic Localization for Permissions <br> • Optimized printing (hidden forms/buttons) <br> • Fixed various bugs and crashes |
174
+ | v1.4.1 | • Changed "Administrative User" translation to "Responsible User" (مستخدم مسؤول) <br> • Enforced custom sorting order for Permissions (View -> Add -> Change -> Other) |
175
+ | v1.5.0 | • Department Management (Modal-based CRUD)<br> • Department field implementation<br> • Template refactoring (partials/, profile/, users/ for logs)<br> • Verbose names for models |
176
+ | v1.6.0 | • **Automated Activity Logging**: dynamic logging for all CREATE/UPDATE/DELETE actions via Middleware & Signals<br> • **Refactor**: Renamed `Department` model to `Scope` (Scope Management)<br> • Removed manual logging requirement<br> • **Architecture**: Decoupled models, forms, and tables using dynamic imports and `apps.get_model` <br> • **Soft Delete**: Users are now marked as inactive with a timestamp instead of being permanently deleted<br> • **Activity Log**: Deleted users appear with a strikethrough<br> • **CSS Refactor**: Extracted and cleaned up styling with CSS variables<br> • **Login**: Refactored login page with separated JS/CSS and a new modern default logo |
177
+ | v1.6.1 | • **Theme Configuration**: Added `MICRO_USERS_THEME` setting for easy color customization <br> • **Bug Fixes**: Explicitly excluded unwanted columns (id, ip_address, user_agent) from Activity Log table <br> • **UI**: Improved Scope Manager button visibility |
178
+ | v1.6.2 | • **UI**: Improved some tooltips for buttons and descriptions |
179
+ | v1.6.3 | • **Bug Fixes**: Fixed a crash with table tooltips "disabled" |
180
+ | v1.7.0 | • **New Theme**: Complete visual overhaul with modern, consistent styling <br> • **Refactor**: Updated Login, Profile, and Detail templates for better UX <br> • **Feature**: Added Scope filter to Activity Logs (superuser only) <br> • **UX**: Clear button in filters now preserves current sort order |
181
+ | v1.7.1 | • **Bug Fixes**: Fixed login/next url was not being passed correctly |
182
+ | v1.8.0 | • **Permissions UI**: Complete redesign with App/Model-based grouping and hierarchical checkboxes<br>• **Aesthetics**: Applied modern glassmorphism theme to permission cards with interactive toggles<br>• **Security**: Implemented 3-level security logic (GM, SM, User) and "invisible" Superuser protection<br>• **Foolproofing**: Added self-editing protection for staff and scope enforcement for managers<br>• **Localization**: Fully translated system auth labels and metadata to Arabic |
183
+ | v1.8.1 | • **UI Refinement**: Swapped `Email` and `Phone` positions across all forms, tables, and detail views<br>• **Field Logic**: Set `Email` and `Phone` as optional (not required) for all users<br>• **Security**: Added `manage_staff` custom permission to restrict `is_staff` management to authorized managers only<br>• **Bug Fix**: Reserved `manage_staff` assignment power strictly for Superusers and fixed UI grouping for custom permissions |
184
+ | v1.8.2 | • **Login UX**: Enhanced login flow with auto-focus on username and improved "Enter to Submit" handling |
185
+ | v1.8.3 | • **CSP Compliance**: Added `nonce` attribute support to all inline and external script tags (Login, Permissions, Manage Users) for Content Security Policy compliance |
186
+ | v1.8.4 | • **Strict CSP**: Refactored inline JS event handlers to use Event Listeners, fully resolving CSP violation errors |
187
+ | v1.8.5 | • **Optional Scopes**: Added ability for Superusers to toggle Scope system ON/OFF via User Management interface |
188
+ | v1.8.6 | • **Strict CSP Repair**: Fixed remaining inline event handlers in User Management pages (`manage_users`, `scope_form`) that were violating CSP directives, moving all logic to external `manage_users.js` |
189
+ | v1.8.7 | • Fixed a couple of template tab title mismatches |
190
+ | v1.8.8 | • Fixed a couple of template content title mismatches and classes |
191
+ | v1.8.9 | • Fixed migrations |
192
+ | v1.9.0 | • **UI Overhaul**: Unified all buttons, and clssses to conform to themes, rounded corners, and improved spacing |
@@ -0,0 +1,224 @@
1
+ Metadata-Version: 2.1
2
+ Name: micro-users
3
+ Version: 1.9.0
4
+ Summary: Arabic Django user management app with abstract user, permissions, and activity logging
5
+ Home-page: https://github.com/debeski/micro-users
6
+ Author: DeBeski
7
+ Author-email: DeBeski <debeski1@gmail.com>
8
+ License: MIT
9
+ Project-URL: Homepage, https://github.com/debeski/micro-users
10
+ Keywords: django,users,permissions,authentication
11
+ Classifier: Framework :: Django
12
+ Classifier: Framework :: Django :: 5
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: License :: OSI Approved :: MIT License
22
+ Classifier: Operating System :: OS Independent
23
+ Requires-Python: >=3.9
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: Django>=5.1
27
+ Requires-Dist: django-crispy-forms>=2.4
28
+ Requires-Dist: django-tables2>=2.7
29
+ Requires-Dist: django-filter>=24.3
30
+ Requires-Dist: pillow>=11.0
31
+ Requires-Dist: babel>=2.1
32
+
33
+ # Micro Users - Arabic Django User Management App
34
+
35
+ [![PyPI version](https://badge.fury.io/py/micro-users.svg)](https://pypi.org/project/micro-users/)
36
+
37
+ <p align="center">
38
+ <img src="https://raw.githubusercontent.com/debeski/micro-users/main/users/static/img/login_logo.webp" alt="Micro Users Login Logo" width="450"/>
39
+ </p>
40
+
41
+ **Arabic** lightweight, reusable Django app providing user management with abstract user, permissions, localization, and activity logging.
42
+
43
+ ## Requirements
44
+ - **Must be installed on a fresh database.**
45
+ - Python 3.11+
46
+ - Django 5.1+
47
+ - django-crispy-forms 2.4+
48
+ - django-tables2 2.7+
49
+ - django-filter 24.3+
50
+ - pillow 11.0+
51
+ - babel 2.1+
52
+
53
+ ## Features
54
+ - Custom AbstractUser model
55
+ - Scope Management System (Optional)
56
+ - Custom Grouped User permissions system
57
+ - Automatic Activity logging (login/logout, CRUD for all models)
58
+ - Specific User detail and log view
59
+ - Localization support
60
+ - Admin interface integration
61
+ - CRUD views and templates
62
+ - Filtering and tabulation
63
+ > *Future updates are planned to support dynamic language switching between RTL and LTR.*
64
+
65
+ ## Installation
66
+
67
+ ```bash
68
+ pip install git+https://github.com/debeski/micro-users.git
69
+ # OR
70
+ pip install micro-users
71
+ ```
72
+
73
+ ## Configuration
74
+
75
+ 1. Add to `INSTALLED_APPS`:
76
+ ```python
77
+ INSTALLED_APPS = [
78
+ 'users', # Preferably on top
79
+ 'django.contrib.admin',
80
+ 'django.contrib.auth',
81
+ ...
82
+ ]
83
+ ```
84
+
85
+ 2. Add Middleware in `settings.py` (Required for logging):
86
+ ```python
87
+ MIDDLEWARE = [
88
+ # ...
89
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
90
+ # ...
91
+ 'users.middleware.ActivityLogMiddleware', # Add this line
92
+ ]
93
+ ```
94
+
95
+ 3. Add Context Processor in `settings.py` (Optional, for `scope_enabled` variable in templates):
96
+ ```python
97
+ TEMPLATES = [
98
+ {
99
+ # ...
100
+ 'OPTIONS': {
101
+ 'context_processors': [
102
+ # ...
103
+ 'users.context_processors.scope_settings', # Add this line
104
+ ],
105
+ },
106
+ },
107
+ ]
108
+ ```
109
+
110
+ 4. Set custom user model in `settings.py`:
111
+ ```python
112
+ AUTH_USER_MODEL = 'users.CustomUser'
113
+ ```
114
+
115
+ 5. Include URLs in your main project folder `urls.py`:
116
+ ```python
117
+ urlpatterns = [
118
+ ...
119
+ path('manage/', include('users.urls')),
120
+ ]
121
+ ```
122
+
123
+ 6. Run migrations:
124
+ ```bash
125
+ python manage.py migrate users
126
+ ```
127
+
128
+ ## How to Use
129
+
130
+ Once configured, the app automatically handles user management and activity logging. Ensure your project has a `base.html` template in the root templates directory, as all user management templates extend it.
131
+
132
+ ### Activity Logging
133
+
134
+ The app provides a fully **automated** activity logging system. No manual configuration is required in your views.
135
+
136
+ - **Login/Logout**: Automatically tracked.
137
+ - **Create/Update/Delete**: Any change to any model in your app (including `Scope` and `User`) is automatically logged via Django Signals.
138
+ - **Log content**: Tracks the user, action type, model name, object ID, and timestamp.
139
+ - *Note*: `last_login` field updates are automatically filtered out to prevent redundant "Update" logs on login.
140
+
141
+ To view logs, navigate to `manage/logs/` or use the Django Admin interface ("حركات السجل").
142
+
143
+ ## Available URLs
144
+
145
+ All user management URLs are prefixed with `manage/` as configured above. Below is the complete list:
146
+
147
+ | URL Pattern | View/Function | Description |
148
+ |-------------|---------------|-------------|
149
+ | `manage/login/` | `auth_views.LoginView.as_view()` | User login |
150
+ | `manage/logout/` | `auth_views.LogoutView.as_view()` | User logout |
151
+ | `manage/users/` | `views.UserListView.as_view()` | List all users |
152
+ | `manage/users/create/` | `views.create_user` | Create new user |
153
+ | `manage/users/edit/<int:pk>/` | `views.edit_user` | Edit existing user |
154
+ | `manage/users/delete/<int:pk>/` | `views.delete_user` | Delete user |
155
+ | `manage/users/<int:pk>/` | `views.UserDetailView.as_view()` | View user details |
156
+ | `manage/profile` | `views.user_profile` | View current user profile |
157
+ | `manage/profile/edit/` | `views.edit_profile` | Edit current profile |
158
+ | `manage/logs/` | `views.UserActivityLogView.as_view()` | View activity logs |
159
+ | `manage/reset_password/<int:pk>/` | `views.reset_password` | Reset user password |
160
+ | `manage/scopes/manage/` | `views.manage_scopes` | Scope Manager (Modal) |
161
+
162
+ ## Structure
163
+ ```
164
+ users/
165
+ ├── views.py # CRUD operations
166
+ ├── urls.py # URL routing
167
+ ├── tables.py # User and Activity Log tables
168
+ ├── signals.py # Logging signals
169
+ ├── middleware.py # Request capture for signals
170
+ ├── models.py # User model, permissions, activity logs
171
+ ├── forms.py # Creation, edit,. etc.
172
+ ├── filter.py # Search filters
173
+ ├── apps.py # Permissions Localization
174
+ ├── admin.py # Admin UI integration
175
+ ├── __init__.py # Python init
176
+ ├── templates/ # HTML templates (includes partials)
177
+ ├── static/ # CSS classes
178
+ └── migrations/ # Database migrations
179
+ ```
180
+
181
+ ## Customization
182
+
183
+ ### Replacing Login Logo
184
+ To replace the default login logo, simply place your own `login_logo.webp` image in your project's static directory at `static/img/login_logo.webp`.
185
+
186
+
187
+ ## Version History
188
+
189
+ | Version | Changes |
190
+ |----------|---------|
191
+ | v1.0.0 | • Initial release as pip package |
192
+ | v1.0.1 | • Fixed a couple of new issues as a pip package |
193
+ | v1.0.2 | • Fixed the readme and building files |
194
+ | v1.0.3 | • Still getting the hang of this pip publish thing |
195
+ | v1.0.4 | • Honestly still messing with and trying settings and stuff out |
196
+ | v1.1.0 | • OK, finally a working seamless micro-users app |
197
+ | v1.1.1 | • Fixed an expolit where a staff member could disable the ADMIN user |
198
+ | v1.2.0 | • Added User Details view with specific user activity log |
199
+ | v1.2.1 | • Fixed a minor import bug |
200
+ | v1.2.2 | • Separated user detail view from table for consistency<br> • Optimized the new detail + log view for optimal compatibiliyy with users |
201
+ | v1.2.3 | • Fixed a couple of visual inconsistencies |
202
+ | v1.3.0 | • Patched a critical security permission issue<br> • Disabled ADMIN from being viewed/edited from all other members<br> • Fixed a crash when sorting with full_name<br> • Enabled Logging for all actions |
203
+ | v1.3.1 | • Corrected a misplaced code that caused a crash when editing profile |
204
+ | v1.3.2 | • Minor table modifications |
205
+ | v1.4.0 | • Redesigned Permissions UI (Grouped by App/Action) <br> • Added Global Bulk Permission Selectors <br> • Improved Arabic Localization for Permissions <br> • Optimized printing (hidden forms/buttons) <br> • Fixed various bugs and crashes |
206
+ | v1.4.1 | • Changed "Administrative User" translation to "Responsible User" (مستخدم مسؤول) <br> • Enforced custom sorting order for Permissions (View -> Add -> Change -> Other) |
207
+ | v1.5.0 | • Department Management (Modal-based CRUD)<br> • Department field implementation<br> • Template refactoring (partials/, profile/, users/ for logs)<br> • Verbose names for models |
208
+ | v1.6.0 | • **Automated Activity Logging**: dynamic logging for all CREATE/UPDATE/DELETE actions via Middleware & Signals<br> • **Refactor**: Renamed `Department` model to `Scope` (Scope Management)<br> • Removed manual logging requirement<br> • **Architecture**: Decoupled models, forms, and tables using dynamic imports and `apps.get_model` <br> • **Soft Delete**: Users are now marked as inactive with a timestamp instead of being permanently deleted<br> • **Activity Log**: Deleted users appear with a strikethrough<br> • **CSS Refactor**: Extracted and cleaned up styling with CSS variables<br> • **Login**: Refactored login page with separated JS/CSS and a new modern default logo |
209
+ | v1.6.1 | • **Theme Configuration**: Added `MICRO_USERS_THEME` setting for easy color customization <br> • **Bug Fixes**: Explicitly excluded unwanted columns (id, ip_address, user_agent) from Activity Log table <br> • **UI**: Improved Scope Manager button visibility |
210
+ | v1.6.2 | • **UI**: Improved some tooltips for buttons and descriptions |
211
+ | v1.6.3 | • **Bug Fixes**: Fixed a crash with table tooltips "disabled" |
212
+ | v1.7.0 | • **New Theme**: Complete visual overhaul with modern, consistent styling <br> • **Refactor**: Updated Login, Profile, and Detail templates for better UX <br> • **Feature**: Added Scope filter to Activity Logs (superuser only) <br> • **UX**: Clear button in filters now preserves current sort order |
213
+ | v1.7.1 | • **Bug Fixes**: Fixed login/next url was not being passed correctly |
214
+ | v1.8.0 | • **Permissions UI**: Complete redesign with App/Model-based grouping and hierarchical checkboxes<br>• **Aesthetics**: Applied modern glassmorphism theme to permission cards with interactive toggles<br>• **Security**: Implemented 3-level security logic (GM, SM, User) and "invisible" Superuser protection<br>• **Foolproofing**: Added self-editing protection for staff and scope enforcement for managers<br>• **Localization**: Fully translated system auth labels and metadata to Arabic |
215
+ | v1.8.1 | • **UI Refinement**: Swapped `Email` and `Phone` positions across all forms, tables, and detail views<br>• **Field Logic**: Set `Email` and `Phone` as optional (not required) for all users<br>• **Security**: Added `manage_staff` custom permission to restrict `is_staff` management to authorized managers only<br>• **Bug Fix**: Reserved `manage_staff` assignment power strictly for Superusers and fixed UI grouping for custom permissions |
216
+ | v1.8.2 | • **Login UX**: Enhanced login flow with auto-focus on username and improved "Enter to Submit" handling |
217
+ | v1.8.3 | • **CSP Compliance**: Added `nonce` attribute support to all inline and external script tags (Login, Permissions, Manage Users) for Content Security Policy compliance |
218
+ | v1.8.4 | • **Strict CSP**: Refactored inline JS event handlers to use Event Listeners, fully resolving CSP violation errors |
219
+ | v1.8.5 | • **Optional Scopes**: Added ability for Superusers to toggle Scope system ON/OFF via User Management interface |
220
+ | v1.8.6 | • **Strict CSP Repair**: Fixed remaining inline event handlers in User Management pages (`manage_users`, `scope_form`) that were violating CSP directives, moving all logic to external `manage_users.js` |
221
+ | v1.8.7 | • Fixed a couple of template tab title mismatches |
222
+ | v1.8.8 | • Fixed a couple of template content title mismatches and classes |
223
+ | v1.8.9 | • Fixed migrations |
224
+ | v1.9.0 | • **UI Overhaul**: Unified all buttons, and clssses to conform to themes, rounded corners, and improved spacing |