micro-users 1.3.1__py3-none-any.whl → 1.3.2__py3-none-any.whl

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.

Potentially problematic release.


This version of micro-users might be problematic. Click here for more details.

@@ -0,0 +1,282 @@
1
+ Metadata-Version: 2.1
2
+ Name: micro-users
3
+ Version: 1.3.2
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
+ Keywords: django,users,permissions,authentication
10
+ Classifier: Framework :: Django
11
+ Classifier: Framework :: Django :: 5
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: License :: OSI Approved :: MIT License
21
+ Classifier: Operating System :: OS Independent
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: Django (>=5.1)
26
+ Requires-Dist: django-crispy-forms (>=2.4)
27
+ Requires-Dist: django-tables2 (>=2.7)
28
+ Requires-Dist: django-filter (>=24.3)
29
+ Requires-Dist: pillow (>=11.0)
30
+ Requires-Dist: babel (>=2.1)
31
+
32
+ # Micro Users - Arabic Django User Management App
33
+
34
+ [![PyPI version](https://badge.fury.io/py/micro-users.svg)](https://pypi.org/project/micro-users/)
35
+
36
+ **Arabic** lightweight, reusable Django app providing user management with abstract user, permissions, localization, and activity logging.
37
+
38
+ ## Requirements
39
+ - **Must be installed on a fresh database.**
40
+ - Python 3.11+
41
+ - Django 5.1+
42
+ - django-crispy-forms 2.4+
43
+ - django-tables2 2.7+
44
+ - django-filter 24.3+
45
+ - pillow 11.0+
46
+ - babel 2.1+
47
+
48
+ ## Features
49
+ - Custom AbstractUser model
50
+ - User permissions system
51
+ - Activity logging (login/logout, CRUD tracking)
52
+ - Specific User detail and log view *new*
53
+ - Localization support
54
+ - Admin interface integration
55
+ - CRUD views and templates
56
+ - Filtering and tabulation
57
+
58
+ ## Installation
59
+
60
+ ```bash
61
+ pip install git+https://github.com/debeski/micro-users.git
62
+ # OR local
63
+ pip install micro-users
64
+ ```
65
+
66
+ ## Configuration
67
+
68
+ 1. Add to `INSTALLED_APPS`:
69
+ ```python
70
+ INSTALLED_APPS = [
71
+ 'users', # Preferably on top
72
+ 'django.contrib.admin',
73
+ 'django.contrib.auth',
74
+ ...
75
+ ]
76
+ ```
77
+
78
+ 2. Set custom user model in settings.py:
79
+ ```python
80
+ AUTH_USER_MODEL = 'users.CustomUser'
81
+ ```
82
+
83
+ 3. Include URLs in your main project folder `urls.py`:
84
+ ```python
85
+ urlpatterns = [
86
+ ...
87
+ path('manage/', include('users.urls')),
88
+ ]
89
+ ```
90
+
91
+ 4. 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 automatically logs **LOGIN** and **LOGOUT** actions. For custom logging of other actions in your application, you can use the following helper functions:
103
+
104
+ #### Available Helper Functions
105
+
106
+ 1. **Get Client IP** - Extract the user's IP address from request:
107
+ ```python
108
+ from users.signals import get_client_ip
109
+
110
+ # Usage in views
111
+ ip_address = get_client_ip(request)
112
+ ```
113
+
114
+ 2. **Log User Action** - Create a reusable logging function:
115
+ ```python
116
+ from django.utils import timezone
117
+ from users.models import UserActivityLog
118
+ from users.signals import get_client_ip
119
+
120
+ def log_user_action(request, instance, action, model_name):
121
+ """
122
+ Logs a user action to the activity log.
123
+
124
+ Args:
125
+ request: HttpRequest object
126
+ instance: The model instance being acted upon
127
+ action: Action type (see ACTION_TYPES below)
128
+ model_name: Name of the model/entity (in Arabic or English)
129
+ """
130
+ UserActivityLog.objects.create(
131
+ user=request.user,
132
+ action=action,
133
+ model_name=model_name,
134
+ object_id=instance.pk,
135
+ number=instance.number if hasattr(instance, 'number') else '',
136
+ timestamp=timezone.now(),
137
+ ip_address=get_client_ip(request),
138
+ user_agent=request.META.get("HTTP_USER_AGENT", ""),
139
+ )
140
+ ```
141
+
142
+ #### Action Types Available
143
+ Use these constants when logging actions:
144
+
145
+ | Action Constant | Arabic Display | Description |
146
+ |-----------------|----------------|-------------|
147
+ | `'LOGIN'` | تسجيل دخـول | User login (auto-logged) |
148
+ | `'LOGOUT'` | تسجيل خـروج | User logout (auto-logged) |
149
+ | `'CREATE'` | انشـاء | Object creation |
150
+ | `'UPDATE'` | تعديـل | Object modification |
151
+ | `'DELETE'` | حــذف | Object deletion |
152
+ | `'VIEW'` | عـرض | Object viewing |
153
+ | `'DOWNLOAD'` | تحميل | File download |
154
+ | `'CONFIRM'` | تأكيـد | Action confirmation |
155
+ | `'REJECT'` | رفــض | Action rejection |
156
+ | `'RESET'` | اعادة ضبط | Password/Data reset |
157
+
158
+ #### Usage Examples
159
+
160
+ 1. **Logging a CREATE action**:
161
+ ```python
162
+ def create_document(request):
163
+ # ... create logic ...
164
+ document = Document.objects.create(...)
165
+
166
+ # Log the action
167
+ from users.models import UserActivityLog
168
+ from users.signals import get_client_ip
169
+
170
+ UserActivityLog.objects.create(
171
+ user=request.user,
172
+ action='CREATE',
173
+ model_name='وثيقة',
174
+ object_id=document.pk,
175
+ number=document.number,
176
+ ip_address=get_client_ip(request),
177
+ user_agent=request.META.get("HTTP_USER_AGENT", ""),
178
+ )
179
+ ```
180
+
181
+ 2. **Using the helper function**:
182
+ ```python
183
+ # Create a helper function in your app
184
+ def log_action(request, instance, action, model_name):
185
+ from users.models import UserActivityLog
186
+ from users.signals import get_client_ip
187
+ from django.utils import timezone
188
+
189
+ UserActivityLog.objects.create(
190
+ user=request.user,
191
+ action=action,
192
+ model_name=model_name,
193
+ object_id=instance.pk,
194
+ number=getattr(instance, 'number', ''),
195
+ timestamp=timezone.now(),
196
+ ip_address=get_client_ip(request),
197
+ user_agent=request.META.get("HTTP_USER_AGENT", ""),
198
+ )
199
+
200
+ # Usage in views
201
+ def update_order(request, order_id):
202
+ order = get_object_or_404(Order, pk=order_id)
203
+ # ... update logic ...
204
+ log_action(request, order, 'UPDATE', 'طلب')
205
+ ```
206
+
207
+ 3. **Logging without an instance** (for general actions):
208
+ ```python
209
+ def log_general_action(request, action, model_name, description=''):
210
+ from users.models import UserActivityLog
211
+ from users.signals import get_client_ip
212
+ from django.utils import timezone
213
+
214
+ UserActivityLog.objects.create(
215
+ user=request.user,
216
+ action=action,
217
+ model_name=model_name,
218
+ object_id=None,
219
+ number=description,
220
+ timestamp=timezone.now(),
221
+ ip_address=get_client_ip(request),
222
+ user_agent=request.META.get("HTTP_USER_AGENT", ""),
223
+ )
224
+
225
+ # Usage
226
+ log_general_action(request, 'CONFIRM', 'نظام', 'تم تأكيد الإعدادات')
227
+ ```
228
+
229
+ ## Available URLs
230
+
231
+ All user management URLs are prefixed with `manage/` as configured. Below is the complete list:
232
+
233
+ | URL Pattern | View/Function | Description |
234
+ |-------------|---------------|-------------|
235
+ | `manage/login/` | `auth_views.LoginView.as_view()` | User login |
236
+ | `manage/logout/` | `auth_views.LogoutView.as_view()` | User logout |
237
+ | `manage/users/` | `views.UserListView.as_view()` | List all users |
238
+ | `manage/users/create/` | `views.create_user` | Create new user |
239
+ | `manage/users/edit/<int:pk>/` | `views.edit_user` | Edit existing user |
240
+ | `manage/users/delete/<int:pk>/` | `views.delete_user` | Delete user |
241
+ | `manage/users/<int:pk>/` | `views.UserDetailView.as_view()` | View user details |
242
+ | `manage/profile` | `views.user_profile` | View current user profile |
243
+ | `manage/profile/edit/` | `views.edit_profile` | Edit current profile |
244
+ | `manage/logs/` | `views.UserActivityLogView.as_view()` | View activity logs |
245
+ | `manage/reset_password/<int:pk>/` | `views.reset_password` | Reset user password |
246
+
247
+ ## Structure
248
+ ```
249
+ users/
250
+ ├── views.py # CRUD operations
251
+ ├── urls.py # URL routing
252
+ ├── tables.py # User and Activity Log tables
253
+ ├── signals.py # Logging signals
254
+ ├── models.py # User model, permissions, activity logs
255
+ ├── forms.py # Creation, edit,. etc.
256
+ ├── filter.py # Search filters
257
+ ├── apps.py # Permissions Localization
258
+ ├── admin.py # Admin UI integration
259
+ ├── __init__.py # Python init
260
+ ├── templates/ # HTML templates
261
+ ├── static/ # CSS classes
262
+ └── migrations/ # Database migrations
263
+ ```
264
+
265
+ ## Version History
266
+
267
+ | Version | Changes |
268
+ |----------|---------|
269
+ | v1.0.0 | • Initial release as pip package |
270
+ | v1.0.1 | • Fixed a couple of new issues as a pip package |
271
+ | v1.0.2 | • Fixed the readme and building files |
272
+ | v1.0.3 | • Still getting the hang of this pip publish thing |
273
+ | v1.0.4 | • Honestly still messing with and trying settings and stuff out |
274
+ | v1.1.0 | • OK, finally a working seamless micro-users app |
275
+ | v1.1.1 | • Fixed an expolit where a staff member could disable the ADMIN user |
276
+ | v1.2.0 | • Added User Details view with specific user activity log |
277
+ | v1.2.1 | • Fixed a minor import bug |
278
+ | v1.2.3 | • Separated user detail view from table for consistency<br> • Optimized the new detail + log view for optimal compatibiliyy with users |
279
+ | v1.2.4 | • Fixed a couple of visual inconsistencies |
280
+ | 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 |
281
+ | v1.3.1 | • Corrected a misplaced code that caused a crash when editing profile |
282
+ | v1.3.2 | • Minor table modifications |
@@ -5,7 +5,7 @@ users/filters.py,sha256=neOdbyOSYVQXAQ2vKAW-0bcj7KIh9xc8UboHTlaZU4Q,4785
5
5
  users/forms.py,sha256=GHC8pFm2i9PD3MVaakrgMXEszsBrXieHq7DYiAfo8Fw,14977
6
6
  users/models.py,sha256=V_SIyGGq2w_bww7YufMjqXMSKN1u9CkSMPuOLiwPjtc,2100
7
7
  users/signals.py,sha256=5Kd3KyfPT6740rvwZj4vy1yXsmjVhmaQ__RB8p5R5aE,1336
8
- users/tables.py,sha256=WwC7BMpzNrcfEatJj6gHMP8k_FGqer-Zfn9vZRB7kZo,2196
8
+ users/tables.py,sha256=2HiDXa_4Hq1at86vfbhg1U3NobMjMWXTVQIJz3AizmQ,2088
9
9
  users/urls.py,sha256=FwQ9GVOBRQ4iXQ9UyLFI0aEAga0d5qL_miPNpmFPA-Q,1022
10
10
  users/views.py,sha256=oJLsr_G7TJP3Y6lRdkoP2oNVGe8tYD3x8I4ARO_iDA8,8730
11
11
  users/migrations/0001_initial.py,sha256=lx9sSKS-lxHhI6gelVH52NOkwqEMJ32TvOJUn9zaOXM,4709
@@ -21,8 +21,8 @@ users/templates/users/profile_edit.html,sha256=L9DUHlQHG-PmxwxBbSjgPk1dEmy0spPi6
21
21
  users/templates/users/user_actions.html,sha256=J44-sn0fMbLUWjdtlcf5YhgT5OYRykr1mFkeVXoI1ew,1543
22
22
  users/templates/users/user_detail.html,sha256=QkJ-6jdtUdi8mM-V_MzqYcdoEkzXEsIeFMliNjgIOsc,2053
23
23
  users/templates/users/user_form.html,sha256=jcyI7OQZOY4ue4DajPtfjAt2SmAYO5ZgHNOqTp2-FO0,1352
24
- micro_users-1.3.1.dist-info/LICENSE,sha256=Fco89ULLSSxKkC2KKnx57SaT0R7WOkZfuk8IYcGiN50,1063
25
- micro_users-1.3.1.dist-info/METADATA,sha256=IdsBDJU5IATuaw3bbwJyapchgPYJo2itC_-SnIZfubA,4363
26
- micro_users-1.3.1.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
27
- micro_users-1.3.1.dist-info/top_level.txt,sha256=tWT24ZcWau2wrlbpU_h3mP2jRukyLaVYiyHBuOezpLQ,6
28
- micro_users-1.3.1.dist-info/RECORD,,
24
+ micro_users-1.3.2.dist-info/LICENSE,sha256=Fco89ULLSSxKkC2KKnx57SaT0R7WOkZfuk8IYcGiN50,1063
25
+ micro_users-1.3.2.dist-info/METADATA,sha256=ov27iIs5nPtYsDN6RZVro1vm3SRGwSn0qaaXufBKrdA,9713
26
+ micro_users-1.3.2.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
27
+ micro_users-1.3.2.dist-info/top_level.txt,sha256=tWT24ZcWau2wrlbpU_h3mP2jRukyLaVYiyHBuOezpLQ,6
28
+ micro_users-1.3.2.dist-info/RECORD,,
users/tables.py CHANGED
@@ -1,5 +1,3 @@
1
- # Imports of the required python modules and libraries
2
- ######################################################
3
1
  import django_tables2 as tables
4
2
  from django.contrib.auth import get_user_model
5
3
  from .models import UserActivityLog
@@ -9,7 +7,11 @@ User = get_user_model() # Use custom user model
9
7
  class UserTable(tables.Table):
10
8
  username = tables.Column(verbose_name="اسم المستخدم")
11
9
  email = tables.Column(verbose_name="البريد الالكتروني")
12
- full_name = tables.Column(verbose_name="الاسم بالكامل", orderable=False,)
10
+ full_name = tables.Column(
11
+ verbose_name="الاسم الكامل",
12
+ accessor='user.full_name',
13
+ order_by='user__first_name'
14
+ )
13
15
  is_staff = tables.BooleanColumn(verbose_name="مسؤول")
14
16
  is_active = tables.BooleanColumn(verbose_name="نشط")
15
17
  last_login = tables.DateColumn(
@@ -22,7 +24,6 @@ class UserTable(tables.Table):
22
24
  orderable=False,
23
25
  verbose_name=''
24
26
  )
25
-
26
27
  class Meta:
27
28
  model = User
28
29
  template_name = "django_tables2/bootstrap5.html"
@@ -30,13 +31,12 @@ class UserTable(tables.Table):
30
31
  attrs = {'class': 'table table-hover align-middle'}
31
32
 
32
33
  class UserActivityLogTable(tables.Table):
33
- user = tables.Column(verbose_name="اسم الدخول")
34
34
  timestamp = tables.DateColumn(
35
35
  format="H:i Y-m-d ", # This is the format you want for the timestamp
36
36
  verbose_name="وقت العملية"
37
37
  )
38
38
  full_name = tables.Column(
39
- verbose_name="الاسم بالكامل",
39
+ verbose_name="الاسم الكامل",
40
40
  accessor='user.full_name',
41
41
  order_by='user__first_name'
42
42
  )
@@ -1,133 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: micro-users
3
- Version: 1.3.1
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
- Keywords: django,users,permissions,authentication
10
- Classifier: Framework :: Django
11
- Classifier: Framework :: Django :: 5
12
- Classifier: Programming Language :: Python :: 3
13
- Classifier: Programming Language :: Python :: 3.8
14
- Classifier: Programming Language :: Python :: 3.9
15
- Classifier: Programming Language :: Python :: 3.10
16
- Classifier: Programming Language :: Python :: 3.11
17
- Classifier: Programming Language :: Python :: 3.12
18
- Classifier: Programming Language :: Python :: 3.13
19
- Classifier: Programming Language :: Python :: 3.14
20
- Classifier: License :: OSI Approved :: MIT License
21
- Classifier: Operating System :: OS Independent
22
- Requires-Python: >=3.9
23
- Description-Content-Type: text/markdown
24
- License-File: LICENSE
25
- Requires-Dist: Django (>=5.1)
26
- Requires-Dist: django-crispy-forms (>=2.4)
27
- Requires-Dist: django-tables2 (>=2.7)
28
- Requires-Dist: django-filter (>=24.3)
29
- Requires-Dist: pillow (>=11.0)
30
- Requires-Dist: babel (>=2.1)
31
-
32
- # Micro Users - Arabic Django User Management App
33
-
34
- [![PyPI version](https://badge.fury.io/py/micro-users.svg)](https://pypi.org/project/micro-users/)
35
-
36
- **Arabic** lightweight, reusable Django app providing user management with abstract user, permissions, localization, and activity logging.
37
-
38
-
39
- ## Requirements
40
- - **Must be installed on a fresh database.**
41
- - Python 3.11+
42
- - Django 5.1+
43
- - django-crispy-forms 2.4+
44
- - django-tables2 2.7+
45
- - django-filter 24.3+
46
- - pillow 11.0+
47
- - babel 2.1+
48
-
49
-
50
- ## Features
51
- - Custom AbstractUser model
52
- - User permissions system
53
- - Activity logging (login/logout, CRUD tracking)
54
- - Specific User detail and log view *new*
55
- - Localization support
56
- - Admin interface integration
57
- - CRUD views and templates
58
- - Filtering and tabulation
59
-
60
- ## Installation
61
-
62
- ```bash
63
- pip install git+https://github.com/debeski/micro-users.git
64
- # OR local
65
- pip install micro-users
66
- ```
67
-
68
- ## Configuration
69
-
70
- 1. Add to `INSTALLED_APPS`:
71
- ```python
72
- INSTALLED_APPS = [
73
- 'users', # Preferably on top
74
- 'django.contrib.admin',
75
- 'django.contrib.auth',
76
- ...
77
- ]
78
- ```
79
-
80
- 2. Set custom user model in settings.py:
81
- ```python
82
- AUTH_USER_MODEL = 'users.CustomUser'
83
- ```
84
-
85
- 3. Include URLs in your main project folder `urls.py`:
86
- ```python
87
- urlpatterns = [
88
- ...
89
- path('manage/', include('users.urls')),
90
- ]
91
- ```
92
-
93
- 4. Run migrations:
94
- ```bash
95
- python manage.py migrate users
96
- ```
97
-
98
-
99
- ## Structure
100
- ```
101
- users/
102
- ├── views.py # CRUD operations
103
- ├── urls.py # URL routing
104
- ├── tables.py # User and Activity Log tables
105
- ├── signals.py # Logging signals
106
- ├── models.py # User model, permissions, activity logs
107
- ├── forms.py # Creation, edit,. etc.
108
- ├── filter.py # Search filters
109
- ├── apps.py # Permissions Localization
110
- ├── admin.py # Admin UI integration
111
- ├── __init__.py # Python init
112
- ├── templates/ # HTML templates
113
- ├── static/ # CSS classes
114
- └── migrations/ # Database migrations
115
- ```
116
-
117
- ## Version History
118
-
119
- | Version | Changes |
120
- |----------|---------|
121
- | v1.0.0 | • Initial release as pip package |
122
- | v1.0.1 | • Fixed a couple of new issues as a pip package |
123
- | v1.0.2 | • Fixed the readme and building files |
124
- | v1.0.3 | • Still getting the hang of this pip publish thing |
125
- | v1.0.4 | • Honestly still messing with and trying settings and stuff out |
126
- | v1.1.0 | • OK, finally a working seamless micro-users app |
127
- | v1.1.1 | • Fixed a bug where a staff member can edit the admin details |
128
- | v1.2.0 | • Added User Details view with specific user activity log |
129
- | v1.2.1 | • Fixed a minor import bug |
130
- | v1.2.3 | • Separated user detail view from table for consistency<br> • Optimized the new detail + log view for optimal compatibiliyy with users |
131
- | v1.2.4 | • Fixed a couple of visual inconsistencies |
132
- | v1.3.0 | • Patched a critical security permission issue<br> • Disabled ADMIN from being viewed/edited from other staff members<br> • Fixed an issue when sorting with full_name<br> • Enabled Logging for all actions |
133
- | v1.3.1 | • replaced a misplaced code that caused a crash when editing profile |