django-project-base 0.1.37.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 (208) hide show
  1. django_project_base-0.1.37.1/LICENSE +22 -0
  2. django_project_base-0.1.37.1/MANIFEST.in +5 -0
  3. django_project_base-0.1.37.1/PKG-INFO +102 -0
  4. django_project_base-0.1.37.1/README.md +52 -0
  5. django_project_base-0.1.37.1/django_project_base/__init__.py +6 -0
  6. django_project_base-0.1.37.1/django_project_base/account/__init__.py +4 -0
  7. django_project_base-0.1.37.1/django_project_base/account/apps.py +13 -0
  8. django_project_base-0.1.37.1/django_project_base/account/authentication.py +28 -0
  9. django_project_base-0.1.37.1/django_project_base/account/constants.py +3 -0
  10. django_project_base-0.1.37.1/django_project_base/account/management/__init__.py +0 -0
  11. django_project_base-0.1.37.1/django_project_base/account/management/commands/__init__.py +0 -0
  12. django_project_base-0.1.37.1/django_project_base/account/management/commands/allauth_to_social_core.py +46 -0
  13. django_project_base-0.1.37.1/django_project_base/account/management/commands/delete_users.py +23 -0
  14. django_project_base-0.1.37.1/django_project_base/account/middleware.py +91 -0
  15. django_project_base-0.1.37.1/django_project_base/account/rest/__init__.py +0 -0
  16. django_project_base-0.1.37.1/django_project_base/account/rest/account.py +401 -0
  17. django_project_base-0.1.37.1/django_project_base/account/rest/impersonate.py +141 -0
  18. django_project_base-0.1.37.1/django_project_base/account/rest/invite.py +188 -0
  19. django_project_base-0.1.37.1/django_project_base/account/rest/login.py +129 -0
  20. django_project_base-0.1.37.1/django_project_base/account/rest/profile.py +725 -0
  21. django_project_base-0.1.37.1/django_project_base/account/rest/profile_merge.py +151 -0
  22. django_project_base-0.1.37.1/django_project_base/account/rest/project_profiles.py +288 -0
  23. django_project_base-0.1.37.1/django_project_base/account/rest/project_profiles_utils.py +168 -0
  24. django_project_base-0.1.37.1/django_project_base/account/rest/reset_password.py +182 -0
  25. django_project_base-0.1.37.1/django_project_base/account/router.py +44 -0
  26. django_project_base-0.1.37.1/django_project_base/account/service/__init__.py +0 -0
  27. django_project_base-0.1.37.1/django_project_base/account/service/merge_users_service.py +123 -0
  28. django_project_base-0.1.37.1/django_project_base/account/service/register_user_service.py +30 -0
  29. django_project_base-0.1.37.1/django_project_base/account/service/reset_password_email_service.py +79 -0
  30. django_project_base-0.1.37.1/django_project_base/account/settings.py +8 -0
  31. django_project_base-0.1.37.1/django_project_base/account/social_auth/__init__.py +0 -0
  32. django_project_base-0.1.37.1/django_project_base/account/social_auth/providers.py +39 -0
  33. django_project_base-0.1.37.1/django_project_base/account/social_auth/settings.py +47 -0
  34. django_project_base-0.1.37.1/django_project_base/account/urls.py +8 -0
  35. django_project_base-0.1.37.1/django_project_base/apps.py +13 -0
  36. django_project_base-0.1.37.1/django_project_base/auth/__init__.py +0 -0
  37. django_project_base-0.1.37.1/django_project_base/auth/admin.py +3 -0
  38. django_project_base-0.1.37.1/django_project_base/auth/apps.py +6 -0
  39. django_project_base-0.1.37.1/django_project_base/auth/migrations/__init__.py +0 -0
  40. django_project_base-0.1.37.1/django_project_base/auth/models.py +27 -0
  41. django_project_base-0.1.37.1/django_project_base/auth/tests.py +3 -0
  42. django_project_base-0.1.37.1/django_project_base/auth/views.py +3 -0
  43. django_project_base-0.1.37.1/django_project_base/aws/__init__.py +0 -0
  44. django_project_base-0.1.37.1/django_project_base/aws/ses.py +55 -0
  45. django_project_base-0.1.37.1/django_project_base/base/__init__.py +1 -0
  46. django_project_base-0.1.37.1/django_project_base/base/auth_backends.py +49 -0
  47. django_project_base-0.1.37.1/django_project_base/base/event.py +221 -0
  48. django_project_base-0.1.37.1/django_project_base/base/exceptions.py +10 -0
  49. django_project_base-0.1.37.1/django_project_base/base/fields.py +66 -0
  50. django_project_base-0.1.37.1/django_project_base/base/filter_to_model.py +83 -0
  51. django_project_base-0.1.37.1/django_project_base/base/middleware.py +66 -0
  52. django_project_base-0.1.37.1/django_project_base/base/models.py +371 -0
  53. django_project_base-0.1.37.1/django_project_base/base/permissions.py +126 -0
  54. django_project_base-0.1.37.1/django_project_base/base/queryset_with_cache.py +62 -0
  55. django_project_base-0.1.37.1/django_project_base/base/signals.py +16 -0
  56. django_project_base-0.1.37.1/django_project_base/base/tests.py +88 -0
  57. django_project_base-0.1.37.1/django_project_base/base/viewsets.py +26 -0
  58. django_project_base-0.1.37.1/django_project_base/caching/__init__.py +39 -0
  59. django_project_base-0.1.37.1/django_project_base/caching/cache_queue/__init__.py +118 -0
  60. django_project_base-0.1.37.1/django_project_base/caching/cache_queue/cache_queue_other.py +80 -0
  61. django_project_base-0.1.37.1/django_project_base/caching/cache_queue/cache_queue_redis.py +41 -0
  62. django_project_base-0.1.37.1/django_project_base/celery/__init__.py +1 -0
  63. django_project_base-0.1.37.1/django_project_base/celery/apps.py +9 -0
  64. django_project_base-0.1.37.1/django_project_base/celery/background_tasks/__init__.py +0 -0
  65. django_project_base-0.1.37.1/django_project_base/celery/background_tasks/base_task.py +47 -0
  66. django_project_base-0.1.37.1/django_project_base/celery/background_tasks/notification_tasks.py +40 -0
  67. django_project_base-0.1.37.1/django_project_base/celery/celery.py +78 -0
  68. django_project_base-0.1.37.1/django_project_base/celery/settings.py +12 -0
  69. django_project_base-0.1.37.1/django_project_base/constants.py +14 -0
  70. django_project_base-0.1.37.1/django_project_base/country_holidays.py +33 -0
  71. django_project_base-0.1.37.1/django_project_base/licensing/__init__.py +1 -0
  72. django_project_base-0.1.37.1/django_project_base/licensing/apps.py +6 -0
  73. django_project_base-0.1.37.1/django_project_base/licensing/logic.py +120 -0
  74. django_project_base-0.1.37.1/django_project_base/licensing/migrations/0001_initial.py +55 -0
  75. django_project_base-0.1.37.1/django_project_base/licensing/migrations/0002_remove_licenseaccessuse_comment_and_more_squashed_0004_alter_licenseaccessuse_amount.py +61 -0
  76. django_project_base-0.1.37.1/django_project_base/licensing/migrations/0005_auto_20230901_0613.py +22 -0
  77. django_project_base-0.1.37.1/django_project_base/licensing/migrations/__init__.py +0 -0
  78. django_project_base-0.1.37.1/django_project_base/licensing/models.py +25 -0
  79. django_project_base-0.1.37.1/django_project_base/licensing/rest/__init__.py +0 -0
  80. django_project_base-0.1.37.1/django_project_base/licensing/rest/rest.py +28 -0
  81. django_project_base-0.1.37.1/django_project_base/licensing/rest/router.py +11 -0
  82. django_project_base-0.1.37.1/django_project_base/licensing/urls.py +7 -0
  83. django_project_base-0.1.37.1/django_project_base/locale/en/LC_MESSAGES/django.mo +0 -0
  84. django_project_base-0.1.37.1/django_project_base/locale/en/LC_MESSAGES/django.po +690 -0
  85. django_project_base-0.1.37.1/django_project_base/locale/en/LC_MESSAGES/djangojs.mo +0 -0
  86. django_project_base-0.1.37.1/django_project_base/locale/en/LC_MESSAGES/djangojs.po +322 -0
  87. django_project_base-0.1.37.1/django_project_base/locale/sl/LC_MESSAGES/django.mo +0 -0
  88. django_project_base-0.1.37.1/django_project_base/locale/sl/LC_MESSAGES/django.po +703 -0
  89. django_project_base-0.1.37.1/django_project_base/locale/sl/LC_MESSAGES/djangojs.mo +0 -0
  90. django_project_base-0.1.37.1/django_project_base/locale/sl/LC_MESSAGES/djangojs.po +360 -0
  91. django_project_base-0.1.37.1/django_project_base/management/__init__.py +0 -0
  92. django_project_base-0.1.37.1/django_project_base/management/commands/__init__.py +0 -0
  93. django_project_base-0.1.37.1/django_project_base/management/commands/confirm_setting.py +39 -0
  94. django_project_base-0.1.37.1/django_project_base/management/commands/list_pending_settings.py +41 -0
  95. django_project_base-0.1.37.1/django_project_base/models.py +0 -0
  96. django_project_base-0.1.37.1/django_project_base/notifications/__init__.py +3 -0
  97. django_project_base-0.1.37.1/django_project_base/notifications/apps.py +13 -0
  98. django_project_base-0.1.37.1/django_project_base/notifications/base/__init__.py +0 -0
  99. django_project_base-0.1.37.1/django_project_base/notifications/base/channels/__init__.py +0 -0
  100. django_project_base-0.1.37.1/django_project_base/notifications/base/channels/channel.py +289 -0
  101. django_project_base-0.1.37.1/django_project_base/notifications/base/channels/integrations/__init__.py +0 -0
  102. django_project_base-0.1.37.1/django_project_base/notifications/base/channels/integrations/aws_ses.py +151 -0
  103. django_project_base-0.1.37.1/django_project_base/notifications/base/channels/integrations/aws_sns_single_sms.py +76 -0
  104. django_project_base-0.1.37.1/django_project_base/notifications/base/channels/integrations/nexmo_sms.py +79 -0
  105. django_project_base-0.1.37.1/django_project_base/notifications/base/channels/integrations/provider_integration.py +98 -0
  106. django_project_base-0.1.37.1/django_project_base/notifications/base/channels/integrations/t2.py +368 -0
  107. django_project_base-0.1.37.1/django_project_base/notifications/base/channels/mail_channel.py +55 -0
  108. django_project_base-0.1.37.1/django_project_base/notifications/base/channels/sms_channel.py +36 -0
  109. django_project_base-0.1.37.1/django_project_base/notifications/base/channels/websocket_channel.py +0 -0
  110. django_project_base-0.1.37.1/django_project_base/notifications/base/duplicate_notification_mixin.py +33 -0
  111. django_project_base-0.1.37.1/django_project_base/notifications/base/enums.py +48 -0
  112. django_project_base-0.1.37.1/django_project_base/notifications/base/notification.py +338 -0
  113. django_project_base-0.1.37.1/django_project_base/notifications/base/phone_number_parser.py +46 -0
  114. django_project_base-0.1.37.1/django_project_base/notifications/base/queable_notification_mixin.py +31 -0
  115. django_project_base-0.1.37.1/django_project_base/notifications/base/send_notification_service.py +140 -0
  116. django_project_base-0.1.37.1/django_project_base/notifications/constants.py +1 -0
  117. django_project_base-0.1.37.1/django_project_base/notifications/email_notification.py +167 -0
  118. django_project_base-0.1.37.1/django_project_base/notifications/maintenance_notification.py +27 -0
  119. django_project_base-0.1.37.1/django_project_base/notifications/management/__init__.py +0 -0
  120. django_project_base-0.1.37.1/django_project_base/notifications/management/commands/__init__.py +0 -0
  121. django_project_base-0.1.37.1/django_project_base/notifications/management/commands/resend_notification.py +19 -0
  122. django_project_base-0.1.37.1/django_project_base/notifications/migrations/0001_initial.py +184 -0
  123. django_project_base-0.1.37.1/django_project_base/notifications/migrations/0002_remove_djangoprojectbasenotification_project_and_more.py +38 -0
  124. django_project_base-0.1.37.1/django_project_base/notifications/migrations/0003_alter_djangoprojectbasemessage_options.py +16 -0
  125. django_project_base-0.1.37.1/django_project_base/notifications/migrations/0003_alter_djangoprojectbasemessage_options_and_more.py +16 -0
  126. django_project_base-0.1.37.1/django_project_base/notifications/migrations/0004_alter_djangoprojectbasenotification_options.py +16 -0
  127. django_project_base-0.1.37.1/django_project_base/notifications/migrations/0004_alter_djangoprojectbasenotification_options_and_more.py +66 -0
  128. django_project_base-0.1.37.1/django_project_base/notifications/migrations/0005_merge_20230906_1213.py +46 -0
  129. django_project_base-0.1.37.1/django_project_base/notifications/migrations/0006_djangoprojectbasenotification_send_notification_sms.py +45 -0
  130. django_project_base-0.1.37.1/django_project_base/notifications/migrations/0007_auto_20231026_0555.py +35 -0
  131. django_project_base-0.1.37.1/django_project_base/notifications/migrations/0008_deliveryreport_auxiliary_notification.py +17 -0
  132. django_project_base-0.1.37.1/django_project_base/notifications/migrations/0009_auto_20231108_0658.py +36 -0
  133. django_project_base-0.1.37.1/django_project_base/notifications/migrations/0010_djangoprojectbasenotification_extra_data.py +17 -0
  134. django_project_base-0.1.37.1/django_project_base/notifications/migrations/0011_djangoprojectbasemessageattachment.py +27 -0
  135. django_project_base-0.1.37.1/django_project_base/notifications/migrations/__init__.py +0 -0
  136. django_project_base-0.1.37.1/django_project_base/notifications/models.py +314 -0
  137. django_project_base-0.1.37.1/django_project_base/notifications/notification_queryset.py +36 -0
  138. django_project_base-0.1.37.1/django_project_base/notifications/rest/__init__.py +0 -0
  139. django_project_base-0.1.37.1/django_project_base/notifications/rest/delivery_report.py +80 -0
  140. django_project_base-0.1.37.1/django_project_base/notifications/rest/maintenance_notification.py +199 -0
  141. django_project_base-0.1.37.1/django_project_base/notifications/rest/notification.py +749 -0
  142. django_project_base-0.1.37.1/django_project_base/notifications/rest/router.py +19 -0
  143. django_project_base-0.1.37.1/django_project_base/notifications/settings.py +20 -0
  144. django_project_base-0.1.37.1/django_project_base/notifications/templates/account_created.html +13 -0
  145. django_project_base-0.1.37.1/django_project_base/notifications/templates/notification.html +120 -0
  146. django_project_base-0.1.37.1/django_project_base/notifications/templates/notification_login.html +95 -0
  147. django_project_base-0.1.37.1/django_project_base/notifications/tests/__init__.py +0 -0
  148. django_project_base-0.1.37.1/django_project_base/notifications/tests/api/__init__.py +0 -0
  149. django_project_base-0.1.37.1/django_project_base/notifications/tests/api/test_create_mail.py +58 -0
  150. django_project_base-0.1.37.1/django_project_base/notifications/tests/api/test_list_mail.py +57 -0
  151. django_project_base-0.1.37.1/django_project_base/notifications/tests/api/test_remainig_license.py +17 -0
  152. django_project_base-0.1.37.1/django_project_base/notifications/tests/api/test_retrieve_mail.py +36 -0
  153. django_project_base-0.1.37.1/django_project_base/notifications/tests/notifications_transaction_test_case.py +83 -0
  154. django_project_base-0.1.37.1/django_project_base/notifications/tests/unit/__init__.py +0 -0
  155. django_project_base-0.1.37.1/django_project_base/notifications/tests/unit/test_is_mail_sent.py +56 -0
  156. django_project_base-0.1.37.1/django_project_base/notifications/tests/unit/test_is_phone_number_valid.py +12 -0
  157. django_project_base-0.1.37.1/django_project_base/notifications/utils.py +9 -0
  158. django_project_base-0.1.37.1/django_project_base/permissions/__init__.py +35 -0
  159. django_project_base-0.1.37.1/django_project_base/profiling/__init__.py +2 -0
  160. django_project_base-0.1.37.1/django_project_base/profiling/middleware.py +202 -0
  161. django_project_base-0.1.37.1/django_project_base/profiling/performance_base_command.py +33 -0
  162. django_project_base-0.1.37.1/django_project_base/profiling/performance_celery_task.py +22 -0
  163. django_project_base-0.1.37.1/django_project_base/profiling/performance_celery_task_class.py +17 -0
  164. django_project_base-0.1.37.1/django_project_base/profiling/performance_function_decorator.py +26 -0
  165. django_project_base-0.1.37.1/django_project_base/profiling/views.py +98 -0
  166. django_project_base-0.1.37.1/django_project_base/query_tracker/__init__.py +0 -0
  167. django_project_base-0.1.37.1/django_project_base/query_tracker/base.py +138 -0
  168. django_project_base-0.1.37.1/django_project_base/rest/__init__.py +0 -0
  169. django_project_base-0.1.37.1/django_project_base/rest/project.py +478 -0
  170. django_project_base-0.1.37.1/django_project_base/rest/project_role.py +99 -0
  171. django_project_base-0.1.37.1/django_project_base/router.py +91 -0
  172. django_project_base-0.1.37.1/django_project_base/serialization.py +107 -0
  173. django_project_base-0.1.37.1/django_project_base/settings.py +109 -0
  174. django_project_base-0.1.37.1/django_project_base/settings_parser.py +33 -0
  175. django_project_base-0.1.37.1/django_project_base/static/browser-update/browser-update.js +24 -0
  176. django_project_base-0.1.37.1/django_project_base/static/browser-update/update.min.js +3 -0
  177. django_project_base-0.1.37.1/django_project_base/templates/app-debug/main.html +85 -0
  178. django_project_base-0.1.37.1/django_project_base/templates/email/base.html +12 -0
  179. django_project_base-0.1.37.1/django_project_base/templatetags/__init__.py +0 -0
  180. django_project_base-0.1.37.1/django_project_base/templatetags/dpb_tags.py +9 -0
  181. django_project_base-0.1.37.1/django_project_base/urls.py +19 -0
  182. django_project_base-0.1.37.1/django_project_base/utils.py +182 -0
  183. django_project_base-0.1.37.1/django_project_base/views.py +25 -0
  184. django_project_base-0.1.37.1/django_project_base.egg-info/PKG-INFO +102 -0
  185. django_project_base-0.1.37.1/django_project_base.egg-info/SOURCES.txt +206 -0
  186. django_project_base-0.1.37.1/django_project_base.egg-info/dependency_links.txt +1 -0
  187. django_project_base-0.1.37.1/django_project_base.egg-info/requires.txt +22 -0
  188. django_project_base-0.1.37.1/django_project_base.egg-info/top_level.txt +1 -0
  189. django_project_base-0.1.37.1/pyproject.toml +43 -0
  190. django_project_base-0.1.37.1/requirements.txt +22 -0
  191. django_project_base-0.1.37.1/setup.cfg +4 -0
  192. django_project_base-0.1.37.1/setup.py +100 -0
  193. django_project_base-0.1.37.1/tests/test_account_register.py +94 -0
  194. django_project_base-0.1.37.1/tests/test_auth.py +179 -0
  195. django_project_base-0.1.37.1/tests/test_auth_backends.py +36 -0
  196. django_project_base-0.1.37.1/tests/test_base.py +14 -0
  197. django_project_base-0.1.37.1/tests/test_caching.py +243 -0
  198. django_project_base-0.1.37.1/tests/test_celery_notification_task.py +17 -0
  199. django_project_base-0.1.37.1/tests/test_impersonate.py +66 -0
  200. django_project_base-0.1.37.1/tests/test_maintenance_notifications.py +56 -0
  201. django_project_base-0.1.37.1/tests/test_mgmt_cmd_delete_users.py +30 -0
  202. django_project_base-0.1.37.1/tests/test_models.py +43 -0
  203. django_project_base-0.1.37.1/tests/test_project.py +61 -0
  204. django_project_base-0.1.37.1/tests/test_project_settings.py +39 -0
  205. django_project_base-0.1.37.1/tests/test_retrieve_holidays.py +14 -0
  206. django_project_base-0.1.37.1/tests/test_role.py +92 -0
  207. django_project_base-0.1.37.1/tests/test_serialization.py +143 -0
  208. django_project_base-0.1.37.1/tests/test_user_profile.py +187 -0
