dj-tinyuser 0.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.
Files changed (97) hide show
  1. dj_tinyuser-0.0.1/LICENSE +12 -0
  2. dj_tinyuser-0.0.1/LICENSE.django-project +12 -0
  3. dj_tinyuser-0.0.1/LICENSE.django-project.md +15 -0
  4. dj_tinyuser-0.0.1/LICENSE.md +15 -0
  5. dj_tinyuser-0.0.1/PKG-INFO +194 -0
  6. dj_tinyuser-0.0.1/README.md +159 -0
  7. dj_tinyuser-0.0.1/dj_tinyuser/__init__.py +0 -0
  8. dj_tinyuser-0.0.1/dj_tinyuser/account_adapter.py +90 -0
  9. dj_tinyuser-0.0.1/dj_tinyuser/admin.py +31 -0
  10. dj_tinyuser-0.0.1/dj_tinyuser/api/__init__.py +1 -0
  11. dj_tinyuser-0.0.1/dj_tinyuser/api/apps.py +9 -0
  12. dj_tinyuser-0.0.1/dj_tinyuser/api/locale/de/LC_MESSAGES/django.po +43 -0
  13. dj_tinyuser-0.0.1/dj_tinyuser/api/permissions.py +24 -0
  14. dj_tinyuser-0.0.1/dj_tinyuser/api/serializers.py +208 -0
  15. dj_tinyuser-0.0.1/dj_tinyuser/api/tests/__init__.py +1 -0
  16. dj_tinyuser-0.0.1/dj_tinyuser/api/tests/test_invitations_api.py +182 -0
  17. dj_tinyuser-0.0.1/dj_tinyuser/api/tests/test_profile_api.py +1 -0
  18. dj_tinyuser-0.0.1/dj_tinyuser/api/tests/test_user_api.py +261 -0
  19. dj_tinyuser-0.0.1/dj_tinyuser/api/urls.py +19 -0
  20. dj_tinyuser-0.0.1/dj_tinyuser/api/views.py +65 -0
  21. dj_tinyuser-0.0.1/dj_tinyuser/apps.py +7 -0
  22. dj_tinyuser-0.0.1/dj_tinyuser/context_processors.py +31 -0
  23. dj_tinyuser-0.0.1/dj_tinyuser/exceptions.py +6 -0
  24. dj_tinyuser-0.0.1/dj_tinyuser/forms.py +96 -0
  25. dj_tinyuser-0.0.1/dj_tinyuser/global_templates/__init__.py +3 -0
  26. dj_tinyuser-0.0.1/dj_tinyuser/global_templates/account/login.html +1 -0
  27. dj_tinyuser-0.0.1/dj_tinyuser/global_templates/account/password_reset.html +1 -0
  28. dj_tinyuser-0.0.1/dj_tinyuser/global_templates/account/signup.html +1 -0
  29. dj_tinyuser-0.0.1/dj_tinyuser/global_templates/allauth/layouts/base.html +1 -0
  30. dj_tinyuser-0.0.1/dj_tinyuser/input_files/style.scss +27 -0
  31. dj_tinyuser-0.0.1/dj_tinyuser/locale/de/LC_MESSAGES/django.po +880 -0
  32. dj_tinyuser-0.0.1/dj_tinyuser/logging.py +11 -0
  33. dj_tinyuser-0.0.1/dj_tinyuser/managers.py +64 -0
  34. dj_tinyuser-0.0.1/dj_tinyuser/migrations/0001_initial.py +331 -0
  35. dj_tinyuser-0.0.1/dj_tinyuser/migrations/__init__.py +0 -0
  36. dj_tinyuser-0.0.1/dj_tinyuser/mixins/htmx.py +20 -0
  37. dj_tinyuser-0.0.1/dj_tinyuser/models/__init__.py +11 -0
  38. dj_tinyuser-0.0.1/dj_tinyuser/models/fields.py +58 -0
  39. dj_tinyuser-0.0.1/dj_tinyuser/models/tinyuser.py +125 -0
  40. dj_tinyuser-0.0.1/dj_tinyuser/models/userprofile.py +216 -0
  41. dj_tinyuser-0.0.1/dj_tinyuser/settings.py +72 -0
  42. dj_tinyuser-0.0.1/dj_tinyuser/sidebar.py +55 -0
  43. dj_tinyuser-0.0.1/dj_tinyuser/static/tinyuser/css/html.css +28 -0
  44. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/bootstrap5/account/login.dj.html +68 -0
  45. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/bootstrap5/account/password_reset.dj.html +19 -0
  46. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/bootstrap5/account/signup.dj.html +24 -0
  47. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/bootstrap5/base.dj.html +31 -0
  48. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/bootstrap5/index.html +10 -0
  49. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/bootstrap5/invite/failed.html +9 -0
  50. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/bootstrap5/invite/hx/failed.html +14 -0
  51. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/bootstrap5/invite/hx/invite.html +26 -0
  52. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/bootstrap5/invite/hx/success.html +14 -0
  53. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/bootstrap5/invite/invite.html +23 -0
  54. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/bootstrap5/invite/success.html +9 -0
  55. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/bootstrap5/profile/edit.html +10 -0
  56. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/bootstrap5/profile/hx/edit.html +151 -0
  57. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/bootstrap5/profile/hx/profile.html +120 -0
  58. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/bootstrap5/profile/hx/settings.html +27 -0
  59. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/bootstrap5/profile/profile.html +46 -0
  60. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/bootstrap5/profile/settings.html +18 -0
  61. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/bootstrap5/snippets/account/form +9 -0
  62. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/bs5docs/account/login.dj.html +66 -0
  63. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/bs5docs/account/signup.dj.html +26 -0
  64. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/html/account/login.dj.html +58 -0
  65. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/html/account/password_reset.dj.html +20 -0
  66. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/html/account/signup.dj.html +22 -0
  67. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/html/base.dj.html +27 -0
  68. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/html/index.html +7 -0
  69. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/html/invite/failed.html +9 -0
  70. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/html/invite/hx/failed.html +0 -0
  71. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/html/invite/hx/invite.html +0 -0
  72. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/html/invite/hx/success.html +0 -0
  73. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/html/invite/invite.html +0 -0
  74. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/html/invite/success.html +0 -0
  75. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/html/logout/navbar.dj.html +5 -0
  76. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/html/profile/edit.html +0 -0
  77. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/html/profile/hx/edit.html +0 -0
  78. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/html/profile/hx/profile.html +0 -0
  79. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/html/profile/hx/settings.html +0 -0
  80. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/html/profile/profile.html +0 -0
  81. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/html/profile/settings.html +0 -0
  82. dj_tinyuser-0.0.1/dj_tinyuser/templates/tinyuser/html/theme/nav.dj.html +20 -0
  83. dj_tinyuser-0.0.1/dj_tinyuser/templates.json +39 -0
  84. dj_tinyuser-0.0.1/dj_tinyuser/templates.yml +23 -0
  85. dj_tinyuser-0.0.1/dj_tinyuser/templatetags/__init__.py +0 -0
  86. dj_tinyuser-0.0.1/dj_tinyuser/templatetags/tinyuser.py +14 -0
  87. dj_tinyuser-0.0.1/dj_tinyuser/tests/__init__.py +0 -0
  88. dj_tinyuser-0.0.1/dj_tinyuser/tests/test_tinyuser_model.py +46 -0
  89. dj_tinyuser-0.0.1/dj_tinyuser/tests/test_userprofile_model.py +56 -0
  90. dj_tinyuser-0.0.1/dj_tinyuser/urls.py +22 -0
  91. dj_tinyuser-0.0.1/dj_tinyuser/utils.py +18 -0
  92. dj_tinyuser-0.0.1/dj_tinyuser/views/__init__.py +12 -0
  93. dj_tinyuser-0.0.1/dj_tinyuser/views/dashboard.py +0 -0
  94. dj_tinyuser-0.0.1/dj_tinyuser/views/index.py +15 -0
  95. dj_tinyuser-0.0.1/dj_tinyuser/views/invite.py +141 -0
  96. dj_tinyuser-0.0.1/dj_tinyuser/views/profile.py +470 -0
  97. dj_tinyuser-0.0.1/pyproject.toml +114 -0
