micro-users 1.0.1__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.
Potentially problematic release.
This version of micro-users might be problematic. Click here for more details.
- micro_users-1.0.1/LICENSE +21 -0
- micro_users-1.0.1/MANIFEST.in +19 -0
- micro_users-1.0.1/PKG-INFO +99 -0
- micro_users-1.0.1/README.md +70 -0
- micro_users-1.0.1/micro_users.egg-info/PKG-INFO +99 -0
- micro_users-1.0.1/micro_users.egg-info/SOURCES.txt +29 -0
- micro_users-1.0.1/micro_users.egg-info/dependency_links.txt +1 -0
- micro_users-1.0.1/micro_users.egg-info/requires.txt +6 -0
- micro_users-1.0.1/micro_users.egg-info/top_level.txt +1 -0
- micro_users-1.0.1/pyproject.toml +51 -0
- micro_users-1.0.1/setup.cfg +4 -0
- micro_users-1.0.1/setup.py +39 -0
- micro_users-1.0.1/users/__init__.py +0 -0
- micro_users-1.0.1/users/admin.py +18 -0
- micro_users-1.0.1/users/apps.py +30 -0
- micro_users-1.0.1/users/filters.py +120 -0
- micro_users-1.0.1/users/forms.py +364 -0
- micro_users-1.0.1/users/migrations/__init__.py +0 -0
- micro_users-1.0.1/users/models.py +40 -0
- micro_users-1.0.1/users/signals.py +41 -0
- micro_users-1.0.1/users/static/css/login.css +134 -0
- micro_users-1.0.1/users/tables.py +40 -0
- micro_users-1.0.1/users/templates/registration/login.html +115 -0
- micro_users-1.0.1/users/templates/user_activity_log.html +22 -0
- micro_users-1.0.1/users/templates/users/manage_users.html +73 -0
- micro_users-1.0.1/users/templates/users/profile.html +63 -0
- micro_users-1.0.1/users/templates/users/profile_edit.html +77 -0
- micro_users-1.0.1/users/templates/users/user_actions.html +29 -0
- micro_users-1.0.1/users/templates/users/user_form.html +37 -0
- micro_users-1.0.1/users/urls.py +18 -0
- micro_users-1.0.1/users/views.py +198 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 DeBeski
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Include the README so PyPI shows your long description
|
|
2
|
+
include README.md
|
|
3
|
+
|
|
4
|
+
# Include the license
|
|
5
|
+
include LICENSE
|
|
6
|
+
|
|
7
|
+
# Include all files inside the users package
|
|
8
|
+
recursive-include users *
|
|
9
|
+
|
|
10
|
+
# If you have templates inside the users app
|
|
11
|
+
recursive-include users/templates *
|
|
12
|
+
|
|
13
|
+
# If you have static files
|
|
14
|
+
recursive-include users/static *
|
|
15
|
+
|
|
16
|
+
# Make sure no unnecessary Python cache files are included
|
|
17
|
+
exclude *.pyc
|
|
18
|
+
exclude __pycache__/
|
|
19
|
+
recursive-exclude * __pycache__ *.pyc *.pyo
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: micro_users
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: 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: License :: OSI Approved :: MIT License
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Requires-Python: >=3.9
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: Django>=5.17
|
|
24
|
+
Requires-Dist: django-crispy-forms>=2.4
|
|
25
|
+
Requires-Dist: django-tables2>=2.7.5
|
|
26
|
+
Requires-Dist: django-filter>=25.1
|
|
27
|
+
Requires-Dist: pillow>=11.0
|
|
28
|
+
Requires-Dist: babel>=2.1
|
|
29
|
+
|
|
30
|
+
# Micro Users - Django User Management App
|
|
31
|
+
|
|
32
|
+
[](https://pypi.org/project/micro-users/)
|
|
33
|
+
|
|
34
|
+
A lightweight, reusable Django app providing user management with abstract user, permissions, localization, and activity logging.
|
|
35
|
+
|
|
36
|
+
## Features
|
|
37
|
+
- Custom AbstractUser model
|
|
38
|
+
- User permissions system
|
|
39
|
+
- Activity logging (login/logout tracking)
|
|
40
|
+
- Localization support
|
|
41
|
+
- Admin interface integration
|
|
42
|
+
- CRUD views and templates
|
|
43
|
+
- Filtering and tabulation
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install git+https://github.com/debeski/micro-users.git
|
|
49
|
+
# OR local
|
|
50
|
+
pip install micro-users
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Configuration
|
|
54
|
+
|
|
55
|
+
1. Add to `INSTALLED_APPS`:
|
|
56
|
+
```python
|
|
57
|
+
INSTALLED_APPS = [
|
|
58
|
+
...
|
|
59
|
+
'django_tables2',
|
|
60
|
+
'django_filters',
|
|
61
|
+
'crispy_forms',
|
|
62
|
+
'users', # Add this
|
|
63
|
+
]
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
2. Set custom user model in settings.py:
|
|
67
|
+
```python
|
|
68
|
+
AUTH_USER_MODEL = 'users.User'
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
3. Include URLs in your main project folder `urls.py`:
|
|
72
|
+
```python
|
|
73
|
+
urlpatterns = [
|
|
74
|
+
...
|
|
75
|
+
path('users/', include('users.urls')),
|
|
76
|
+
]
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
4. make migrations and migrate:
|
|
80
|
+
```bash
|
|
81
|
+
python manage.py makemigrations users
|
|
82
|
+
python manage.py migrate users
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Requirements
|
|
86
|
+
- Python 3.9+
|
|
87
|
+
- Django 5.1+
|
|
88
|
+
- See setup.py for full dependencies
|
|
89
|
+
|
|
90
|
+
## Structure
|
|
91
|
+
```
|
|
92
|
+
users/
|
|
93
|
+
├── models.py # User model, permissions, activity logs
|
|
94
|
+
├── views.py # CRUD operations
|
|
95
|
+
├── urls.py # URL routing
|
|
96
|
+
├── admin.py # Admin integration
|
|
97
|
+
├── templates/ # HTML templates
|
|
98
|
+
└── migrations/ # Database migrations
|
|
99
|
+
```
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Micro Users - Django User Management App
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/micro-users/)
|
|
4
|
+
|
|
5
|
+
A lightweight, reusable Django app providing user management with abstract user, permissions, localization, and activity logging.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
- Custom AbstractUser model
|
|
9
|
+
- User permissions system
|
|
10
|
+
- Activity logging (login/logout tracking)
|
|
11
|
+
- Localization support
|
|
12
|
+
- Admin interface integration
|
|
13
|
+
- CRUD views and templates
|
|
14
|
+
- Filtering and tabulation
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install git+https://github.com/debeski/micro-users.git
|
|
20
|
+
# OR local
|
|
21
|
+
pip install micro-users
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Configuration
|
|
25
|
+
|
|
26
|
+
1. Add to `INSTALLED_APPS`:
|
|
27
|
+
```python
|
|
28
|
+
INSTALLED_APPS = [
|
|
29
|
+
...
|
|
30
|
+
'django_tables2',
|
|
31
|
+
'django_filters',
|
|
32
|
+
'crispy_forms',
|
|
33
|
+
'users', # Add this
|
|
34
|
+
]
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
2. Set custom user model in settings.py:
|
|
38
|
+
```python
|
|
39
|
+
AUTH_USER_MODEL = 'users.User'
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
3. Include URLs in your main project folder `urls.py`:
|
|
43
|
+
```python
|
|
44
|
+
urlpatterns = [
|
|
45
|
+
...
|
|
46
|
+
path('users/', include('users.urls')),
|
|
47
|
+
]
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
4. make migrations and migrate:
|
|
51
|
+
```bash
|
|
52
|
+
python manage.py makemigrations users
|
|
53
|
+
python manage.py migrate users
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Requirements
|
|
57
|
+
- Python 3.9+
|
|
58
|
+
- Django 5.1+
|
|
59
|
+
- See setup.py for full dependencies
|
|
60
|
+
|
|
61
|
+
## Structure
|
|
62
|
+
```
|
|
63
|
+
users/
|
|
64
|
+
├── models.py # User model, permissions, activity logs
|
|
65
|
+
├── views.py # CRUD operations
|
|
66
|
+
├── urls.py # URL routing
|
|
67
|
+
├── admin.py # Admin integration
|
|
68
|
+
├── templates/ # HTML templates
|
|
69
|
+
└── migrations/ # Database migrations
|
|
70
|
+
```
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: micro-users
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: 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: License :: OSI Approved :: MIT License
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Requires-Python: >=3.9
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: Django>=5.17
|
|
24
|
+
Requires-Dist: django-crispy-forms>=2.4
|
|
25
|
+
Requires-Dist: django-tables2>=2.7.5
|
|
26
|
+
Requires-Dist: django-filter>=25.1
|
|
27
|
+
Requires-Dist: pillow>=11.0
|
|
28
|
+
Requires-Dist: babel>=2.1
|
|
29
|
+
|
|
30
|
+
# Micro Users - Django User Management App
|
|
31
|
+
|
|
32
|
+
[](https://pypi.org/project/micro-users/)
|
|
33
|
+
|
|
34
|
+
A lightweight, reusable Django app providing user management with abstract user, permissions, localization, and activity logging.
|
|
35
|
+
|
|
36
|
+
## Features
|
|
37
|
+
- Custom AbstractUser model
|
|
38
|
+
- User permissions system
|
|
39
|
+
- Activity logging (login/logout tracking)
|
|
40
|
+
- Localization support
|
|
41
|
+
- Admin interface integration
|
|
42
|
+
- CRUD views and templates
|
|
43
|
+
- Filtering and tabulation
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install git+https://github.com/debeski/micro-users.git
|
|
49
|
+
# OR local
|
|
50
|
+
pip install micro-users
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Configuration
|
|
54
|
+
|
|
55
|
+
1. Add to `INSTALLED_APPS`:
|
|
56
|
+
```python
|
|
57
|
+
INSTALLED_APPS = [
|
|
58
|
+
...
|
|
59
|
+
'django_tables2',
|
|
60
|
+
'django_filters',
|
|
61
|
+
'crispy_forms',
|
|
62
|
+
'users', # Add this
|
|
63
|
+
]
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
2. Set custom user model in settings.py:
|
|
67
|
+
```python
|
|
68
|
+
AUTH_USER_MODEL = 'users.User'
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
3. Include URLs in your main project folder `urls.py`:
|
|
72
|
+
```python
|
|
73
|
+
urlpatterns = [
|
|
74
|
+
...
|
|
75
|
+
path('users/', include('users.urls')),
|
|
76
|
+
]
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
4. make migrations and migrate:
|
|
80
|
+
```bash
|
|
81
|
+
python manage.py makemigrations users
|
|
82
|
+
python manage.py migrate users
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Requirements
|
|
86
|
+
- Python 3.9+
|
|
87
|
+
- Django 5.1+
|
|
88
|
+
- See setup.py for full dependencies
|
|
89
|
+
|
|
90
|
+
## Structure
|
|
91
|
+
```
|
|
92
|
+
users/
|
|
93
|
+
├── models.py # User model, permissions, activity logs
|
|
94
|
+
├── views.py # CRUD operations
|
|
95
|
+
├── urls.py # URL routing
|
|
96
|
+
├── admin.py # Admin integration
|
|
97
|
+
├── templates/ # HTML templates
|
|
98
|
+
└── migrations/ # Database migrations
|
|
99
|
+
```
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
setup.py
|
|
6
|
+
micro_users.egg-info/PKG-INFO
|
|
7
|
+
micro_users.egg-info/SOURCES.txt
|
|
8
|
+
micro_users.egg-info/dependency_links.txt
|
|
9
|
+
micro_users.egg-info/requires.txt
|
|
10
|
+
micro_users.egg-info/top_level.txt
|
|
11
|
+
users/__init__.py
|
|
12
|
+
users/admin.py
|
|
13
|
+
users/apps.py
|
|
14
|
+
users/filters.py
|
|
15
|
+
users/forms.py
|
|
16
|
+
users/models.py
|
|
17
|
+
users/signals.py
|
|
18
|
+
users/tables.py
|
|
19
|
+
users/urls.py
|
|
20
|
+
users/views.py
|
|
21
|
+
users/migrations/__init__.py
|
|
22
|
+
users/static/css/login.css
|
|
23
|
+
users/templates/user_activity_log.html
|
|
24
|
+
users/templates/registration/login.html
|
|
25
|
+
users/templates/users/manage_users.html
|
|
26
|
+
users/templates/users/profile.html
|
|
27
|
+
users/templates/users/profile_edit.html
|
|
28
|
+
users/templates/users/user_actions.html
|
|
29
|
+
users/templates/users/user_form.html
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
users
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = [
|
|
3
|
+
"setuptools<69", # ensures Metadata-Version <= 2.2
|
|
4
|
+
"wheel<0.41"
|
|
5
|
+
]
|
|
6
|
+
build-backend = "setuptools.build_meta"
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
[project]
|
|
10
|
+
name = "micro_users"
|
|
11
|
+
version = "1.0.1"
|
|
12
|
+
description = "Django user management app with abstract user, permissions, and activity logging"
|
|
13
|
+
readme = "README.md"
|
|
14
|
+
requires-python = ">=3.9"
|
|
15
|
+
license = { text = "MIT" }
|
|
16
|
+
authors = [
|
|
17
|
+
{ name = "DeBeski", email = "debeski1@gmail.com" }
|
|
18
|
+
]
|
|
19
|
+
keywords = ["django", "users", "permissions", "authentication"]
|
|
20
|
+
|
|
21
|
+
# Dependencies
|
|
22
|
+
dependencies = [
|
|
23
|
+
"Django>=5.17",
|
|
24
|
+
"django-crispy-forms>=2.4",
|
|
25
|
+
"django-tables2>=2.7.5",
|
|
26
|
+
"django-filter>=25.1",
|
|
27
|
+
"pillow>=11.0",
|
|
28
|
+
"babel>=2.1",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
# Classifiers
|
|
32
|
+
classifiers = [
|
|
33
|
+
"Framework :: Django",
|
|
34
|
+
"Framework :: Django :: 5",
|
|
35
|
+
"Programming Language :: Python :: 3",
|
|
36
|
+
"Programming Language :: Python :: 3.8",
|
|
37
|
+
"Programming Language :: Python :: 3.9",
|
|
38
|
+
"Programming Language :: Python :: 3.10",
|
|
39
|
+
"Programming Language :: Python :: 3.11",
|
|
40
|
+
"Programming Language :: Python :: 3.12",
|
|
41
|
+
"License :: OSI Approved :: MIT License",
|
|
42
|
+
"Operating System :: OS Independent",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
# Tell setuptools which packages to include
|
|
46
|
+
[tool.setuptools.packages.find]
|
|
47
|
+
include = ["users"]
|
|
48
|
+
|
|
49
|
+
# Include static/templates files (equivalent to include_package_data=True)
|
|
50
|
+
[tool.setuptools]
|
|
51
|
+
include-package-data = true
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from setuptools import setup
|
|
2
|
+
|
|
3
|
+
with open("README.md", "r", encoding="utf-8") as fh:
|
|
4
|
+
long_description = fh.read()
|
|
5
|
+
|
|
6
|
+
setup(
|
|
7
|
+
name="micro_users",
|
|
8
|
+
version="1.0.1",
|
|
9
|
+
author="DeBeski",
|
|
10
|
+
author_email="debeski1@gmail.com",
|
|
11
|
+
description="Django user management app with abstract user, permissions, and activity logging",
|
|
12
|
+
long_description=long_description,
|
|
13
|
+
long_description_content_type="text/markdown",
|
|
14
|
+
url="https://github.com/debeski/micro_users",
|
|
15
|
+
packages=["users"],
|
|
16
|
+
include_package_data=True,
|
|
17
|
+
classifiers=[
|
|
18
|
+
"Framework :: Django",
|
|
19
|
+
"Framework :: Django :: 5",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.8",
|
|
22
|
+
"Programming Language :: Python :: 3.9",
|
|
23
|
+
"Programming Language :: Python :: 3.10",
|
|
24
|
+
"Programming Language :: Python :: 3.11",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
|
+
"License :: OSI Approved :: MIT License", # MIT license
|
|
27
|
+
"Operating System :: OS Independent",
|
|
28
|
+
],
|
|
29
|
+
python_requires=">=3.9",
|
|
30
|
+
install_requires=[
|
|
31
|
+
"Django>=5.17",
|
|
32
|
+
"django-crispy-forms>=2.4",
|
|
33
|
+
"django-tables2>=2.7.5",
|
|
34
|
+
"django-filter>=25.1",
|
|
35
|
+
"pillow>=11.0",
|
|
36
|
+
"babel>=2.1",
|
|
37
|
+
],
|
|
38
|
+
license="MIT",
|
|
39
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Imports of the required python modules and libraries
|
|
2
|
+
######################################################
|
|
3
|
+
from django.contrib import admin
|
|
4
|
+
from django.contrib.auth.admin import UserAdmin
|
|
5
|
+
from django.contrib.auth import get_user_model
|
|
6
|
+
from django.contrib.auth.models import Group
|
|
7
|
+
|
|
8
|
+
User = get_user_model()
|
|
9
|
+
|
|
10
|
+
class CustomUserAdmin(UserAdmin):
|
|
11
|
+
model = User
|
|
12
|
+
list_display = ['username', 'email', 'is_staff', 'is_active', 'phone', 'occupation']
|
|
13
|
+
list_filter = ['is_staff', 'is_active']
|
|
14
|
+
search_fields = ['username', 'email']
|
|
15
|
+
ordering = ['username']
|
|
16
|
+
|
|
17
|
+
admin.site.register(User, CustomUserAdmin)
|
|
18
|
+
admin.site.unregister(Group)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Imports of the required python modules and libraries
|
|
2
|
+
######################################################
|
|
3
|
+
from django.apps import AppConfig
|
|
4
|
+
|
|
5
|
+
def custom_permission_str(self):
|
|
6
|
+
"""Custom Arabic translations for Django permissions"""
|
|
7
|
+
model_name = str(self.content_type)
|
|
8
|
+
permission_name = str(self.name)
|
|
9
|
+
|
|
10
|
+
# Translate default permissions
|
|
11
|
+
if "Can add" in permission_name:
|
|
12
|
+
permission_name = permission_name.replace("Can add", " إضافة ")
|
|
13
|
+
elif "Can change" in permission_name:
|
|
14
|
+
permission_name = permission_name.replace("Can change", " تعديل ")
|
|
15
|
+
elif "Can delete" in permission_name:
|
|
16
|
+
permission_name = permission_name.replace("Can delete", " حذف ")
|
|
17
|
+
elif "Can view" in permission_name:
|
|
18
|
+
permission_name = permission_name.replace("Can view", " عرض ")
|
|
19
|
+
|
|
20
|
+
return f"{permission_name}"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class UsersConfig(AppConfig):
|
|
24
|
+
default_auto_field = 'django.db.models.BigAutoField'
|
|
25
|
+
name = 'users'
|
|
26
|
+
verbose_name = "المستخدمين"
|
|
27
|
+
|
|
28
|
+
def ready(self):
|
|
29
|
+
from django.contrib.auth.models import Permission
|
|
30
|
+
Permission.__str__ = custom_permission_str
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Imports of the required python modules and libraries
|
|
2
|
+
######################################################
|
|
3
|
+
import django_filters
|
|
4
|
+
from django.contrib.auth import get_user_model
|
|
5
|
+
from crispy_forms.helper import FormHelper
|
|
6
|
+
from crispy_forms.layout import Layout, Row, Column, Field, HTML
|
|
7
|
+
from django.db.models import Q
|
|
8
|
+
from .models import UserActivityLog
|
|
9
|
+
|
|
10
|
+
User = get_user_model() # Use custom user model
|
|
11
|
+
|
|
12
|
+
class UserFilter(django_filters.FilterSet):
|
|
13
|
+
keyword = django_filters.CharFilter(
|
|
14
|
+
method='filter_keyword',
|
|
15
|
+
label='',
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
class Meta:
|
|
19
|
+
model = User
|
|
20
|
+
fields = []
|
|
21
|
+
|
|
22
|
+
def __init__(self, *args, **kwargs):
|
|
23
|
+
super().__init__(*args, **kwargs)
|
|
24
|
+
self.form.helper = FormHelper()
|
|
25
|
+
self.form.helper.form_method = 'GET'
|
|
26
|
+
self.form.helper.form_class = 'form-inline'
|
|
27
|
+
self.form.helper.form_show_labels = False
|
|
28
|
+
self.form.helper.layout = Layout(
|
|
29
|
+
Row(
|
|
30
|
+
Column(Field('keyword', placeholder="البحث"), css_class='form-group col-auto flex-fill'),
|
|
31
|
+
Column(HTML('<button type="submit" class="btn btn-secondary w-100"><i class="bi bi-search bi-font text-light me-2"></i>بحـــث</button>'), css_class='col-auto text-center'),
|
|
32
|
+
Column(HTML('{% if request.GET and request.GET.keys|length > 1 %} <a href="{% url "manage_users" %}" class="btn btn-warning bi-font">clear</a> {% endif %}'), css_class='form-group col-auto text-center'),
|
|
33
|
+
css_class='form-row'
|
|
34
|
+
),
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
def filter_keyword(self, queryset, name, value):
|
|
38
|
+
"""
|
|
39
|
+
Filter the queryset by matching the keyword in username, email, phone, and occupation.
|
|
40
|
+
"""
|
|
41
|
+
return queryset.filter(
|
|
42
|
+
Q(username__icontains=value) |
|
|
43
|
+
Q(email__icontains=value) |
|
|
44
|
+
Q(phone__icontains=value) |
|
|
45
|
+
Q(occupation__icontains=value) |
|
|
46
|
+
Q(first_name__icontains=value) |
|
|
47
|
+
Q(last_name__icontains=value)
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class UserActivityLogFilter(django_filters.FilterSet):
|
|
53
|
+
keyword = django_filters.CharFilter(
|
|
54
|
+
method='filter_keyword',
|
|
55
|
+
label='',
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
year = django_filters.ChoiceFilter(
|
|
59
|
+
field_name="timestamp__year",
|
|
60
|
+
lookup_expr="exact",
|
|
61
|
+
choices=[],
|
|
62
|
+
empty_label="السنة",
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
class Meta:
|
|
66
|
+
model = UserActivityLog
|
|
67
|
+
fields = {
|
|
68
|
+
'timestamp': ['gte', 'lte'],
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
def __init__(self, *args, **kwargs):
|
|
72
|
+
super().__init__(*args, **kwargs)
|
|
73
|
+
|
|
74
|
+
# Fetch distinct years dynamically
|
|
75
|
+
years = UserActivityLog.objects.dates('timestamp', 'year').distinct()
|
|
76
|
+
self.filters['year'].extra['choices'] = [(year.year, year.year) for year in years]
|
|
77
|
+
|
|
78
|
+
self.filters['year'].field.widget.attrs.update({
|
|
79
|
+
'onchange': 'this.form.submit();'
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
self.form.helper = FormHelper()
|
|
83
|
+
self.form.helper.form_method = 'GET'
|
|
84
|
+
self.form.helper.form_class = 'form-inline'
|
|
85
|
+
self.form.helper.form_show_labels = False
|
|
86
|
+
|
|
87
|
+
self.form.helper.layout = Layout(
|
|
88
|
+
Row(
|
|
89
|
+
Column(Field('keyword', placeholder="البحث"), css_class='form-group col-auto flex-fill'),
|
|
90
|
+
Column(Field('year', placeholder="السنة", dir="rtl"), css_class='form-group col-auto'),
|
|
91
|
+
Column(
|
|
92
|
+
Row(
|
|
93
|
+
Column(Field('timestamp__gte', css_class='flatpickr', placeholder="من "), css_class='col-6'),
|
|
94
|
+
Column(Field('timestamp__lte', css_class='flatpickr', placeholder="إلى "), css_class='col-6'),
|
|
95
|
+
),
|
|
96
|
+
css_class='col-auto flex-fill'
|
|
97
|
+
),
|
|
98
|
+
Column(HTML('<button type="submit" class="btn btn-secondary w-100"><i class="bi bi-search bi-font text-light me-2"></i>بحـــث</button>'), css_class='col-auto text-center'),
|
|
99
|
+
Column(HTML('{% if request.GET and request.GET.keys|length > 1 %} <a href="{% url "user_activity_log" %}" class="btn btn-warning bi-font">clear</a> {% endif %}'), css_class='form-group col-auto text-center'),
|
|
100
|
+
css_class='form-row'
|
|
101
|
+
),
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
def filter_keyword(self, queryset, name, value):
|
|
105
|
+
"""
|
|
106
|
+
Filter the queryset by matching the keyword in username, email, phone, and occupation.
|
|
107
|
+
"""
|
|
108
|
+
return queryset.filter(
|
|
109
|
+
Q(user__username__icontains=value) |
|
|
110
|
+
Q(user__email__icontains=value) |
|
|
111
|
+
Q(user__profile__phone__icontains=value) |
|
|
112
|
+
Q(user__profile__occupation__icontains=value) |
|
|
113
|
+
Q(action__icontains=value) |
|
|
114
|
+
Q(model_name__icontains=value) |
|
|
115
|
+
Q(number__icontains=value) |
|
|
116
|
+
Q(ip_address__icontains=value)
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|