@@ -0,0 +1,22 @@
1
+ Proprietary license
2
+
3
+ Copyright Scantron A/S & Scantron d.o.o. & Velis d.o.o. & Jure Erznožnik
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software
6
+ and associated documentation files (the "Software"), to deal in the Software, including
7
+ without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
+ and/or sell copies of the Software, and to permit persons to whom the Software is furnished to
9
+ do so, subject to the following conditions and restrictions:
10
+
11
+ - Condition: The above copyright notice and permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+ - Restriction: Use of this Software, whether in original or modified form, is **expressly
14
+ prohibited** for purposes related to access control systems and/or intercom
15
+ (doorphone) technologies, including but not limited to development, deployment, or
16
+ integration by any person or entity operating in or serving such domains.
17
+
18
+ The software is provided "as is", without warranty of any kind, express or implied, including
19
+ but not limited to the warranties of merchantability, fitness for a particular purpose and
20
+ noninfringement. In no event shall the authors or copyright holders be liable for any claim,
21
+ damages or other liability, whether in an action of contract, tort or otherwise, arising from, out
22
+ of or in connection with the software or the use or other dealings in the software.
@@ -0,0 +1,5 @@
1
+ include requirements.txt
2
+ incluide LICENSE
3
+ recursive-include django_project_base *
4
+ global-exclude __pycache__
5
+ global-exclude *.py[co]
@@ -0,0 +1,102 @@
1
+ Metadata-Version: 2.4
2
+ Name: django-project-base
3
+ Version: 0.1.37.1
4
+ Summary: Everything revolves around it: users, roles, permissions, tags, etc.
5
+ Home-page: https://github.com/velis74/django-project-base
6
+ Author: velis74
7
+ Author-email: support@velis.si
8
+ License: Proprietary
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: Other/Proprietary License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Framework :: Django
14
+ Requires-Python: >=3.8
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: django
18
+ Requires-Dist: djangorestframework
19
+ Requires-Dist: dynamicforms>=0.77.17
20
+ Requires-Dist: swapper
21
+ Requires-Dist: django-rest-registration
22
+ Requires-Dist: drf-spectacular<0.26.0,>=0.17.2
23
+ Requires-Dist: django-taggit
24
+ Requires-Dist: svgwrite
25
+ Requires-Dist: django-hijack<3
26
+ Requires-Dist: pytz
27
+ Requires-Dist: tox
28
+ Requires-Dist: social-auth-app-django
29
+ Requires-Dist: django-permissions-policy
30
+ Requires-Dist: django-csp
31
+ Requires-Dist: requests
32
+ Requires-Dist: boto3
33
+ Requires-Dist: natural
34
+ Requires-Dist: celery>=5.2
35
+ Requires-Dist: pandas
36
+ Requires-Dist: click>=8.1
37
+ Requires-Dist: ruff
38
+ Requires-Dist: ruff-lsp
39
+ Dynamic: author
40
+ Dynamic: author-email
41
+ Dynamic: classifier
42
+ Dynamic: description
43
+ Dynamic: description-content-type
44
+ Dynamic: home-page
45
+ Dynamic: license
46
+ Dynamic: license-file
47
+ Dynamic: requires-dist
48
+ Dynamic: requires-python
49
+ Dynamic: summary
50
+
51
+ # Notice to users of this library
52
+
53
+ ## This library is no longer free software.
54
+
55
+ With 0.80.0 the library has gained a development partner that will doubtless raise it to new heights.
56
+
57
+ The LICENSE has been modified to a proprietary one with restrictions, so please be mindful of conditions.
58
+
59
+ The library is thus deprecated and in maintenance mode only.
60
+
61
+ # Django project base
62
+
63
+ A collection of functionalities that are common to most projects we do.
64
+
65
+ - account management
66
+ - project management
67
+ - notifications (both to users and to apps)
68
+ - tagging
69
+ - background job processing
70
+ - roles & permissions
71
+ - profiling
72
+
73
+ This project is in VERY early development stage. Some of the functionalities are not even developed yet, some need
74
+ major rework, but some, surprisingly, should work pretty well already. An example of pretty well functioning ones is
75
+ account management.
76
+
77
+ ## Example project
78
+
79
+ For running example django project prepare python environment and run (run in repository root):
80
+
81
+ ```bash
82
+ $ pip install -r requirements.txt
83
+ $ python manage.py runserver
84
+ ```
85
+
86
+ ## Documentation
87
+
88
+ Run command in repository root:
89
+
90
+ ```bash
91
+ $ npm run docs:dev
92
+ ```
93
+
94
+ The dev server should be running at http://localhost:5173. Visit the URL in your browser to read documentation!
95
+
96
+ To generate pdf file. Run:
97
+
98
+ ```bash
99
+ $ npm run export-pdf
100
+ ```
101
+
102
+ Pdf file is located in docs/pdf folder.
@@ -0,0 +1,52 @@
1
+ # Notice to users of this library
2
+
3
+ ## This library is no longer free software.
4
+
5
+ With 0.80.0 the library has gained a development partner that will doubtless raise it to new heights.
6
+
7
+ The LICENSE has been modified to a proprietary one with restrictions, so please be mindful of conditions.
8
+
9
+ The library is thus deprecated and in maintenance mode only.
10
+
11
+ # Django project base
12
+
13
+ A collection of functionalities that are common to most projects we do.
14
+
15
+ - account management
16
+ - project management
17
+ - notifications (both to users and to apps)
18
+ - tagging
19
+ - background job processing
20
+ - roles & permissions
21
+ - profiling
22
+
23
+ This project is in VERY early development stage. Some of the functionalities are not even developed yet, some need
24
+ major rework, but some, surprisingly, should work pretty well already. An example of pretty well functioning ones is
25
+ account management.
26
+
27
+ ## Example project
28
+
29
+ For running example django project prepare python environment and run (run in repository root):
30
+
31
+ ```bash
32
+ $ pip install -r requirements.txt
33
+ $ python manage.py runserver
34
+ ```
35
+
36
+ ## Documentation
37
+
38
+ Run command in repository root:
39
+
40
+ ```bash
41
+ $ npm run docs:dev
42
+ ```
43
+
44
+ The dev server should be running at http://localhost:5173. Visit the URL in your browser to read documentation!
45
+
46
+ To generate pdf file. Run:
47
+
48
+ ```bash
49
+ $ npm run export-pdf
50
+ ```
51
+
52
+ Pdf file is located in docs/pdf folder.
@@ -0,0 +1,6 @@
1
+ __title__ = "django project base"
2
+ # __version__ = "{version-string}" #TODO: Switch back to version string when merging to main
3
+ __version__ = "0.1.37.1"
4
+ default_app_config = "django_project_base.apps.DjangoProjectBaseConfig"
5
+
6
+ VERSION = __version__
@@ -0,0 +1,4 @@
1
+ from .constants import ACCOUNT_APP_ID
2
+ from .middleware import SessionMiddleware #noqa
3
+
4
+ default_app_config = "%s.apps.DjangoProjectBaseAccountsConfig" % ACCOUNT_APP_ID
@@ -0,0 +1,13 @@
1
+ from django.apps import AppConfig
2
+
3
+ from django_project_base.account import ACCOUNT_APP_ID
4
+ from django_project_base.account.settings import ACCOUNT_SETTINGS
5
+ from django_project_base.settings_parser import parse_settings
6
+
7
+
8
+ class DjangoProjectBaseAccountsConfig(AppConfig):
9
+ name = ACCOUNT_APP_ID
10
+ verbose_name = "Django Project Base Account management"
11
+
12
+ def ready(self):
13
+ parse_settings(ACCOUNT_SETTINGS)
@@ -0,0 +1,28 @@
1
+ from rest_framework.authentication import SessionAuthentication
2
+
3
+
4
+ # noinspection PyRedeclaration
5
+ class SessionAuthentication(SessionAuthentication):
6
+ """
7
+ This is needed because original SessionAuthentication doesn't return anything is authenticate_header. And this means
8
+ that if user is not logged in, status of response would be 403 and not 401.
9
+ If authenticate_header returns some string, status of response will be 401.
10
+
11
+ This is only relevant for authentication class that if listed first in
12
+ REST_FRAMEWORK / DEFAULT_AUTHENTICATION_CLASSES setting.
13
+ Also see code in rest_framework.views.APIView.handle_exception and inside this function see call of function
14
+ self.get_authenticate_header
15
+
16
+ If you use this SessionAuthentication class instad of original one
17
+ (rest_framework.authentication.SessionAuthentication) you must also set
18
+ REST_REGISTRATION["LOGIN_AUTHENTICATE_SESSION"] to True in settings.py.
19
+ Without it, user won't be logged in.
20
+ See code in rest_registration.api.views.login.LoginView.post. Here is call to perform_login function. Inside that,
21
+ there is call of should_authenticate_session() that returns True if there is original SessionAuthentication class
22
+ listed in REST_FRAMEWORK / DEFAULT_AUTHENTICATION_CLASSES setting. If you are using inherited one,
23
+ it will return False by default. Except you set REST_REGISTRATION["LOGIN_AUTHENTICATE_SESSION"] setting to True in
24
+ settings.py.
25
+ """
26
+
27
+ def authenticate_header(self, request):
28
+ return "sessionid"
@@ -0,0 +1,3 @@
1
+ ACCOUNT_APP_ID = "django_project_base.account"
2
+ MERGE_USERS_QS_CK = f"merge-users-list-%d" # noqa: F541
3
+ RESET_USER_PASSWORD_VERIFICATION_CODE = "reset-user-password-ver-identifier-"
@@ -0,0 +1,46 @@
1
+ import json
2
+
3
+ from typing import Optional
4
+
5
+ import social_core.backends.facebook
6
+ import social_core.backends.google
7
+ import social_core.backends.microsoft
8
+
9
+ from django.db import connection
10
+ from social_django.models import UserSocialAuth
11
+
12
+ from django_project_base.profiling.performance_base_command import PerformanceCommand
13
+
14
+
15
+ # This is not tested because there is no socialaccount model anymore
16
+ class Command(PerformanceCommand): # pragma: no cover
17
+ help = "Migrate social login data from allauth to social_core"
18
+
19
+ provider_mapping: dict = {
20
+ "google": social_core.backends.google.GoogleOAuth2.name,
21
+ "facebook": social_core.backends.facebook.FacebookOAuth2.name,
22
+ "azure": social_core.backends.microsoft.MicrosoftOAuth2.name,
23
+ }
24
+
25
+ def handle(self, *args, **options):
26
+ with connection.cursor() as cursor:
27
+ cursor.execute("select user_id, provider, extra_data from socialaccount_socialaccount;")
28
+ rows: list = cursor.fetchall()
29
+ for row in rows:
30
+ user_id: int = row[0]
31
+ provider: str = row[1]
32
+ extra_data: dict = json.loads(row[2]) if row[2] else {}
33
+ user_email: Optional[str] = extra_data.get("email") or extra_data.get("mail")
34
+ if user_email:
35
+ new_provider: str = self.provider_mapping.get(provider)
36
+ assert new_provider, "New social auth provider for %s is not defined" % provider
37
+ payload = {
38
+ "user_id": user_id,
39
+ "provider": new_provider,
40
+ }
41
+ social_auth_records_exists: bool = UserSocialAuth.objects.filter(**payload).exists()
42
+ if not social_auth_records_exists:
43
+ payload["uid"] = user_email
44
+ payload["extra_data"] = None
45
+ UserSocialAuth.objects.create(**payload)
46
+ return "ok"
@@ -0,0 +1,23 @@
1
+ import datetime
2
+ import logging
3
+
4
+ import swapper
5
+
6
+ from django.db import transaction
7
+
8
+ from django_project_base.profiling.performance_base_command import PerformanceCommand
9
+
10
+
11
+ class Command(PerformanceCommand):
12
+ help = "Deletes users marked for deletion"
13
+
14
+ def handle(self, *args, **options):
15
+ for profile in swapper.load_model("django_project_base", "Profile").objects.filter(
16
+ delete_at__isnull=False, delete_at__lt=datetime.datetime.now()
17
+ ):
18
+ with transaction.atomic():
19
+ try:
20
+ profile.delete()
21
+ except Exception as e: # pragma: no cover
22
+ logging.getLogger(__name__).error(e)
23
+ return "Finished deleting users"
@@ -0,0 +1,91 @@
1
+ import json
2
+
3
+ import swapper
4
+
5
+ from django.conf import settings
6
+ from django.contrib.sessions.middleware import SessionMiddleware as SessionMiddlewareBase
7
+ from django.utils.functional import SimpleLazyObject
8
+ from rest_framework.authentication import get_authorization_header
9
+
10
+
11
+ class ProjectNotSelectedError(NotImplementedError):
12
+ def __init__(self, message: str, *args: object) -> None:
13
+ super().__init__(message, *args)
14
+ self.message = message
15
+
16
+
17
+ def selected_project_not_setup():
18
+ raise ProjectNotSelectedError(
19
+ """The functionality called requires settings variables that establish currently selected project.
20
+ Check docs for DJANGO_PROJECT_BASE_BASE_REQUEST_URL_VARIABLES and its "project" setting.
21
+ The setting needs to be declared and currently selected project passed at least once from the front-end
22
+ """
23
+ )
24
+
25
+
26
+ def load_selected_project(slug: str):
27
+ def load():
28
+ ProjectModel = swapper.load_model("django_project_base", "Project")
29
+ try:
30
+ return ProjectModel.objects.prefetch_related("owner").get(slug=slug)
31
+ except ProjectModel.DoesNotExist:
32
+ selected_project_not_setup()
33
+
34
+ return load
35
+
36
+
37
+ class SessionMiddleware(SessionMiddlewareBase):
38
+ def get_request_params(self, request):
39
+ if request.method in ["POST", "PUT", "PATCH", "DELETE"]:
40
+ body_data = json.loads(request.body.decode("utf-8"))
41
+ if isinstance(body_data, list):
42
+ return body_data[0]
43
+ return body_data
44
+ else:
45
+ return getattr(request, request.method)
46
+
47
+ def process_request(self, request):
48
+ auth = get_authorization_header(request).split()
49
+ if auth and auth[0].lower() == b"sessionid":
50
+ session_key = auth[1].decode("utf-8")
51
+ setattr(request, "_dont_enforce_csrf_checks", True)
52
+ else:
53
+ session_key = request.COOKIES.get(settings.SESSION_COOKIE_NAME)
54
+
55
+ request.session = self.SessionStore(session_key)
56
+
57
+ # determine if currently selected project has been passed with the request and set it to session if so
58
+ # this requires UrlVarsMiddleware to have been installed before this middleware
59
+ current_project_attr = (
60
+ getattr(settings, "DJANGO_PROJECT_BASE_BASE_REQUEST_URL_VARIABLES", {})
61
+ .get("project", {})
62
+ .get("value_name", None)
63
+ )
64
+
65
+ # also set request.selected_project variables or throw errors on access if conditions not satisfied
66
+ if current_project_attr:
67
+ if curr_project_slug := getattr(request, current_project_attr, None):
68
+ request.session[current_project_attr] = curr_project_slug
69
+ else:
70
+ curr_project_slug = request.session.get(current_project_attr, None)
71
+
72
+ request.selected_project_slug = curr_project_slug
73
+ request.selected_project = SimpleLazyObject(load_selected_project(curr_project_slug))
74
+ else:
75
+ request.selected_project_slug = SimpleLazyObject(selected_project_not_setup)
76
+ request.selected_project = SimpleLazyObject(selected_project_not_setup)
77
+
78
+ def process_response(self, request, response):
79
+ process_response = super().process_response(request, response)
80
+ if getattr(response, "returntype", None) == "json" or "/dynamicforms/progress" in request.path:
81
+ # sometimes (i.e. at new user login) dynamicforms progress is called before user login...
82
+ # and it can happen, that responses come back after login. But response have request session id,
83
+ # that is not valid anymore (because login happened in the meantime).
84
+ # And when such response come back to frontend it starts using this session data for further requests.
85
+ # Which actually means that user is not logged in anymore.
86
+ # So we can just remove session data from dynamicforms/progress response. It shouldn't be needed anyway.
87
+ process_response.cookies.pop("sessionid", None)
88
+ process_response.cookies.pop("csrftoken", None)
89
+ process_response.csrf_cookie_set = False
90
+
91
+ return process_response