@@ -0,0 +1,12 @@
1
+ Copyright (C) 2026 by Christian Moser <devel@c-moser.at>
2
+
3
+ Permission to use, copy, modify, and/or distribute this software for any
4
+ purpose with or without fee is hereby granted.
5
+
6
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
7
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
8
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
9
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
10
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
11
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
12
+ PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,12 @@
1
+ Copyright (C) 2026 by Christian Moser <devel@c-moser.at>
2
+
3
+ Permission to use, copy, modify, and/or distribute this software for any
4
+ purpose with or without fee is hereby granted.
5
+
6
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
7
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
8
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
9
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
10
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
11
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
12
+ PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,15 @@
1
+ License of django-project
2
+ =========================
3
+
4
+ **Copyright (C) 2026 by Christian Moser <devel@c-moser.at>**
5
+
6
+ Permission to use, copy, modify, and/or distribute this software for any
7
+ purpose with or without fee is hereby granted.
8
+
9
+ **THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ PERFORMANCE OF THIS SOFTWARE.**
@@ -0,0 +1,15 @@
1
+ LICENSE for *django-tinyuser*
2
+ =============================
3
+
4
+ **Copyright (C) 2026 by ChristianMoser [\<devel@c-moser.at\>](mailto:devel@c-moser.at)**
5
+
6
+ Permission to use, copy, modify, and/or distribute this software for any
7
+ purpose with or without fee is hereby granted.
8
+
9
+ **THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
11
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ PERFORMANCE OF THIS SOFTWARE.**
@@ -0,0 +1,194 @@
1
+ Metadata-Version: 2.4
2
+ Name: dj-tinyuser
3
+ Version: 0.0.1
4
+ Summary: A small minimal user for django using allauth-integration
5
+ License-Expression: 0BSD
6
+ License-File: LICENSE
7
+ License-File: LICENSE.django-project
8
+ License-File: LICENSE.django-project.md
9
+ License-File: LICENSE.md
10
+ Author: Christian Moser
11
+ Author-email: dev@c-moser.at
12
+ Maintainer: Christian Moser
13
+ Maintainer-email: dev@c-moser.at
14
+ Requires-Python: >=3.12,<3.15
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Requires-Dist: dj-templates (>=0.0.28,<0.1.0)
20
+ Requires-Dist: django (>=6.0.5,<7.0)
21
+ Requires-Dist: django-allauth[openid,saml,socialaccount] (>=65.16.1,<66.0.0)
22
+ Requires-Dist: django-environ (>=0.12.0,<0.13.0)
23
+ Requires-Dist: django-extensions (>=4.1,<5.0)
24
+ Requires-Dist: django-invitations (>=2.1.0,<3.0.0)
25
+ Requires-Dist: django-oauth-toolkit (>=3.2.0,<4.0.0)
26
+ Requires-Dist: django-widget-tweaks (>=1.5.0,<2.0.0)
27
+ Requires-Dist: fido2 (>=2.2.1,<3.0.0)
28
+ Requires-Dist: flake8 (>=7.3.0,<8.0.0)
29
+ Requires-Dist: markdown (>=3.10.2,<4.0.0)
30
+ Requires-Dist: orjson (>=3.11.9,<4.0.0)
31
+ Requires-Dist: pillow (>=12.1.1,<13.0.0)
32
+ Requires-Dist: pyyaml (>=6.0.3,<7.0.0)
33
+ Description-Content-Type: text/markdown
34
+
35
+
36
+ # Django TinyUser
37
+
38
+ **Neither the app nor the documentation is finished yet, but I wanted to publish the project anyway, because I need it for my projects and I want to share it with others. If you want to contribute to the project, feel free to open a pull request or an issue.**
39
+
40
+
41
+ *Django TinyUser* is a small user authentication app for django. It is meant to be used by projects that need a small user authentication for their projects and don't want to implement their own. It is used by my projects and docker images for basic user authentication using *django-allauth*.
42
+
43
+ This project is distributed under the [*0BSD*-License](./LICENSE.django-tinyuser.md).
44
+
45
+ It uses *[django-allauth](https://docs.allauth.org/en/latest/)* as backend and
46
+ overloads the templates for *Bootstrap* and *Tailwind CSS*.
47
+
48
+ ## Links and Documentation
49
+
50
+ + [Official documentation](https://doc.c-moser.at/pub/projects/django/django-tinyuser/latest/)
51
+ + [Django TinyUser on Codeberg](https://codeberg.org/c9moser/django-tinyuser)
52
+ + [Django TinyUser on GitHub](https://github.com/c9moser/django-tinyuser)
53
+ + **Documentation of the dependencies:**
54
+ * [Django documentation](https://docs.djangoproject.com/en/stable/)
55
+ * [Allauth documentation](https://docs.allauth.org/en/latest/)
56
+ * [Django REST Framework documentation](https://www.django-rest-framework.org/)
57
+ * [Bootstrap documentation](https://getbootstrap.com/docs/5.3/getting-started/introduction/)
58
+ * [Tailwind CSS documentation](https://tailwindcss.com/docs/installation)
59
+
60
+ ## Installation
61
+
62
+ Add *TinyUser* to your project using poetry
63
+
64
+ ```sh
65
+ poetry add https+git://codeberg.org/c9moser/django-tinyuser.git
66
+ ```
67
+
68
+ ### Configuration of your project
69
+
70
+ ```python
71
+ from django_tinyuser.global_templates.tailwindcss import PATH as TINYUSER_GLOBAL_TEMPLATES
72
+ ...
73
+ # Register allauth and django_tinyuser
74
+ APPS = [
75
+ ...
76
+ 'allauth',
77
+ 'allauth.account',
78
+ 'allauth.socialaccount', # if you want to use social auth
79
+ # add the providers you want to use, e.g. 'allauth.socialaccount.providers.google',
80
+ 'django_tinyuser',
81
+ ...
82
+ ]
83
+ ```
84
+
85
+ If you use *Bootstrap*, you can add overloads to your TEMPLATES. The overloads are located in
86
+ the global_templates folder of django_tinyuser. You can add them to your TEMPLATES like
87
+ this is and they will be used instead of the default templates of django-allauth.
88
+
89
+ Note that you have to add the path to the overloads before the default templates of django-allauth,
90
+ otherwise they will not be used.
91
+
92
+ And don't forget to add the context processors for *django-allauth*, and *django-tinyuser*
93
+ otherwise the templates will not work.
94
+
95
+ ```python
96
+ from django_tinyuser.global_templates.bootstrap import PATH as TINYUSER_GLOBAL_TEMPLATES
97
+ TEMPLATES = [
98
+ {
99
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
100
+ # Add Bootstrap overloads to TEMPLATES
101
+ 'DIRS': [TINYUSER_GLOBAL_TEMPLATES],
102
+ 'APP_DIRS': True,
103
+ 'OPTIONS': {
104
+ 'context_processors': [
105
+ ...
106
+ 'django.template.context_processors.request',
107
+ 'django.contrib.auth.context_processors.auth',
108
+ 'django.contrib.messages.context_processors.messages',
109
+ 'django_tinyuser.context_processors.tinyuser'
110
+ ...
111
+ ],
112
+ },
113
+ },
114
+ ...
115
+ ]
116
+ ```
117
+
118
+ If you use *Tailwind CSS*, you can add the overloads to your TEMPLATES like this is and they will be used instead of the default templates of django-allauth.
119
+ ```python
120
+ from django_tinyuser.global_templates.tailwindcss import PATH as TINYUSER_GLOBAL_TEMPLATES
121
+ TEMPLATES = [
122
+ {
123
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
124
+ # Add Tailwind CSS overloads to TEMPLATES
125
+ 'DIRS': [TINYUSER_GLOBAL_TEMPLATES],
126
+ 'APP_DIRS': True,
127
+ 'OPTIONS': {
128
+ 'context_processors': [
129
+ ...
130
+ 'django.template.context_processors.request',
131
+ 'django.contrib.auth.context_processors.auth',
132
+ 'django.contrib.messages.context_processors.messages',
133
+ 'django_tinyuser.context_processors.tinyuser'
134
+ ...
135
+ ],
136
+ },
137
+ },
138
+ ...
139
+ ]
140
+ ```
141
+ You also need to set the `CSS_FRAMEWORK` option in your settings.py to the css framework you use,
142
+ otherwise the templates will not work.
143
+
144
+ ```python
145
+ CSS_FRAMEWORK = 'bootstrap' # if you use Bootstrap
146
+ # or
147
+ CSS_FRAMEWORK = 'tailwindcss' # if you use Tailwind CSS
148
+ # or
149
+ CSS_FRAMEWORK = 'custom' # if you use custom templates
150
+ ```
151
+
152
+ And you need to set the `AUTH_USER_MODEL` to `django_tinyuser.TinyUser` in your settings.py or
153
+ to an overloaded model if you have customized the user model.
154
+
155
+ ```python
156
+ AUTH_USER_MODEL = 'django_tinyuser.TinyUser'
157
+ ```
158
+
159
+ Then add the urls of *django-allauth* to your urls.py
160
+
161
+ ```python
162
+ from django.urls import path, include
163
+ urlpatterns = [
164
+ ...
165
+ path('accounts/', include('allauth.urls')),
166
+ ...
167
+ ]
168
+ ```
169
+
170
+ Finally run the migrations to create the required tables added by required apps, `django-allauth` and `django-tinyuser`.
171
+
172
+ ```bash
173
+ python manage.py migrate
174
+ ```
175
+
176
+
177
+ ## Configuration options to be added to your settings.py
178
+ ### CSS\_FRAMEWORK
179
+
180
+ One of the following values:
181
+
182
+ + *bootstrap* - if you use Bootstrap (partially implemented, but not tested yet)
183
+ + *tailwindcss* - if you use Tailwind CSS (not implemented yet)
184
+ + *custom* - custom template (you need to overload all
185
+ templates yourself and add the path to your TEMPLATES)
186
+
187
+ Note that the default value is 'bootstrap', so if you use Bootstrap, you don't need to set this option.
188
+
189
+ **If you use Tailwind CSS, you need to set this option to 'tailwindcss', otherwise the templates will not work.**
190
+
191
+ You can contact me under my <a href="https://social.c-moser.at/@chris" target="_blank" rel="me">Mastodon</a> account
192
+ if you have any questions or suggestions for the project. I am also open for contributions, so if you want to
193
+ contribute to the project, feel free to open a pull request or an issue.
194
+
@@ -0,0 +1,159 @@
1
+
2
+ # Django TinyUser
3
+
4
+ **Neither the app nor the documentation is finished yet, but I wanted to publish the project anyway, because I need it for my projects and I want to share it with others. If you want to contribute to the project, feel free to open a pull request or an issue.**
5
+
6
+
7
+ *Django TinyUser* is a small user authentication app for django. It is meant to be used by projects that need a small user authentication for their projects and don't want to implement their own. It is used by my projects and docker images for basic user authentication using *django-allauth*.
8
+
9
+ This project is distributed under the [*0BSD*-License](./LICENSE.django-tinyuser.md).
10
+
11
+ It uses *[django-allauth](https://docs.allauth.org/en/latest/)* as backend and
12
+ overloads the templates for *Bootstrap* and *Tailwind CSS*.
13
+
14
+ ## Links and Documentation
15
+
16
+ + [Official documentation](https://doc.c-moser.at/pub/projects/django/django-tinyuser/latest/)
17
+ + [Django TinyUser on Codeberg](https://codeberg.org/c9moser/django-tinyuser)
18
+ + [Django TinyUser on GitHub](https://github.com/c9moser/django-tinyuser)
19
+ + **Documentation of the dependencies:**
20
+ * [Django documentation](https://docs.djangoproject.com/en/stable/)
21
+ * [Allauth documentation](https://docs.allauth.org/en/latest/)
22
+ * [Django REST Framework documentation](https://www.django-rest-framework.org/)
23
+ * [Bootstrap documentation](https://getbootstrap.com/docs/5.3/getting-started/introduction/)
24
+ * [Tailwind CSS documentation](https://tailwindcss.com/docs/installation)
25
+
26
+ ## Installation
27
+
28
+ Add *TinyUser* to your project using poetry
29
+
30
+ ```sh
31
+ poetry add https+git://codeberg.org/c9moser/django-tinyuser.git
32
+ ```
33
+
34
+ ### Configuration of your project
35
+
36
+ ```python
37
+ from django_tinyuser.global_templates.tailwindcss import PATH as TINYUSER_GLOBAL_TEMPLATES
38
+ ...
39
+ # Register allauth and django_tinyuser
40
+ APPS = [
41
+ ...
42
+ 'allauth',
43
+ 'allauth.account',
44
+ 'allauth.socialaccount', # if you want to use social auth
45
+ # add the providers you want to use, e.g. 'allauth.socialaccount.providers.google',
46
+ 'django_tinyuser',
47
+ ...
48
+ ]
49
+ ```
50
+
51
+ If you use *Bootstrap*, you can add overloads to your TEMPLATES. The overloads are located in
52
+ the global_templates folder of django_tinyuser. You can add them to your TEMPLATES like
53
+ this is and they will be used instead of the default templates of django-allauth.
54
+
55
+ Note that you have to add the path to the overloads before the default templates of django-allauth,
56
+ otherwise they will not be used.
57
+
58
+ And don't forget to add the context processors for *django-allauth*, and *django-tinyuser*
59
+ otherwise the templates will not work.
60
+
61
+ ```python
62
+ from django_tinyuser.global_templates.bootstrap import PATH as TINYUSER_GLOBAL_TEMPLATES
63
+ TEMPLATES = [
64
+ {
65
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
66
+ # Add Bootstrap overloads to TEMPLATES
67
+ 'DIRS': [TINYUSER_GLOBAL_TEMPLATES],
68
+ 'APP_DIRS': True,
69
+ 'OPTIONS': {
70
+ 'context_processors': [
71
+ ...
72
+ 'django.template.context_processors.request',
73
+ 'django.contrib.auth.context_processors.auth',
74
+ 'django.contrib.messages.context_processors.messages',
75
+ 'django_tinyuser.context_processors.tinyuser'
76
+ ...
77
+ ],
78
+ },
79
+ },
80
+ ...
81
+ ]
82
+ ```
83
+
84
+ If you use *Tailwind CSS*, you can add the overloads to your TEMPLATES like this is and they will be used instead of the default templates of django-allauth.
85
+ ```python
86
+ from django_tinyuser.global_templates.tailwindcss import PATH as TINYUSER_GLOBAL_TEMPLATES
87
+ TEMPLATES = [
88
+ {
89
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
90
+ # Add Tailwind CSS overloads to TEMPLATES
91
+ 'DIRS': [TINYUSER_GLOBAL_TEMPLATES],
92
+ 'APP_DIRS': True,
93
+ 'OPTIONS': {
94
+ 'context_processors': [
95
+ ...
96
+ 'django.template.context_processors.request',
97
+ 'django.contrib.auth.context_processors.auth',
98
+ 'django.contrib.messages.context_processors.messages',
99
+ 'django_tinyuser.context_processors.tinyuser'
100
+ ...
101
+ ],
102
+ },
103
+ },
104
+ ...
105
+ ]
106
+ ```
107
+ You also need to set the `CSS_FRAMEWORK` option in your settings.py to the css framework you use,
108
+ otherwise the templates will not work.
109
+
110
+ ```python
111
+ CSS_FRAMEWORK = 'bootstrap' # if you use Bootstrap
112
+ # or
113
+ CSS_FRAMEWORK = 'tailwindcss' # if you use Tailwind CSS
114
+ # or
115
+ CSS_FRAMEWORK = 'custom' # if you use custom templates
116
+ ```
117
+
118
+ And you need to set the `AUTH_USER_MODEL` to `django_tinyuser.TinyUser` in your settings.py or
119
+ to an overloaded model if you have customized the user model.
120
+
121
+ ```python
122
+ AUTH_USER_MODEL = 'django_tinyuser.TinyUser'
123
+ ```
124
+
125
+ Then add the urls of *django-allauth* to your urls.py
126
+
127
+ ```python
128
+ from django.urls import path, include
129
+ urlpatterns = [
130
+ ...
131
+ path('accounts/', include('allauth.urls')),
132
+ ...
133
+ ]
134
+ ```
135
+
136
+ Finally run the migrations to create the required tables added by required apps, `django-allauth` and `django-tinyuser`.
137
+
138
+ ```bash
139
+ python manage.py migrate
140
+ ```
141
+
142
+
143
+ ## Configuration options to be added to your settings.py
144
+ ### CSS\_FRAMEWORK
145
+
146
+ One of the following values:
147
+
148
+ + *bootstrap* - if you use Bootstrap (partially implemented, but not tested yet)
149
+ + *tailwindcss* - if you use Tailwind CSS (not implemented yet)
150
+ + *custom* - custom template (you need to overload all
151
+ templates yourself and add the path to your TEMPLATES)
152
+
153
+ Note that the default value is 'bootstrap', so if you use Bootstrap, you don't need to set this option.
154
+
155
+ **If you use Tailwind CSS, you need to set this option to 'tailwindcss', otherwise the templates will not work.**
156
+
157
+ You can contact me under my <a href="https://social.c-moser.at/@chris" target="_blank" rel="me">Mastodon</a> account
158
+ if you have any questions or suggestions for the project. I am also open for contributions, so if you want to
159
+ contribute to the project, feel free to open a pull request or an issue.
File without changes
@@ -0,0 +1,90 @@
1
+ from allauth.account.adapter import DefaultAccountAdapter
2
+ from django.forms import Form
3
+ from django.http import HttpRequest
4
+ from invitations.adapters import BaseInvitationsAdapter
5
+
6
+ from dj_tinyuser import settings
7
+ from dj_tinyuser.models import TinyUser
8
+
9
+
10
+ class TinyUserAccountAdapterBase:
11
+ def save_user(self, request: HttpRequest, user: TinyUser, form: Form, commit: bool = True):
12
+ """
13
+ Saves a new `User` instance using information provided in the signup form.
14
+
15
+ :param request: The current HTTP request.
16
+ :type request: HttpRequest
17
+ :param user: User instance to be saved.
18
+ :type user: TinyUser
19
+ :param form: The signup form containing user data.
20
+ :type form: forms.Form
21
+ :param commit: Whether to commit the user to the database, defaults to True
22
+ :type commit: bool, optional
23
+ :return: The saved user instance.
24
+ :rtype: TinyUser
25
+ """
26
+ from django.contrib.auth.models import Group
27
+
28
+ # Only add to groups on user creation, not on update
29
+ if user.pk is None:
30
+ add_to_default_groups = True
31
+ else:
32
+ add_to_default_groups = False
33
+ # Don't add to groups if we're not committing the user yet
34
+ if not commit:
35
+ add_to_default_groups = False
36
+
37
+ user = super().save_user(request, user, form, commit)
38
+
39
+ # Add the user to the default group if specified
40
+ if add_to_default_groups:
41
+ for group_name in settings.DEFAULT_USER_GROUPS:
42
+ group, created = Group.objects.get_or_create(name=group_name)
43
+ user.groups.add(group)
44
+
45
+ return user
46
+
47
+ def allow_signup(self, request: HttpRequest) -> bool:
48
+ """
49
+ Determines whether signups are allowed based on the current request and settings.
50
+
51
+ Logged in users are not allowed to sign up for new accounts,
52
+ and the setting ALLOW_SIGNUP is checked for unauthenticated users.
53
+
54
+ If ALLOW_SIGNUP is set to True, anyone can sign up.
55
+ If it's set to False, signups are disabled and only invited users can sign up.
56
+
57
+ :param request: The current HTTP request.
58
+ :type request: HttpRequest
59
+ :return: True if signups are allowed, False otherwise.
60
+ :rtype: bool
61
+ """
62
+
63
+ if hasattr(request, "user") and request.user.is_authenticated:
64
+ return False # Disable sign ups for authenticated users
65
+
66
+ # Check the ALLOW_SIGNUP setting for unauthenticated users
67
+ return settings.ALLOW_SIGNUP
68
+
69
+
70
+ class TinyUserAccountAdapter(DefaultAccountAdapter, TinyUserAccountAdapterBase):
71
+ pass
72
+
73
+
74
+ class TinyUserDRFAccountAdapter(DefaultAccountAdapter, BaseInvitationsAdapter, TinyUserAccountAdapterBase):
75
+ def format_email_subject(self, subject, context=None):
76
+ """
77
+ Formats the email subject for invitation emails.
78
+
79
+ This method is used by the django-invitations package to format the subject of invitation emails.
80
+ It can be overridden to customize the email subject based on the application's needs.
81
+
82
+ :param subject: The original email subject template.
83
+ :type subject: str
84
+ :return: The formatted email subject.
85
+ :rtype: str
86
+ """
87
+ if context is None:
88
+ return DefaultAccountAdapter.format_email_subject(self, subject)
89
+ else:
90
+ return BaseInvitationsAdapter.format_email_subject(self, subject, context)
@@ -0,0 +1,31 @@
1
+ from django.contrib import admin
2
+ from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
3
+ from django.utils.translation import gettext_lazy as _
4
+
5
+ from .models import TinyUser, UserProfile
6
+
7
+
8
+ class TinyUserAdmin(BaseUserAdmin):
9
+ fieldsets = (
10
+ (None, {"fields": ("email", "username", "password")}),
11
+ (_("Personal info"), {"fields": ("first_name", "last_name")}),
12
+ (_("Permissions"), {"fields": ("is_active", "is_staff", "is_superuser")}),
13
+ (_("Important dates"), {"fields": ("last_login", "date_joined")}),
14
+ )
15
+ add_fieldsets = (
16
+ (
17
+ None,
18
+ {
19
+ "classes": ("wide",),
20
+ "fields": ("email", "username", "password1", "password2"),
21
+ },
22
+ ),
23
+ )
24
+ list_display = ("email", "username", "is_staff", "is_active")
25
+ search_fields = ("email", "username")
26
+ ordering = ("email",)
27
+ filter_horizontal = ()
28
+
29
+
30
+ admin.site.register(TinyUser, TinyUserAdmin)
31
+ admin.site.register(UserProfile)
@@ -0,0 +1 @@
1
+ """."""
@@ -0,0 +1,9 @@
1
+ """."""
2
+
3
+ from django.apps import AppConfig
4
+
5
+
6
+ class TinyuserApiConfig(AppConfig):
7
+ """dj_tinyuser.api app config."""
8
+
9
+ name = "dj_tinyuser.api"
@@ -0,0 +1,43 @@
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: PACKAGE VERSION\n"
10
+ "Report-Msgid-Bugs-To: \n"
11
+ "POT-Creation-Date: 2026-08-30 13:37+0000\n"
12
+ "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "Language: \n"
16
+ "MIME-Version: 1.0\n"
17
+ "Content-Type: text/plain; charset=UTF-8\n"
18
+ "Content-Transfer-Encoding: 8bit\n"
19
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
20
+
21
+ #: dj_tinyuser/webapi/serializers.py:58
22
+ msgid "Email is required."
23
+ msgstr ""
24
+
25
+ #: dj_tinyuser/webapi/serializers.py:60
26
+ msgid "Username is required."
27
+ msgstr ""
28
+
29
+ #: dj_tinyuser/webapi/serializers.py:62
30
+ msgid "Password is required."
31
+ msgstr ""
32
+
33
+ #: dj_tinyuser/webapi/serializers.py:65
34
+ msgid "Signups are not allowed."
35
+ msgstr ""
36
+
37
+ #: dj_tinyuser/webapi/serializers.py:100
38
+ msgid "Email cannot be updated."
39
+ msgstr ""
40
+
41
+ #: dj_tinyuser/webapi/serializers.py:164
42
+ msgid "Unable to authenticate with provided credentials."
43
+ msgstr ""
@@ -0,0 +1,24 @@
1
+ """Permissions for WebAPI."""
2
+
3
+ from rest_framework.exceptions import PermissionDenied
4
+ from rest_framework.permissions import BasePermission
5
+
6
+ from dj_tinyuser import settings
7
+
8
+
9
+ class IsInvitor(BasePermission):
10
+ """Permission: is_invitor."""
11
+
12
+ def has_permission(self, request, view):
13
+ """Check for invitor permission."""
14
+ if not request.user.is_authenticated or not (
15
+ request.user.is_staff
16
+ or bool(
17
+ request.user.groups.filter(
18
+ name__in=settings.INVITE_GROUPS if settings.INVITE_GROUPS else ["invitors"]
19
+ ).first()
20
+ )
21
+ ):
22
+ raise PermissionDenied("Not an invitor.")
23
+
24
+ return True