baseapp-backend 0.0.51__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.
Files changed (915) hide show
  1. baseapp/README.md +40 -0
  2. baseapp/__init__.py +6 -0
  3. baseapp/activity_log/README.md +104 -0
  4. baseapp/activity_log/__init__.py +0 -0
  5. baseapp/activity_log/admin.py +0 -0
  6. baseapp/activity_log/apps.py +9 -0
  7. baseapp/activity_log/context.py +15 -0
  8. baseapp/activity_log/graphql/__init__.py +0 -0
  9. baseapp/activity_log/graphql/filters.py +40 -0
  10. baseapp/activity_log/graphql/interfaces.py +50 -0
  11. baseapp/activity_log/graphql/object_types.py +133 -0
  12. baseapp/activity_log/graphql/queries.py +17 -0
  13. baseapp/activity_log/graphql/subscriptions.py +49 -0
  14. baseapp/activity_log/middleware.py +92 -0
  15. baseapp/activity_log/migrations/0001_initial.py +25 -0
  16. baseapp/activity_log/migrations/0002_auto_20241216_1804.py +29 -0
  17. baseapp/activity_log/migrations/0003_delete_activitylog_activitylog.py +38 -0
  18. baseapp/activity_log/migrations/__init__.py +0 -0
  19. baseapp/activity_log/models.py +35 -0
  20. baseapp/activity_log/permissions.py +34 -0
  21. baseapp/activity_log/tests/__init__.py +0 -0
  22. baseapp/activity_log/tests/conftest.py +2 -0
  23. baseapp/activity_log/tests/factories.py +1 -0
  24. baseapp/activity_log/tests/test_graphql_mutations.py +90 -0
  25. baseapp/activity_log/tests/test_graphql_queries.py +415 -0
  26. baseapp/content_feed/__init__.py +0 -0
  27. baseapp/content_feed/admin.py +17 -0
  28. baseapp/content_feed/apps.py +9 -0
  29. baseapp/content_feed/graphql/__init__.py +0 -0
  30. baseapp/content_feed/graphql/filters.py +21 -0
  31. baseapp/content_feed/graphql/mutations.py +80 -0
  32. baseapp/content_feed/graphql/object_types.py +54 -0
  33. baseapp/content_feed/graphql/queries.py +14 -0
  34. baseapp/content_feed/migrations/0001_initial.py +69 -0
  35. baseapp/content_feed/migrations/0002_contentpostimage.py +52 -0
  36. baseapp/content_feed/migrations/0003_alter_contentpostimage_image.py +25 -0
  37. baseapp/content_feed/migrations/0004_alter_contentpostimage_post.py +25 -0
  38. baseapp/content_feed/migrations/0005_contentpost_is_reactions_enabled_and_more.py +27 -0
  39. baseapp/content_feed/migrations/__init__.py +0 -0
  40. baseapp/content_feed/models.py +69 -0
  41. baseapp/content_feed/tests/__init__.py +0 -0
  42. baseapp/content_feed/tests/conftest.py +2 -0
  43. baseapp/content_feed/tests/factories.py +19 -0
  44. baseapp/content_feed/tests/test_graphql_mutations_create.py +99 -0
  45. baseapp_api_key/README.md +297 -0
  46. baseapp_api_key/__init__.py +0 -0
  47. baseapp_api_key/admin.py +50 -0
  48. baseapp_api_key/apps.py +9 -0
  49. baseapp_api_key/graphql/__init__.py +1 -0
  50. baseapp_api_key/graphql/consumers.py +71 -0
  51. baseapp_api_key/graphql/middleware.py +17 -0
  52. baseapp_api_key/management/commands/api_key.py +69 -0
  53. baseapp_api_key/managers.py +124 -0
  54. baseapp_api_key/migrations/0001_initial.py +64 -0
  55. baseapp_api_key/migrations/__init__.py +0 -0
  56. baseapp_api_key/models.py +30 -0
  57. baseapp_api_key/querysets.py +17 -0
  58. baseapp_api_key/rest_framework/__init__.py +0 -0
  59. baseapp_api_key/rest_framework/authentication.py +51 -0
  60. baseapp_api_key/rest_framework/permissions.py +33 -0
  61. baseapp_api_key/settings.py +1 -0
  62. baseapp_api_key/tests/__init__.py +0 -0
  63. baseapp_api_key/tests/conftest.py +11 -0
  64. baseapp_api_key/tests/factories.py +24 -0
  65. baseapp_api_key/tests/fixtures.py +0 -0
  66. baseapp_api_key/tests/helpers.py +14 -0
  67. baseapp_api_key/tests/integration/__init__.py +0 -0
  68. baseapp_api_key/tests/mixins.py +1 -0
  69. baseapp_api_key/tests/unit/__init__.py +0 -0
  70. baseapp_api_key/tests/unit/test_api_key.py +195 -0
  71. baseapp_auth/README.md +142 -0
  72. baseapp_auth/__init__.py +0 -0
  73. baseapp_auth/admin.py +144 -0
  74. baseapp_auth/anonymization.py +42 -0
  75. baseapp_auth/apps.py +23 -0
  76. baseapp_auth/emails.py +298 -0
  77. baseapp_auth/exceptions.py +12 -0
  78. baseapp_auth/fields.py +14 -0
  79. baseapp_auth/forms.py +73 -0
  80. baseapp_auth/graphql/__init__.py +1 -0
  81. baseapp_auth/graphql/filters.py +21 -0
  82. baseapp_auth/graphql/object_types.py +160 -0
  83. baseapp_auth/graphql/permissions.py +17 -0
  84. baseapp_auth/graphql/queries.py +32 -0
  85. baseapp_auth/locale/es/LC_MESSAGES/django.mo +0 -0
  86. baseapp_auth/locale/es/LC_MESSAGES/django.po +384 -0
  87. baseapp_auth/managers.py +32 -0
  88. baseapp_auth/migrations/0001_initial.py +15 -0
  89. baseapp_auth/migrations/0002_passwordvalidation.py +60 -0
  90. baseapp_auth/migrations/0003_superuserupdatelog.py +66 -0
  91. baseapp_auth/migrations/0004_alter_superuserupdatelog_assigner.py +25 -0
  92. baseapp_auth/migrations/__init__.py +0 -0
  93. baseapp_auth/models.py +200 -0
  94. baseapp_auth/password_validators.py +62 -0
  95. baseapp_auth/permissions.py +37 -0
  96. baseapp_auth/pipeline.py +74 -0
  97. baseapp_auth/querysets.py +41 -0
  98. baseapp_auth/rest_framework/__init__.py +0 -0
  99. baseapp_auth/rest_framework/change_email/__init__.py +0 -0
  100. baseapp_auth/rest_framework/change_email/serializers.py +57 -0
  101. baseapp_auth/rest_framework/change_email/views.py +102 -0
  102. baseapp_auth/rest_framework/change_expired_password/__init__.py +0 -0
  103. baseapp_auth/rest_framework/change_expired_password/serializers.py +57 -0
  104. baseapp_auth/rest_framework/change_expired_password/views.py +20 -0
  105. baseapp_auth/rest_framework/confirm_email/__init__.py +0 -0
  106. baseapp_auth/rest_framework/confirm_email/serializers.py +21 -0
  107. baseapp_auth/rest_framework/confirm_email/views.py +40 -0
  108. baseapp_auth/rest_framework/forgot_password/__init__.py +0 -0
  109. baseapp_auth/rest_framework/forgot_password/serializers.py +63 -0
  110. baseapp_auth/rest_framework/forgot_password/views.py +63 -0
  111. baseapp_auth/rest_framework/jwt/__init__.py +0 -0
  112. baseapp_auth/rest_framework/jwt/serializers.py +52 -0
  113. baseapp_auth/rest_framework/jwt/tokens.py +26 -0
  114. baseapp_auth/rest_framework/jwt/views.py +29 -0
  115. baseapp_auth/rest_framework/login/__init__.py +0 -0
  116. baseapp_auth/rest_framework/login/helpers.py +37 -0
  117. baseapp_auth/rest_framework/login/serializers.py +42 -0
  118. baseapp_auth/rest_framework/login/views.py +41 -0
  119. baseapp_auth/rest_framework/mfa/__init__.py +0 -0
  120. baseapp_auth/rest_framework/mfa/mixins.py +26 -0
  121. baseapp_auth/rest_framework/pre_auth/__init__.py +0 -0
  122. baseapp_auth/rest_framework/pre_auth/serializers.py +49 -0
  123. baseapp_auth/rest_framework/pre_auth/views.py +33 -0
  124. baseapp_auth/rest_framework/register/__init__.py +0 -0
  125. baseapp_auth/rest_framework/register/serializers.py +49 -0
  126. baseapp_auth/rest_framework/register/views.py +26 -0
  127. baseapp_auth/rest_framework/routers/__init__.py +0 -0
  128. baseapp_auth/rest_framework/routers/account.py +50 -0
  129. baseapp_auth/rest_framework/urls/__init__.py +0 -0
  130. baseapp_auth/rest_framework/urls/auth_authtoken.py +16 -0
  131. baseapp_auth/rest_framework/urls/auth_jwt.py +16 -0
  132. baseapp_auth/rest_framework/urls/auth_mfa.py +20 -0
  133. baseapp_auth/rest_framework/urls/auth_mfa_jwt.py +18 -0
  134. baseapp_auth/rest_framework/urls/mfa.py +55 -0
  135. baseapp_auth/rest_framework/urls/pre_auth.py +16 -0
  136. baseapp_auth/rest_framework/users/__init__.py +0 -0
  137. baseapp_auth/rest_framework/users/channels.py +17 -0
  138. baseapp_auth/rest_framework/users/fields.py +8 -0
  139. baseapp_auth/rest_framework/users/mixins.py +58 -0
  140. baseapp_auth/rest_framework/users/parsers.py +14 -0
  141. baseapp_auth/rest_framework/users/permissions.py +6 -0
  142. baseapp_auth/rest_framework/users/serializers.py +215 -0
  143. baseapp_auth/rest_framework/users/tasks.py +42 -0
  144. baseapp_auth/rest_framework/users/views.py +180 -0
  145. baseapp_auth/settings.py +18 -0
  146. baseapp_auth/static/baseapp_auth/css/grouped_permission_widget.css +37 -0
  147. baseapp_auth/static/baseapp_auth/js/grouped_permission_widget.js +142 -0
  148. baseapp_auth/tasks.py +18 -0
  149. baseapp_auth/templates/admin/widgets/grouped_permission_widget.html +88 -0
  150. baseapp_auth/templates/users/emails/anonymize-user-error-body.html.j2 +7 -0
  151. baseapp_auth/templates/users/emails/anonymize-user-error-body.txt.j2 +9 -0
  152. baseapp_auth/templates/users/emails/anonymize-user-error-subject.txt.j2 +1 -0
  153. baseapp_auth/templates/users/emails/anonymize-user-error-superuser-body.html.j2 +7 -0
  154. baseapp_auth/templates/users/emails/anonymize-user-error-superuser-body.txt.j2 +9 -0
  155. baseapp_auth/templates/users/emails/anonymize-user-error-superuser-subject.txt.j2 +1 -0
  156. baseapp_auth/templates/users/emails/anonymize-user-success-body.html.j2 +7 -0
  157. baseapp_auth/templates/users/emails/anonymize-user-success-body.txt.j2 +9 -0
  158. baseapp_auth/templates/users/emails/anonymize-user-success-subject.txt.j2 +1 -0
  159. baseapp_auth/templates/users/emails/anonymize-user-success-superuser-body.html.j2 +7 -0
  160. baseapp_auth/templates/users/emails/anonymize-user-success-superuser-body.txt.j2 +9 -0
  161. baseapp_auth/templates/users/emails/anonymize-user-success-superuser-subject.txt.j2 +1 -0
  162. baseapp_auth/templates/users/emails/change-email-confirm-body.html.j2 +8 -0
  163. baseapp_auth/templates/users/emails/change-email-confirm-body.txt.j2 +11 -0
  164. baseapp_auth/templates/users/emails/change-email-confirm-subject.txt.j2 +1 -0
  165. baseapp_auth/templates/users/emails/change-email-verify-body.html.j2 +8 -0
  166. baseapp_auth/templates/users/emails/change-email-verify-body.txt.j2 +11 -0
  167. baseapp_auth/templates/users/emails/change-email-verify-subject.txt.j2 +1 -0
  168. baseapp_auth/templates/users/emails/new-superuser-notification-email-body.html.j2 +7 -0
  169. baseapp_auth/templates/users/emails/new-superuser-notification-email-body.txt.j2 +9 -0
  170. baseapp_auth/templates/users/emails/new-superuser-notification-email-subject.txt.j2 +1 -0
  171. baseapp_auth/templates/users/emails/password-expired-body.html.j2 +7 -0
  172. baseapp_auth/templates/users/emails/password-expired-body.txt.j2 +9 -0
  173. baseapp_auth/templates/users/emails/password-expired-subject.txt.j2 +1 -0
  174. baseapp_auth/templates/users/emails/password-reset-body.html.j2 +8 -0
  175. baseapp_auth/templates/users/emails/password-reset-body.txt.j2 +11 -0
  176. baseapp_auth/templates/users/emails/password-reset-subject.txt.j2 +1 -0
  177. baseapp_auth/templates/users/emails/remove-superuser-notification-email-body.html.j2 +7 -0
  178. baseapp_auth/templates/users/emails/remove-superuser-notification-email-body.txt.j2 +9 -0
  179. baseapp_auth/templates/users/emails/remove-superuser-notification-email-subject.txt.j2 +1 -0
  180. baseapp_auth/templates/users/emails/welcome-body.html.j2 +11 -0
  181. baseapp_auth/templates/users/emails/welcome-body.txt.j2 +13 -0
  182. baseapp_auth/templates/users/emails/welcome-subject.txt.j2 +1 -0
  183. baseapp_auth/tests/__init__.py +0 -0
  184. baseapp_auth/tests/conftest.py +12 -0
  185. baseapp_auth/tests/factories.py +19 -0
  186. baseapp_auth/tests/fixtures.py +16 -0
  187. baseapp_auth/tests/fixtures_mfa.py +34 -0
  188. baseapp_auth/tests/graphql/__init__.py +0 -0
  189. baseapp_auth/tests/graphql/conftest.py +2 -0
  190. baseapp_auth/tests/graphql/test_queries_me.py +27 -0
  191. baseapp_auth/tests/graphql/test_queries_user.py +171 -0
  192. baseapp_auth/tests/helpers.py +19 -0
  193. baseapp_auth/tests/integration/__init__.py +0 -0
  194. baseapp_auth/tests/integration/test_change_email.py +283 -0
  195. baseapp_auth/tests/integration/test_change_expired_password.py +136 -0
  196. baseapp_auth/tests/integration/test_confirm_email.py +96 -0
  197. baseapp_auth/tests/integration/test_forgot_password.py +152 -0
  198. baseapp_auth/tests/integration/test_login.py +232 -0
  199. baseapp_auth/tests/integration/test_pagination.py +41 -0
  200. baseapp_auth/tests/integration/test_pre_auth.py +75 -0
  201. baseapp_auth/tests/integration/test_register.py +88 -0
  202. baseapp_auth/tests/integration/test_users.py +515 -0
  203. baseapp_auth/tests/integration/test_users_channels.py +30 -0
  204. baseapp_auth/tests/mixins.py +1 -0
  205. baseapp_auth/tests/unit/__init__.py +0 -0
  206. baseapp_auth/tests/unit/test_celery_beat_health_check.py +32 -0
  207. baseapp_auth/tests/unit/test_emails.py +18 -0
  208. baseapp_auth/tests/unit/test_fields.py +43 -0
  209. baseapp_auth/tests/unit/test_forms.py +15 -0
  210. baseapp_auth/tests/unit/test_users.py +74 -0
  211. baseapp_auth/tests/unit/test_utils.py +16 -0
  212. baseapp_auth/tests/unit/test_widgets.py +105 -0
  213. baseapp_auth/tokens.py +105 -0
  214. baseapp_auth/utils/__init__.py +0 -0
  215. baseapp_auth/utils/app_and_model_verbose_names.py +17 -0
  216. baseapp_auth/utils/normalize_permission.py +22 -0
  217. baseapp_auth/utils/referral_utils.py +13 -0
  218. baseapp_auth/widgets.py +81 -0
  219. baseapp_backend-0.0.51.dist-info/METADATA +305 -0
  220. baseapp_backend-0.0.51.dist-info/RECORD +915 -0
  221. baseapp_backend-0.0.51.dist-info/WHEEL +5 -0
  222. baseapp_backend-0.0.51.dist-info/top_level.txt +25 -0
  223. baseapp_blocks/README.md +88 -0
  224. baseapp_blocks/__init__.py +0 -0
  225. baseapp_blocks/admin.py +11 -0
  226. baseapp_blocks/apps.py +9 -0
  227. baseapp_blocks/base.py +67 -0
  228. baseapp_blocks/graphql/__init__.py +0 -0
  229. baseapp_blocks/graphql/mutations.py +79 -0
  230. baseapp_blocks/graphql/object_types.py +74 -0
  231. baseapp_blocks/graphql/queries.py +2 -0
  232. baseapp_blocks/migrations/0001_initial.py +76 -0
  233. baseapp_blocks/migrations/0002_block_user.py +26 -0
  234. baseapp_blocks/migrations/0003_block_actor_block_target_alter_block_user.py +52 -0
  235. baseapp_blocks/migrations/0003_migrate_profiles.py +55 -0
  236. baseapp_blocks/migrations/0004_alter_block_unique_together_and_more.py +40 -0
  237. baseapp_blocks/migrations/__init__.py +0 -0
  238. baseapp_blocks/models.py +28 -0
  239. baseapp_blocks/permissions.py +54 -0
  240. baseapp_blocks/tests/__init__.py +0 -0
  241. baseapp_blocks/tests/conftest.py +2 -0
  242. baseapp_blocks/tests/factories.py +28 -0
  243. baseapp_blocks/tests/test_block_count.py +32 -0
  244. baseapp_blocks/tests/test_graphql_mutations.py +196 -0
  245. baseapp_chats/README.md +81 -0
  246. baseapp_chats/__init__.py +0 -0
  247. baseapp_chats/admin.py +42 -0
  248. baseapp_chats/apps.py +9 -0
  249. baseapp_chats/base.py +258 -0
  250. baseapp_chats/graphql/__init__.py +0 -0
  251. baseapp_chats/graphql/filters.py +93 -0
  252. baseapp_chats/graphql/interfaces.py +57 -0
  253. baseapp_chats/graphql/mutations.py +912 -0
  254. baseapp_chats/graphql/object_types.py +347 -0
  255. baseapp_chats/graphql/queries.py +9 -0
  256. baseapp_chats/graphql/subscriptions.py +151 -0
  257. baseapp_chats/migrations/0001_initial.py +291 -0
  258. baseapp_chats/migrations/0002_message_set_last_message_and_more.py +111 -0
  259. baseapp_chats/migrations/0003_alter_unreadmessagecount_room.py +25 -0
  260. baseapp_chats/migrations/0004_chatroomparticipant_has_archived_room.py +18 -0
  261. baseapp_chats/migrations/0005_remove_messagestatus_increment_unread_count_and_more.py +39 -0
  262. baseapp_chats/migrations/0006_remove_messagestatus_increment_unread_count_and_more.py +23 -0
  263. baseapp_chats/migrations/0007_messagestatus_increment_unread_count.py +30 -0
  264. baseapp_chats/migrations/0008_alter_chatroomparticipant_options.py +17 -0
  265. baseapp_chats/migrations/0009_remove_message_create_message_status_and_more.py +66 -0
  266. baseapp_chats/migrations/0010_message_deleted.py +18 -0
  267. baseapp_chats/migrations/0011_alter_chatroom_created_by_and_more.py +70 -0
  268. baseapp_chats/migrations/0012_chatroom_created_by_profile.py +27 -0
  269. baseapp_chats/migrations/0013_chatroom_insert_document_id_and_more.py +155 -0
  270. baseapp_chats/migrations/__init__.py +0 -0
  271. baseapp_chats/models.py +58 -0
  272. baseapp_chats/permissions.py +139 -0
  273. baseapp_chats/tests/__init__.py +0 -0
  274. baseapp_chats/tests/conftest.py +2 -0
  275. baseapp_chats/tests/factories.py +45 -0
  276. baseapp_chats/tests/test_graphql_mutations.py +1671 -0
  277. baseapp_chats/tests/test_graphql_queries.py +1289 -0
  278. baseapp_chats/tests/test_graphql_subscriptions.py +280 -0
  279. baseapp_chats/tests/test_triggers.py +28 -0
  280. baseapp_chats/tests/test_users.py +28 -0
  281. baseapp_chats/tests/test_utils.py +171 -0
  282. baseapp_chats/triggers.py +104 -0
  283. baseapp_chats/utils.py +76 -0
  284. baseapp_cloudflare_stream_field/README.md +129 -0
  285. baseapp_cloudflare_stream_field/__init__.py +2 -0
  286. baseapp_cloudflare_stream_field/apps.py +9 -0
  287. baseapp_cloudflare_stream_field/field.py +98 -0
  288. baseapp_cloudflare_stream_field/forms.py +14 -0
  289. baseapp_cloudflare_stream_field/rest_framework.py +10 -0
  290. baseapp_cloudflare_stream_field/static/baseapp_cloudflare_stream_field/js/baseapp_cloudflare_stream_field.js +57 -0
  291. baseapp_cloudflare_stream_field/static/baseapp_cloudflare_stream_field/js/tus.js +5202 -0
  292. baseapp_cloudflare_stream_field/static/baseapp_cloudflare_stream_field/js/tus.js.map +59 -0
  293. baseapp_cloudflare_stream_field/static/baseapp_cloudflare_stream_field/js/tus.min.js +2 -0
  294. baseapp_cloudflare_stream_field/static/baseapp_cloudflare_stream_field/js/tus.min.js.map +1 -0
  295. baseapp_cloudflare_stream_field/stream.py +93 -0
  296. baseapp_cloudflare_stream_field/tasks.py +136 -0
  297. baseapp_cloudflare_stream_field/templates/baseapp_cloudflare_stream_field/admin_async_file_input.html +29 -0
  298. baseapp_cloudflare_stream_field/tests/__init__.py +0 -0
  299. baseapp_cloudflare_stream_field/tests/conftest.py +3 -0
  300. baseapp_cloudflare_stream_field/tests/fixtures.py +300 -0
  301. baseapp_cloudflare_stream_field/tests/settings.py +1 -0
  302. baseapp_cloudflare_stream_field/tests/test_clip_video.py +39 -0
  303. baseapp_cloudflare_stream_field/tests/test_delete_original_trimmed_video.py +44 -0
  304. baseapp_cloudflare_stream_field/tests/test_generate_download_url.py +55 -0
  305. baseapp_cloudflare_stream_field/tests/test_refresh_from_cloudfare.py +179 -0
  306. baseapp_cloudflare_stream_field/tests/test_stream_client.py +57 -0
  307. baseapp_cloudflare_stream_field/urls.py +5 -0
  308. baseapp_cloudflare_stream_field/views.py +46 -0
  309. baseapp_cloudflare_stream_field/widgets.py +56 -0
  310. baseapp_comments/README.md +194 -0
  311. baseapp_comments/__init__.py +0 -0
  312. baseapp_comments/admin.py +27 -0
  313. baseapp_comments/apps.py +12 -0
  314. baseapp_comments/graphql/__init__.py +1 -0
  315. baseapp_comments/graphql/filters.py +30 -0
  316. baseapp_comments/graphql/mutations.py +232 -0
  317. baseapp_comments/graphql/object_types.py +186 -0
  318. baseapp_comments/graphql/queries.py +18 -0
  319. baseapp_comments/graphql/subscriptions.py +134 -0
  320. baseapp_comments/migrations/0001_initial.py +383 -0
  321. baseapp_comments/migrations/0002_alter_comment_user.py +28 -0
  322. baseapp_comments/migrations/0003_alter_comment_comments_count.py +24 -0
  323. baseapp_comments/migrations/0004_remove_comment_snapshot_insert_and_more.py +89 -0
  324. baseapp_comments/migrations/0005_remove_comment_snapshot_insert_and_more.py +82 -0
  325. baseapp_comments/migrations/0006_remove_comment_snapshot_insert_and_more.py +86 -0
  326. baseapp_comments/migrations/0007_remove_comment_insert_insert_and_more.py +26 -0
  327. baseapp_comments/migrations/0008_comment_new_profile_commentevent_new_profile_and_more.py +85 -0
  328. baseapp_comments/migrations/0009_migrate_profiles.py +77 -0
  329. baseapp_comments/migrations/0010_drop_profile_content_type.py +86 -0
  330. baseapp_comments/migrations/0011_rename_new_profile_to_profile.py +80 -0
  331. baseapp_comments/migrations/0012_alter_comment_options.py +27 -0
  332. baseapp_comments/migrations/0013_alter_commentevent_id.py +18 -0
  333. baseapp_comments/migrations/0014_alter_commentevent_pgh_context_and_more.py +39 -0
  334. baseapp_comments/migrations/0015_alter_commentevent_pgh_context_and_more.py +37 -0
  335. baseapp_comments/migrations/0016_remove_commentevent_in_reply_to_and_more.py +53 -0
  336. baseapp_comments/migrations/0017_alter_comment_profile.py +28 -0
  337. baseapp_comments/migrations/0018_comment_insert_document_id_and_more.py +43 -0
  338. baseapp_comments/migrations/__init__.py +0 -0
  339. baseapp_comments/models.py +172 -0
  340. baseapp_comments/notifications.py +52 -0
  341. baseapp_comments/permissions.py +46 -0
  342. baseapp_comments/signals.py +100 -0
  343. baseapp_comments/tests/__init__.py +0 -0
  344. baseapp_comments/tests/conftest.py +2 -0
  345. baseapp_comments/tests/factories.py +48 -0
  346. baseapp_comments/tests/test_comments_count.py +27 -0
  347. baseapp_comments/tests/test_graphql_mutations_create.py +135 -0
  348. baseapp_comments/tests/test_graphql_mutations_delete.py +133 -0
  349. baseapp_comments/tests/test_graphql_mutations_pin.py +131 -0
  350. baseapp_comments/tests/test_graphql_mutations_update.py +120 -0
  351. baseapp_comments/tests/test_graphql_queries_all_comments.py +76 -0
  352. baseapp_comments/tests/test_graphql_queries_comments_from_blocked_profiles.py +102 -0
  353. baseapp_comments/tests/test_graphql_queries_object_comments.py +408 -0
  354. baseapp_comments/tests/test_graphql_subscriptions.py +222 -0
  355. baseapp_comments/tests/test_notifications.py +43 -0
  356. baseapp_comments/tests/test_users.py +22 -0
  357. baseapp_comments/tests/test_validators.py +38 -0
  358. baseapp_comments/validators.py +19 -0
  359. baseapp_core/README.md +68 -0
  360. baseapp_core/__init__.py +0 -0
  361. baseapp_core/admin.py +25 -0
  362. baseapp_core/apps.py +9 -0
  363. baseapp_core/asgi.py +16 -0
  364. baseapp_core/backfill.py +304 -0
  365. baseapp_core/channels.py +107 -0
  366. baseapp_core/constants.py +1 -0
  367. baseapp_core/debug_toolbar.py +2 -0
  368. baseapp_core/deep_links.py +45 -0
  369. baseapp_core/deprecation.py +2 -0
  370. baseapp_core/exceptions.py +2 -0
  371. baseapp_core/graphql/README.md +432 -0
  372. baseapp_core/graphql/__init__.py +27 -0
  373. baseapp_core/graphql/connections.py +15 -0
  374. baseapp_core/graphql/consumers.py +130 -0
  375. baseapp_core/graphql/decorators.py +89 -0
  376. baseapp_core/graphql/errors.py +9 -0
  377. baseapp_core/graphql/fields.py +57 -0
  378. baseapp_core/graphql/middlewares.py +59 -0
  379. baseapp_core/graphql/models.py +20 -0
  380. baseapp_core/graphql/mutations.py +42 -0
  381. baseapp_core/graphql/object_types.py +74 -0
  382. baseapp_core/graphql/optimizer.py +265 -0
  383. baseapp_core/graphql/relay.py +68 -0
  384. baseapp_core/graphql/serializer_mutation.py +181 -0
  385. baseapp_core/graphql/testing/__init__.py +1 -0
  386. baseapp_core/graphql/testing/fixtures.py +229 -0
  387. baseapp_core/graphql/testing/test_graphql_object_type_pre_optimization.py +102 -0
  388. baseapp_core/graphql/testing/test_graphql_optimizer.py +426 -0
  389. baseapp_core/graphql/translation.py +7 -0
  390. baseapp_core/graphql/utils.py +190 -0
  391. baseapp_core/graphql/views.py +62 -0
  392. baseapp_core/hashids/README.md +90 -0
  393. baseapp_core/hashids/__init__.py +0 -0
  394. baseapp_core/hashids/models.py +8 -0
  395. baseapp_core/hashids/strategies/__init__.py +159 -0
  396. baseapp_core/hashids/strategies/bundle.py +27 -0
  397. baseapp_core/hashids/strategies/interfaces/__init__.py +15 -0
  398. baseapp_core/hashids/strategies/interfaces/drf_resolver.py +9 -0
  399. baseapp_core/hashids/strategies/interfaces/graphql_resolver.py +22 -0
  400. baseapp_core/hashids/strategies/interfaces/id_resolver.py +6 -0
  401. baseapp_core/hashids/strategies/interfaces/queryset_annotator.py +12 -0
  402. baseapp_core/hashids/strategies/legacy/__init__.py +17 -0
  403. baseapp_core/hashids/strategies/legacy/drf_resolver.py +9 -0
  404. baseapp_core/hashids/strategies/legacy/graphql_resolver.py +47 -0
  405. baseapp_core/hashids/strategies/legacy/id_resolver.py +11 -0
  406. baseapp_core/hashids/strategies/legacy/queryset_annotator.py +14 -0
  407. baseapp_core/hashids/strategies/pk/__init__.py +9 -0
  408. baseapp_core/hashids/strategies/pk/drf_resolver.py +14 -0
  409. baseapp_core/hashids/strategies/pk/graphql_resolver.py +46 -0
  410. baseapp_core/hashids/strategies/public_id/__init__.py +19 -0
  411. baseapp_core/hashids/strategies/public_id/drf_resolver.py +9 -0
  412. baseapp_core/hashids/strategies/public_id/graphql_resolver.py +60 -0
  413. baseapp_core/hashids/strategies/public_id/id_resolver.py +19 -0
  414. baseapp_core/hashids/strategies/public_id/queryset_annotator.py +25 -0
  415. baseapp_core/hashids/tests/__init__.py +0 -0
  416. baseapp_core/hashids/tests/test_hashids_strategy_pickers.py +410 -0
  417. baseapp_core/hashids/tests/test_strategy_legacy.py +146 -0
  418. baseapp_core/hashids/tests/test_strategy_pk.py +107 -0
  419. baseapp_core/hashids/tests/test_strategy_public_id.py +143 -0
  420. baseapp_core/hashids/utils.py +18 -0
  421. baseapp_core/locale/es/LC_MESSAGES/django.mo +0 -0
  422. baseapp_core/locale/es/LC_MESSAGES/django.po +45 -0
  423. baseapp_core/logging.py +37 -0
  424. baseapp_core/management/commands/__init__.py +0 -0
  425. baseapp_core/management/commands/backfill_document_ids.py +90 -0
  426. baseapp_core/management/commands/generate_uml.py +165 -0
  427. baseapp_core/management/commands/routes_info.py +55 -0
  428. baseapp_core/middleware.py +125 -0
  429. baseapp_core/migrations/0001_initial.py +73 -0
  430. baseapp_core/migrations/__init__.py +0 -0
  431. baseapp_core/models.py +256 -0
  432. baseapp_core/rest_framework/__init__.py +0 -0
  433. baseapp_core/rest_framework/decorators.py +33 -0
  434. baseapp_core/rest_framework/fields.py +59 -0
  435. baseapp_core/rest_framework/mixins.py +60 -0
  436. baseapp_core/rest_framework/pagination.py +5 -0
  437. baseapp_core/rest_framework/routers.py +44 -0
  438. baseapp_core/rest_framework/serializers.py +42 -0
  439. baseapp_core/sentry.py +46 -0
  440. baseapp_core/settings/__init__.py +0 -0
  441. baseapp_core/settings/env.py +30 -0
  442. baseapp_core/static/admin/horizontal_production.png +0 -0
  443. baseapp_core/static/admin/horizontal_staging.png +0 -0
  444. baseapp_core/static/emails/background_bottom.png +0 -0
  445. baseapp_core/static/emails/background_top.png +0 -0
  446. baseapp_core/static/emails/logo.png +0 -0
  447. baseapp_core/static/social/flat-facebook.png +0 -0
  448. baseapp_core/static/social/flat-instagram.png +0 -0
  449. baseapp_core/static/social/flat-linkedin.png +0 -0
  450. baseapp_core/static/social/flat-x.png +0 -0
  451. baseapp_core/static/social/flat-youtube.png +0 -0
  452. baseapp_core/swappable.py +15 -0
  453. baseapp_core/templates/admin/base_site.html +16 -0
  454. baseapp_core/templates/emails/base.html.j2 +11 -0
  455. baseapp_core/templates/emails/base.txt.j2 +3 -0
  456. baseapp_core/tests/__init__.py +0 -0
  457. baseapp_core/tests/conftest.py +3 -0
  458. baseapp_core/tests/factories.py +19 -0
  459. baseapp_core/tests/fixtures.py +120 -0
  460. baseapp_core/tests/helpers.py +45 -0
  461. baseapp_core/tests/mixins.py +23 -0
  462. baseapp_core/tests/settings.py +234 -0
  463. baseapp_core/tests/test_backfill.py +298 -0
  464. baseapp_core/tests/test_case_insensitive_fields.py +24 -0
  465. baseapp_core/tests/test_celery_beat_health_check.py +41 -0
  466. baseapp_core/tests/test_document_id_mixin.py +93 -0
  467. baseapp_core/tests/test_document_id_model.py +69 -0
  468. baseapp_core/tests/test_graphql_schema_is_loaded_when_relay_id_is_evoked.py +39 -0
  469. baseapp_core/tests/test_ids_resolver.py +41 -0
  470. baseapp_core/tests/test_jwt_auth_middleware.py +176 -0
  471. baseapp_core/tests/test_middleware.py +83 -0
  472. baseapp_core/tests/test_migration_health_check.py +63 -0
  473. baseapp_core/tests/test_random_name_generators.py +56 -0
  474. baseapp_core/tests/test_settings.py +15 -0
  475. baseapp_core/tests/test_token_generator.py +72 -0
  476. baseapp_core/tokens.py +37 -0
  477. baseapp_core/utils.py +29 -0
  478. baseapp_core/uvicorn_workers.py +7 -0
  479. baseapp_core/wsgi.py +16 -0
  480. baseapp_drf_view_action_permissions/README.md +226 -0
  481. baseapp_drf_view_action_permissions/__init__.py +0 -0
  482. baseapp_drf_view_action_permissions/action.py +148 -0
  483. baseapp_drf_view_action_permissions/admin.py +21 -0
  484. baseapp_drf_view_action_permissions/apps.py +9 -0
  485. baseapp_drf_view_action_permissions/middleware.py +18 -0
  486. baseapp_drf_view_action_permissions/migrations/0001_initial.py +46 -0
  487. baseapp_drf_view_action_permissions/migrations/0002_iprestriction.py +45 -0
  488. baseapp_drf_view_action_permissions/migrations/__init__.py +0 -0
  489. baseapp_drf_view_action_permissions/mixin.py +43 -0
  490. baseapp_drf_view_action_permissions/models.py +65 -0
  491. baseapp_drf_view_action_permissions/settings.py +9 -0
  492. baseapp_drf_view_action_permissions/tests/__init__.py +0 -0
  493. baseapp_drf_view_action_permissions/tests/apps.py +7 -0
  494. baseapp_drf_view_action_permissions/tests/conftest.py +1 -0
  495. baseapp_drf_view_action_permissions/tests/factories.py +74 -0
  496. baseapp_drf_view_action_permissions/tests/migrations/0001_initial.py +136 -0
  497. baseapp_drf_view_action_permissions/tests/migrations/0002_testmodel.py +34 -0
  498. baseapp_drf_view_action_permissions/tests/migrations/__init__.py +0 -0
  499. baseapp_drf_view_action_permissions/tests/models.py +22 -0
  500. baseapp_drf_view_action_permissions/tests/settings.py +13 -0
  501. baseapp_drf_view_action_permissions/tests/test_integration.py +383 -0
  502. baseapp_drf_view_action_permissions/tests/test_unit.py +92 -0
  503. baseapp_drf_view_action_permissions/utils.py +67 -0
  504. baseapp_e2e/README.md +102 -0
  505. baseapp_e2e/__init__.py +0 -0
  506. baseapp_e2e/apps.py +9 -0
  507. baseapp_e2e/conf.py +36 -0
  508. baseapp_e2e/e2e_scripts/__init__.py +0 -0
  509. baseapp_e2e/e2e_scripts/demo.py +3 -0
  510. baseapp_e2e/rest_framework/__init__.py +0 -0
  511. baseapp_e2e/rest_framework/permissions.py +7 -0
  512. baseapp_e2e/rest_framework/serializers.py +28 -0
  513. baseapp_e2e/rest_framework/views.py +58 -0
  514. baseapp_e2e/tests/__init__.py +0 -0
  515. baseapp_e2e/tests/conftest.py +11 -0
  516. baseapp_e2e/tests/factories.py +8 -0
  517. baseapp_e2e/tests/fixtures.py +0 -0
  518. baseapp_e2e/tests/helpers.py +1 -0
  519. baseapp_e2e/tests/mixins.py +1 -0
  520. baseapp_e2e/tests/test_e2e_endpoints.py +97 -0
  521. baseapp_e2e/utils.py +8 -0
  522. baseapp_follows/README.md +85 -0
  523. baseapp_follows/__init__.py +0 -0
  524. baseapp_follows/admin.py +11 -0
  525. baseapp_follows/apps.py +9 -0
  526. baseapp_follows/graphql/__init__.py +0 -0
  527. baseapp_follows/graphql/interfaces.py +58 -0
  528. baseapp_follows/graphql/mutations.py +90 -0
  529. baseapp_follows/graphql/object_types.py +47 -0
  530. baseapp_follows/graphql/queries.py +9 -0
  531. baseapp_follows/migrations/0001_initial.py +77 -0
  532. baseapp_follows/migrations/0002_follow_new_actor_follow_new_target.py +52 -0
  533. baseapp_follows/migrations/0003_migrate_profiles.py +59 -0
  534. baseapp_follows/migrations/0004_alter_follow_unique_together_and_more.py +33 -0
  535. baseapp_follows/migrations/0005_rename_new_actor_follow_actor_and_more.py +23 -0
  536. baseapp_follows/migrations/0006_alter_follow_actor_alter_follow_target.py +35 -0
  537. baseapp_follows/migrations/0007_alter_follow_unique_together.py +19 -0
  538. baseapp_follows/migrations/0008_create_followstats_remap_fks.py +108 -0
  539. baseapp_follows/migrations/__init__.py +0 -0
  540. baseapp_follows/models.py +149 -0
  541. baseapp_follows/permissions.py +27 -0
  542. baseapp_follows/tests/__init__.py +0 -0
  543. baseapp_follows/tests/conftest.py +2 -0
  544. baseapp_follows/tests/factories.py +24 -0
  545. baseapp_follows/tests/test_follow_count.py +80 -0
  546. baseapp_follows/tests/test_graphql_mutations.py +162 -0
  547. baseapp_message_templates/README.md +404 -0
  548. baseapp_message_templates/__init__.py +0 -0
  549. baseapp_message_templates/admin.py +91 -0
  550. baseapp_message_templates/apps.py +9 -0
  551. baseapp_message_templates/custom_templates.py +100 -0
  552. baseapp_message_templates/email_utils.py +34 -0
  553. baseapp_message_templates/filters.py +40 -0
  554. baseapp_message_templates/migrations/0001_initial.py +135 -0
  555. baseapp_message_templates/migrations/0002_auto_20240108_1503.py +56 -0
  556. baseapp_message_templates/migrations/0003_alter_emailtemplate_name_alter_smstemplate_name.py +31 -0
  557. baseapp_message_templates/migrations/0004_alter_emailtemplate_html_content_and_more.py +29 -0
  558. baseapp_message_templates/migrations/__init__.py +0 -0
  559. baseapp_message_templates/models.py +123 -0
  560. baseapp_message_templates/sendgrid.py +60 -0
  561. baseapp_message_templates/sms_utils.py +14 -0
  562. baseapp_message_templates/static/baseapp_message_templates/prose/image_dialog.js +230 -0
  563. baseapp_message_templates/templates/admin/baseapp_message_templates/emailtemplate/change_form.html +6 -0
  564. baseapp_message_templates/tests/__init__.py +0 -0
  565. baseapp_message_templates/tests/conftest.py +1 -0
  566. baseapp_message_templates/tests/factories.py +13 -0
  567. baseapp_message_templates/tests/unit/__init__.py +0 -0
  568. baseapp_message_templates/tests/unit/test_templates.py +103 -0
  569. baseapp_message_templates/utils.py +37 -0
  570. baseapp_notifications/README.md +331 -0
  571. baseapp_notifications/__init__.py +3 -0
  572. baseapp_notifications/admin.py +12 -0
  573. baseapp_notifications/apps.py +9 -0
  574. baseapp_notifications/base.py +56 -0
  575. baseapp_notifications/graphql/__init__.py +0 -0
  576. baseapp_notifications/graphql/filters.py +16 -0
  577. baseapp_notifications/graphql/mutations.py +125 -0
  578. baseapp_notifications/graphql/object_types.py +122 -0
  579. baseapp_notifications/graphql/queries.py +0 -0
  580. baseapp_notifications/graphql/subscriptions.py +62 -0
  581. baseapp_notifications/locale/es/LC_MESSAGES/django.mo +0 -0
  582. baseapp_notifications/locale/es/LC_MESSAGES/django.po +39 -0
  583. baseapp_notifications/migrations/0001_initial.py +134 -0
  584. baseapp_notifications/migrations/0002_notificationsetting.py +64 -0
  585. baseapp_notifications/migrations/0003_rename_notification_recipient_unread_baseapp_not_recipie_8567c3_idx.py +18 -0
  586. baseapp_notifications/migrations/0004_notification_insert_document_id_and_more.py +74 -0
  587. baseapp_notifications/migrations/__init__.py +0 -0
  588. baseapp_notifications/models.py +26 -0
  589. baseapp_notifications/tasks.py +44 -0
  590. baseapp_notifications/templates/emails/notification-body.html.j2 +24 -0
  591. baseapp_notifications/templates/emails/notification-body.txt.j2 +7 -0
  592. baseapp_notifications/templates/emails/notification-subject.txt.j2 +1 -0
  593. baseapp_notifications/tests/__init__.py +0 -0
  594. baseapp_notifications/tests/conftest.py +2 -0
  595. baseapp_notifications/tests/factories.py +27 -0
  596. baseapp_notifications/tests/test_graphql_mutations.py +298 -0
  597. baseapp_notifications/tests/test_graphql_queries.py +85 -0
  598. baseapp_notifications/tests/test_graphql_subscriptions.py +160 -0
  599. baseapp_notifications/tests/test_utils.py +138 -0
  600. baseapp_notifications/utils.py +145 -0
  601. baseapp_organizations/README.md +1 -0
  602. baseapp_organizations/__init__.py +0 -0
  603. baseapp_organizations/admin.py +11 -0
  604. baseapp_organizations/apps.py +9 -0
  605. baseapp_organizations/graphql/__init__.py +0 -0
  606. baseapp_organizations/graphql/mutations.py +102 -0
  607. baseapp_organizations/graphql/object_types.py +34 -0
  608. baseapp_organizations/graphql/queries.py +9 -0
  609. baseapp_organizations/migrations/0001_initial.py +60 -0
  610. baseapp_organizations/migrations/0002_organization_name.py +18 -0
  611. baseapp_organizations/migrations/0003_alter_organization_profile.py +28 -0
  612. baseapp_organizations/migrations/__init__.py +0 -0
  613. baseapp_organizations/models.py +41 -0
  614. baseapp_organizations/permissions.py +11 -0
  615. baseapp_organizations/tests/__init__.py +0 -0
  616. baseapp_organizations/tests/conftest.py +2 -0
  617. baseapp_organizations/tests/factories.py +9 -0
  618. baseapp_organizations/tests/test_graphql_mutations_create.py +56 -0
  619. baseapp_pages/README.md +128 -0
  620. baseapp_pages/__init__.py +0 -0
  621. baseapp_pages/admin.py +51 -0
  622. baseapp_pages/apps.py +8 -0
  623. baseapp_pages/graphql/__init__.py +8 -0
  624. baseapp_pages/graphql/mutations.py +122 -0
  625. baseapp_pages/graphql/object_types.py +164 -0
  626. baseapp_pages/graphql/queries.py +41 -0
  627. baseapp_pages/meta.py +4 -0
  628. baseapp_pages/migrations/0001_initial.py +298 -0
  629. baseapp_pages/migrations/0002_page_pageevent_page_snapshot_insert_and_more.py +227 -0
  630. baseapp_pages/migrations/0003_remove_page_snapshot_insert_and_more.py +97 -0
  631. baseapp_pages/migrations/0004_alter_page_comments_count_and_more.py +33 -0
  632. baseapp_pages/migrations/0005_remove_metadata_snapshot_insert_and_more.py +155 -0
  633. baseapp_pages/migrations/0006_alter_metadataevent_pgh_context_and_more.py +62 -0
  634. baseapp_pages/migrations/0007_alter_metadataevent_pgh_context_and_more.py +58 -0
  635. baseapp_pages/migrations/0008_remove_pageevent_pgh_context_and_more.py +41 -0
  636. baseapp_pages/migrations/0009_metadata_insert_document_id_and_more.py +71 -0
  637. baseapp_pages/migrations/__init__.py +0 -0
  638. baseapp_pages/models.py +158 -0
  639. baseapp_pages/permissions.py +28 -0
  640. baseapp_pages/tests/__init__.py +0 -0
  641. baseapp_pages/tests/conftest.py +2 -0
  642. baseapp_pages/tests/factories.py +18 -0
  643. baseapp_pages/tests/test_create_mutation.py +106 -0
  644. baseapp_pages/tests/test_delete_mutation.py +95 -0
  645. baseapp_pages/tests/test_edit_mutation.py +123 -0
  646. baseapp_pages/tests/test_get_queries.py +318 -0
  647. baseapp_pages/tests/test_list_queries.py +68 -0
  648. baseapp_pages/tests/utils.py +2 -0
  649. baseapp_payments/README.md +148 -0
  650. baseapp_payments/__init__.py +0 -0
  651. baseapp_payments/admin.py +23 -0
  652. baseapp_payments/apps.py +6 -0
  653. baseapp_payments/migrations/0001_initial.py +32 -0
  654. baseapp_payments/migrations/0002_create_template_emails.py +44 -0
  655. baseapp_payments/migrations/0003_delete_plan.py +16 -0
  656. baseapp_payments/migrations/0004_initial.py +57 -0
  657. baseapp_payments/migrations/0005_customer_created_customer_modified_and_more.py +43 -0
  658. baseapp_payments/migrations/__init__.py +0 -0
  659. baseapp_payments/models.py +47 -0
  660. baseapp_payments/router.py +21 -0
  661. baseapp_payments/serializers.py +299 -0
  662. baseapp_payments/tests/__init__.py +0 -0
  663. baseapp_payments/tests/conftest.py +1 -0
  664. baseapp_payments/tests/factories.py +20 -0
  665. baseapp_payments/tests/test_customer_viewset.py +61 -0
  666. baseapp_payments/tests/test_payment_method_viewset.py +100 -0
  667. baseapp_payments/tests/test_stripe_utils.py +53 -0
  668. baseapp_payments/utils.py +448 -0
  669. baseapp_payments/views.py +243 -0
  670. baseapp_pdf/README.md +93 -0
  671. baseapp_pdf/__init__.py +0 -0
  672. baseapp_pdf/apps.py +9 -0
  673. baseapp_pdf/exceptions.py +11 -0
  674. baseapp_pdf/management/commands/render_example_template_to_pdf.py +116 -0
  675. baseapp_pdf/management/commands/render_to_pdf.py +48 -0
  676. baseapp_pdf/settings.py +1 -0
  677. baseapp_pdf/templates/pdfs/render-template-to-pdf-example.html +221 -0
  678. baseapp_pdf/tests/__init__.py +0 -0
  679. baseapp_pdf/tests/conftest.py +1 -0
  680. baseapp_pdf/tests/integration/__init__.py +0 -0
  681. baseapp_pdf/tests/integration/test_utils.py +105 -0
  682. baseapp_pdf/utils.py +153 -0
  683. baseapp_profiles/MIGRATION.md +62 -0
  684. baseapp_profiles/README.md +46 -0
  685. baseapp_profiles/__init__.py +0 -0
  686. baseapp_profiles/admin.py +28 -0
  687. baseapp_profiles/apps.py +9 -0
  688. baseapp_profiles/graphql/__init__.py +3 -0
  689. baseapp_profiles/graphql/filters.py +64 -0
  690. baseapp_profiles/graphql/middleware.py +39 -0
  691. baseapp_profiles/graphql/mutations.py +297 -0
  692. baseapp_profiles/graphql/object_types.py +158 -0
  693. baseapp_profiles/graphql/queries.py +11 -0
  694. baseapp_profiles/managers.py +11 -0
  695. baseapp_profiles/middleware.py +26 -0
  696. baseapp_profiles/migrations/0001_initial.py +127 -0
  697. baseapp_profiles/migrations/0002_profile_blockers_count_profile_blocking_count_and_more.py +55 -0
  698. baseapp_profiles/migrations/0003_profile_banner_image.py +25 -0
  699. baseapp_profiles/migrations/0004_profile_biography.py +18 -0
  700. baseapp_profiles/migrations/0005_profileuserrole_status.py +20 -0
  701. baseapp_profiles/migrations/0006_alter_profile_name.py +20 -0
  702. baseapp_profiles/migrations/0007_remove_profile_followers_count_and_more.py +21 -0
  703. baseapp_profiles/migrations/__init__.py +0 -0
  704. baseapp_profiles/models.py +258 -0
  705. baseapp_profiles/permissions.py +66 -0
  706. baseapp_profiles/signals.py +10 -0
  707. baseapp_profiles/tests/__init__.py +0 -0
  708. baseapp_profiles/tests/conftest.py +2 -0
  709. baseapp_profiles/tests/factories.py +20 -0
  710. baseapp_profiles/tests/test_get_queries.py +376 -0
  711. baseapp_profiles/tests/test_graphql_mutations_delete.py +91 -0
  712. baseapp_profiles/tests/test_graphql_mutations_update.py +379 -0
  713. baseapp_profiles/tests/test_middleware.py +50 -0
  714. baseapp_profiles/tests/test_url_path.py +36 -0
  715. baseapp_profiles/tests/utils.py +2 -0
  716. baseapp_ratings/README.md +149 -0
  717. baseapp_ratings/__init__.py +0 -0
  718. baseapp_ratings/admin.py +18 -0
  719. baseapp_ratings/apps.py +8 -0
  720. baseapp_ratings/graphql/__init__.py +0 -0
  721. baseapp_ratings/graphql/mutations.py +83 -0
  722. baseapp_ratings/graphql/object_types.py +84 -0
  723. baseapp_ratings/graphql/queries.py +9 -0
  724. baseapp_ratings/migrations/0001_initial.py +71 -0
  725. baseapp_ratings/migrations/0002_alter_rate_target_object_id.py +18 -0
  726. baseapp_ratings/migrations/0003_rate_profile.py +28 -0
  727. baseapp_ratings/migrations/__init__.py +0 -0
  728. baseapp_ratings/models.py +108 -0
  729. baseapp_ratings/permissions.py +40 -0
  730. baseapp_ratings/tests/__init__.py +0 -0
  731. baseapp_ratings/tests/conftest.py +2 -0
  732. baseapp_ratings/tests/factories.py +50 -0
  733. baseapp_ratings/tests/test_graphql_mutations.py +84 -0
  734. baseapp_ratings/tests/test_graphql_queries.py +51 -0
  735. baseapp_reactions/README.md +153 -0
  736. baseapp_reactions/__init__.py +0 -0
  737. baseapp_reactions/admin.py +11 -0
  738. baseapp_reactions/apps.py +12 -0
  739. baseapp_reactions/graphql/__init__.py +0 -0
  740. baseapp_reactions/graphql/mutations.py +97 -0
  741. baseapp_reactions/graphql/object_types.py +102 -0
  742. baseapp_reactions/graphql/queries.py +9 -0
  743. baseapp_reactions/management/commands/update_votings_count.py +12 -0
  744. baseapp_reactions/migrations/0001_initial.py +80 -0
  745. baseapp_reactions/migrations/0002_alter_reaction_id.py +20 -0
  746. baseapp_reactions/migrations/0003_reaction_profile.py +26 -0
  747. baseapp_reactions/migrations/0004_alter_reaction_unique_together_and_more.py +29 -0
  748. baseapp_reactions/migrations/__init__.py +0 -0
  749. baseapp_reactions/models.py +142 -0
  750. baseapp_reactions/notifications.py +37 -0
  751. baseapp_reactions/permissions.py +32 -0
  752. baseapp_reactions/signals.py +22 -0
  753. baseapp_reactions/tests/__init__.py +0 -0
  754. baseapp_reactions/tests/conftest.py +2 -0
  755. baseapp_reactions/tests/factories.py +32 -0
  756. baseapp_reactions/tests/test_graphql_mutations.py +198 -0
  757. baseapp_reactions/tests/test_graphql_queries.py +54 -0
  758. baseapp_reactions/tests/test_notifications.py +28 -0
  759. baseapp_referrals/__init__.py +0 -0
  760. baseapp_referrals/admin.py +11 -0
  761. baseapp_referrals/apps.py +9 -0
  762. baseapp_referrals/migrations/0001_initial.py +49 -0
  763. baseapp_referrals/migrations/__init__.py +0 -0
  764. baseapp_referrals/models.py +24 -0
  765. baseapp_referrals/pipeline.py +11 -0
  766. baseapp_referrals/tests/__init__.py +0 -0
  767. baseapp_referrals/tests/conftest.py +1 -0
  768. baseapp_referrals/tests/unit/__init__.py +0 -0
  769. baseapp_referrals/tests/unit/test_referrals_utils.py +22 -0
  770. baseapp_referrals/utils.py +22 -0
  771. baseapp_reports/README.md +140 -0
  772. baseapp_reports/__init__.py +0 -0
  773. baseapp_reports/admin.py +20 -0
  774. baseapp_reports/apps.py +9 -0
  775. baseapp_reports/graphql/__init__.py +1 -0
  776. baseapp_reports/graphql/filters.py +21 -0
  777. baseapp_reports/graphql/mutations.py +64 -0
  778. baseapp_reports/graphql/object_types.py +97 -0
  779. baseapp_reports/graphql/queries.py +24 -0
  780. baseapp_reports/management/commands/update_reports_count.py +12 -0
  781. baseapp_reports/migrations/0001_initial.py +79 -0
  782. baseapp_reports/migrations/0002_alter_report_report_type.py +22 -0
  783. baseapp_reports/migrations/0003_report_baseapp_rep_target__171117_idx.py +23 -0
  784. baseapp_reports/migrations/0004_alter_report_report_type_reporttype.py +77 -0
  785. baseapp_reports/migrations/0005_create_default_report_types_and_transfer_values.py +129 -0
  786. baseapp_reports/migrations/0006_delete_old_rename_new_report_type.py +20 -0
  787. baseapp_reports/migrations/__init__.py +0 -0
  788. baseapp_reports/models.py +153 -0
  789. baseapp_reports/permissions.py +16 -0
  790. baseapp_reports/tests/__init__.py +0 -0
  791. baseapp_reports/tests/conftest.py +2 -0
  792. baseapp_reports/tests/factories.py +36 -0
  793. baseapp_reports/tests/test_graphql_mutations.py +86 -0
  794. baseapp_reports/tests/test_graphql_queries.py +49 -0
  795. baseapp_social_auth/README.md +96 -0
  796. baseapp_social_auth/__init__.py +0 -0
  797. baseapp_social_auth/cache/__init__.py +0 -0
  798. baseapp_social_auth/cache/admin.py +5 -0
  799. baseapp_social_auth/cache/migrations/0001_initial.py +51 -0
  800. baseapp_social_auth/cache/migrations/0002_alter_socialauthaccesstokencache_id.py +19 -0
  801. baseapp_social_auth/cache/migrations/0003_alter_socialauthaccesstokencache_id.py +19 -0
  802. baseapp_social_auth/cache/migrations/0004_alter_socialauthaccesstokencache_id.py +20 -0
  803. baseapp_social_auth/cache/migrations/__init__.py +0 -0
  804. baseapp_social_auth/cache/models.py +24 -0
  805. baseapp_social_auth/cache/pipeline.py +54 -0
  806. baseapp_social_auth/cache/tasks.py +13 -0
  807. baseapp_social_auth/referrals.py +22 -0
  808. baseapp_social_auth/serializers.py +27 -0
  809. baseapp_social_auth/settings.py +73 -0
  810. baseapp_social_auth/tests/__init__.py +0 -0
  811. baseapp_social_auth/tests/conftest.py +1 -0
  812. baseapp_social_auth/tests/intergration/__init__.py +0 -0
  813. baseapp_social_auth/tests/intergration/test_views.py +485 -0
  814. baseapp_social_auth/tests/pipeline.py +85 -0
  815. baseapp_social_auth/tests/unit/__init__.py +0 -0
  816. baseapp_social_auth/tests/unit/test_tasks.py +24 -0
  817. baseapp_social_auth/views.py +139 -0
  818. baseapp_url_shortening/README.md +58 -0
  819. baseapp_url_shortening/__init__.py +0 -0
  820. baseapp_url_shortening/admin.py +16 -0
  821. baseapp_url_shortening/apps.py +9 -0
  822. baseapp_url_shortening/migrations/0001_initial.py +45 -0
  823. baseapp_url_shortening/migrations/0002_alter_shorturl_full_url.py +18 -0
  824. baseapp_url_shortening/migrations/__init__.py +0 -0
  825. baseapp_url_shortening/models.py +24 -0
  826. baseapp_url_shortening/tests/__init__.py +0 -0
  827. baseapp_url_shortening/tests/conftest.py +1 -0
  828. baseapp_url_shortening/tests/factories.py +13 -0
  829. baseapp_url_shortening/tests/integration/__init__.py +0 -0
  830. baseapp_url_shortening/tests/integration/test_url_shortening.py +17 -0
  831. baseapp_url_shortening/tests/settings.py +1 -0
  832. baseapp_url_shortening/urls.py +17 -0
  833. baseapp_url_shortening/utils.py +19 -0
  834. baseapp_url_shortening/views.py +10 -0
  835. baseapp_wagtail/MANIFEST.in +3 -0
  836. baseapp_wagtail/README.md +208 -0
  837. baseapp_wagtail/__init__.py +0 -0
  838. baseapp_wagtail/apps.py +9 -0
  839. baseapp_wagtail/base/__init__.py +0 -0
  840. baseapp_wagtail/base/apps.py +7 -0
  841. baseapp_wagtail/base/blocks/__init__.py +6 -0
  842. baseapp_wagtail/base/blocks/basic_blocks/__init__.py +0 -0
  843. baseapp_wagtail/base/blocks/basic_blocks/custom_image_block/__init__.py +1 -0
  844. baseapp_wagtail/base/blocks/basic_blocks/custom_image_block/block.py +30 -0
  845. baseapp_wagtail/base/blocks/basic_blocks/custom_image_block/tests/test_custom_image_block.py +20 -0
  846. baseapp_wagtail/base/blocks/basic_blocks/custom_image_chooser_block/__init__.py +1 -0
  847. baseapp_wagtail/base/blocks/basic_blocks/custom_image_chooser_block/block.py +32 -0
  848. baseapp_wagtail/base/blocks/basic_blocks/custom_image_chooser_block/tests/test_custom_image_chooser_block.py +32 -0
  849. baseapp_wagtail/base/blocks/basic_blocks/custom_rich_text_block/__init__.py +1 -0
  850. baseapp_wagtail/base/blocks/basic_blocks/custom_rich_text_block/block.py +8 -0
  851. baseapp_wagtail/base/blocks/basic_blocks/custom_rich_text_block/tests/test_custom_rich_text_block.py +18 -0
  852. baseapp_wagtail/base/blocks/custom_blocks/__init__.py +0 -0
  853. baseapp_wagtail/base/blocks/custom_blocks/banner_block/__init__.py +1 -0
  854. baseapp_wagtail/base/blocks/custom_blocks/banner_block/block.py +49 -0
  855. baseapp_wagtail/base/blocks/custom_blocks/banner_block/tests/test_banner_block.py +28 -0
  856. baseapp_wagtail/base/models.py +75 -0
  857. baseapp_wagtail/base/rest_framework/__init__.py +0 -0
  858. baseapp_wagtail/base/rest_framework/page_preview/__init__.py +0 -0
  859. baseapp_wagtail/base/rest_framework/page_preview/views.py +35 -0
  860. baseapp_wagtail/base/rest_framework/pages/__init__.py +0 -0
  861. baseapp_wagtail/base/rest_framework/pages/serializers.py +83 -0
  862. baseapp_wagtail/base/rest_framework/pages/views.py +62 -0
  863. baseapp_wagtail/base/rest_framework/redirects/__init__.py +0 -0
  864. baseapp_wagtail/base/rest_framework/redirects/views.py +78 -0
  865. baseapp_wagtail/base/rest_framework/router.py +20 -0
  866. baseapp_wagtail/base/rest_framework/sitemap/__init__.py +0 -0
  867. baseapp_wagtail/base/rest_framework/sitemap/serializers.py +7 -0
  868. baseapp_wagtail/base/rest_framework/sitemap/views.py +34 -0
  869. baseapp_wagtail/base/rest_framework/tests/factories.py +11 -0
  870. baseapp_wagtail/base/rest_framework/tests/test_api_pages.py +107 -0
  871. baseapp_wagtail/base/rest_framework/tests/test_api_redirects.py +88 -0
  872. baseapp_wagtail/base/rest_framework/tests/test_api_sitemap.py +43 -0
  873. baseapp_wagtail/base/stream_fields/__init__.py +6 -0
  874. baseapp_wagtail/base/stream_fields/featured_image_stream_field.py +20 -0
  875. baseapp_wagtail/base/stream_fields/page_body_stream_field.py +42 -0
  876. baseapp_wagtail/base/stream_fields/standard_page_stream_block.py +8 -0
  877. baseapp_wagtail/base/tests/test_base_models.py +93 -0
  878. baseapp_wagtail/base/tests/test_base_wagtail_hooks.py +20 -0
  879. baseapp_wagtail/base/wagtail_hooks.py +28 -0
  880. baseapp_wagtail/locale/__init__.py +0 -0
  881. baseapp_wagtail/locale/utils.py +9 -0
  882. baseapp_wagtail/management/__init__.py +0 -0
  883. baseapp_wagtail/management/commands/__init__.py +0 -0
  884. baseapp_wagtail/management/commands/wagtail_revert_package_migrations.py +59 -0
  885. baseapp_wagtail/medias/__init__.py +0 -0
  886. baseapp_wagtail/medias/apps.py +7 -0
  887. baseapp_wagtail/medias/image_formats.py +24 -0
  888. baseapp_wagtail/medias/migrations/0001_initial.py +193 -0
  889. baseapp_wagtail/medias/migrations/0002_customimage_description_and_more.py +25 -0
  890. baseapp_wagtail/medias/migrations/__init__.py +0 -0
  891. baseapp_wagtail/medias/models.py +52 -0
  892. baseapp_wagtail/medias/rest_framework/__init__.py +0 -0
  893. baseapp_wagtail/medias/rest_framework/router.py +8 -0
  894. baseapp_wagtail/medias/serializers.py +39 -0
  895. baseapp_wagtail/medias/tests/factories.py +24 -0
  896. baseapp_wagtail/medias/tests/test_medias_models.py +35 -0
  897. baseapp_wagtail/medias/tests/test_medias_wagtail_hooks.py +42 -0
  898. baseapp_wagtail/medias/wagtail_hooks.py +19 -0
  899. baseapp_wagtail/settings.py +84 -0
  900. baseapp_wagtail/setup_test_migrations.sh +22 -0
  901. baseapp_wagtail/static/baseapp_wagtail/js/section-stream-block.js +77 -0
  902. baseapp_wagtail/templates/blocks/empty.html +3 -0
  903. baseapp_wagtail/templates/pages/empty.html +3 -0
  904. baseapp_wagtail/templates/wagtailadmin/shared/page_status_tag.html +12 -0
  905. baseapp_wagtail/tests/apps.py +5 -0
  906. baseapp_wagtail/tests/conftest.py +1 -0
  907. baseapp_wagtail/tests/factories/wagtail_factories.py +25 -0
  908. baseapp_wagtail/tests/migrations/0001_initial.py +279 -0
  909. baseapp_wagtail/tests/migrations/0002_delete_standardpage.py +16 -0
  910. baseapp_wagtail/tests/migrations/__init__.py +0 -0
  911. baseapp_wagtail/tests/mixins.py +94 -0
  912. baseapp_wagtail/tests/models.py +28 -0
  913. baseapp_wagtail/tests/utils/blocks_helpers.py +43 -0
  914. baseapp_wagtail/tests/utils/media_helper.py +18 -0
  915. baseapp_wagtail/urls.py +19 -0
baseapp/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # BaseApp
2
+
3
+ BaseApp is a Django project template that provides a set of tools and best practices for building web applications.
4
+
5
+ ## Requirements:
6
+
7
+ Run `pip install baseapp-backend`
8
+ And make sure to add the frozen version to your `requirements/base.txt` file
9
+
10
+ If you want to develop, [install using this other guide](#how-to-develop).
11
+
12
+ ## How to use
13
+
14
+ Then enable the desired apps in your Django project's `INSTALLED_APPS` setting:
15
+
16
+ ```python
17
+ INSTALLED_APPS = [
18
+ ...
19
+ 'baseapp.activity_log',
20
+ ...
21
+ ]
22
+ ```
23
+
24
+ ## Features
25
+
26
+ ## How to develop
27
+
28
+ Clone the project inside your project's backend dir:
29
+
30
+ ```
31
+ git clone git@github.com:silverlogic/baseapp-backend.git
32
+ ```
33
+
34
+ And manually install the package:
35
+
36
+ ```
37
+ pip install -e baseapp-backend/baseapp
38
+ ```
39
+
40
+ The `-e` flag will make it like any change you make in the cloned repo files will effect into the project.
baseapp/__init__.py ADDED
@@ -0,0 +1,6 @@
1
+ from importlib.metadata import PackageNotFoundError, version
2
+
3
+ try:
4
+ __version__ = version("baseapp_backend")
5
+ except PackageNotFoundError:
6
+ __version__ = None
@@ -0,0 +1,104 @@
1
+ # BaseApp Activity Log
2
+
3
+ This app exposes an API to view user's activities that are being tracked by the system.
4
+
5
+ ## Installation
6
+
7
+ ### Requirements:
8
+
9
+ You need to have [django-pghistory](https://github.com/Opus10/django-pghistory) installed in your project and models that you want to track should be tracked by pghistory:
10
+
11
+ ```python
12
+ import pghistory
13
+
14
+ @pghistory.track()
15
+ class TrackedModel(models.Model):
16
+ int_field = models.IntegerField()
17
+ text_field = models.TextField()
18
+ ```
19
+
20
+ Add `baseapp.activity_log` to your `INSTALLED_APPS` setting:
21
+
22
+ ```python
23
+ INSTALLED_APPS = [
24
+ ...
25
+ 'baseapp.activity_log',
26
+ ]
27
+ ```
28
+
29
+ Add `HistoryMiddleware` to the `MIDDLEWARE` list in the `settings.py` file:
30
+
31
+ ```python
32
+ MIDDLEWARE = [
33
+ ...
34
+ 'baseapp.activity_log.middleware.HistoryMiddleware',
35
+ ]
36
+ ```
37
+
38
+ Add `ActivityLogPermissionsBackend` to the `AUTHENTICATION_BACKENDS` list in the `settings.py` file:
39
+
40
+ ```python
41
+ AUTHENTICATION_BACKENDS = [
42
+ ...
43
+ "baseapp.activity_log.permissions.ActivityLogPermissionsBackend",
44
+ ]
45
+ ```
46
+
47
+ Add `ActivityLogQueries` to your GraphQL schema:
48
+
49
+ ```python
50
+ from baseapp.activity_log.schema import ActivityLogQueries
51
+
52
+ class Query(ActivityLogQueries, graphene.ObjectType):
53
+ pass
54
+
55
+ schema = graphene.Schema(query=Query)
56
+ ```
57
+
58
+ ## Usage
59
+
60
+ By default users only have access to public activities. To log an activity as public use the `set_public_activity` function:
61
+
62
+ ```python
63
+ from baseapp.activity_log.context import set_public_activity
64
+
65
+ def create_comment(request, body):
66
+ # ...
67
+ set_public_activity(verb="baseapp_comments.add_comment")
68
+ ```
69
+
70
+ ### GraphQL
71
+
72
+ This packages provides the following interfaces that can be used to expose the activity logs for user, profile and specific models:
73
+
74
+ - `NodeActivityLogInterface`
75
+ - `UserActivityLog`
76
+ - `ProfileActivityLog`
77
+
78
+ This app also exposes a query to fetch a global list of activities:
79
+
80
+ ```graphql
81
+ {
82
+ activityLogs(visibility: PUBLIC, first: 10) {
83
+ edges {
84
+ node {
85
+ id
86
+ verb
87
+ profile {
88
+ name
89
+ }
90
+ events {
91
+ diff
92
+ label
93
+ obj {
94
+ ... on Comment {
95
+ body
96
+ }
97
+ }
98
+ }
99
+ createdAt
100
+ }
101
+ }
102
+ }
103
+ }
104
+ ```
File without changes
File without changes
@@ -0,0 +1,9 @@
1
+ from django.apps import AppConfig
2
+
3
+
4
+ class PackageConfig(AppConfig):
5
+ default = True
6
+ name = "baseapp.activity_log"
7
+ label = "baseapp_activity_log"
8
+ verbose_name = "BaseApp Activity Log"
9
+ default_auto_field = "django.db.models.BigAutoField"
@@ -0,0 +1,15 @@
1
+ from typing import Any
2
+
3
+ import pghistory
4
+
5
+ from .models import VisibilityTypes
6
+
7
+
8
+ def set_public_activity(verb: str, **kwargs: Any) -> None:
9
+ """Set public visibility context for activity logging.
10
+
11
+ Args:
12
+ verb: The action verb describing the activity (e.g., 'create', 'update')
13
+ **kwargs: Additional context parameters to be logged
14
+ """
15
+ pghistory.context(visibility=VisibilityTypes.PUBLIC, verb=verb, **kwargs)
File without changes
@@ -0,0 +1,40 @@
1
+ import django_filters
2
+ from django.core.exceptions import ValidationError
3
+ from django.db.models import Q
4
+
5
+ from ..models import ActivityLog
6
+
7
+
8
+ class ActivityLogFilter(django_filters.FilterSet):
9
+ created_from = django_filters.DateFilter(field_name="created_at", lookup_expr="date__gte")
10
+ created_to = django_filters.DateFilter(field_name="created_at", lookup_expr="date__lte")
11
+ user_pk = django_filters.NumberFilter(field_name="user_id")
12
+ profile_pk = django_filters.NumberFilter(field_name="profile_id")
13
+ user_name = django_filters.CharFilter(method="filter_user_name")
14
+
15
+ def filter_user_name(self, queryset, name, value):
16
+ return queryset.filter(
17
+ Q(user__profile__name__icontains=value) | Q(user__email__icontains=value)
18
+ )
19
+
20
+ def filter_queryset(self, queryset):
21
+ created_from = self.data.get("created_from")
22
+ created_to = self.data.get("created_to")
23
+
24
+ if created_from and created_to and created_from > created_to:
25
+ raise ValidationError("`created_from` must be earlier than or equal to `created_to`.")
26
+ return super().filter_queryset(queryset)
27
+
28
+ class Meta:
29
+ model = ActivityLog
30
+ fields = ["created_from", "created_to", "user_pk", "profile_pk", "user_name"]
31
+
32
+
33
+ class MiddlewareEventFilter(django_filters.FilterSet):
34
+ created_from = django_filters.DateFilter(field_name="pgh_created_at__gte")
35
+ created_to = django_filters.DateFilter(field_name="pgh_created_at__lte")
36
+ user_pk = django_filters.NumberFilter(field_name="user_id")
37
+
38
+ class Meta:
39
+ model = ActivityLog
40
+ fields = ["created_from", "created_to", "user_pk"]
@@ -0,0 +1,50 @@
1
+ import graphene
2
+ from graphene_django.filter import DjangoFilterConnectionField
3
+
4
+ from ..models import ActivityLog
5
+ from .object_types import ActivityLogObjectType, VisibilityTypesEnum
6
+
7
+
8
+ class NodeActivityLogInterface(graphene.Interface):
9
+ node_activity_logs = DjangoFilterConnectionField(
10
+ ActivityLogObjectType,
11
+ visibility=VisibilityTypesEnum(),
12
+ first=graphene.Int(default_value=10),
13
+ max_limit=100,
14
+ )
15
+
16
+ def resolve_node_activity_logs(self, info, **kwargs):
17
+ if not info.context.user.has_perm("activity_log.list_node_activitylog", self):
18
+ return ActivityLog.objects.none()
19
+ context_ids = self.pgh_event_model.objects.filter(pgh_obj_id=self.pk).values_list(
20
+ "pgh_context_id", flat=True
21
+ )
22
+ return ActivityLog.objects.filter(pk__in=context_ids)
23
+
24
+
25
+ class UserActivityLog:
26
+ activity_logs = DjangoFilterConnectionField(
27
+ ActivityLogObjectType,
28
+ visibility=VisibilityTypesEnum(),
29
+ first=graphene.Int(default_value=10),
30
+ max_limit=100,
31
+ )
32
+
33
+ def resolve_activity_logs(self, info, **kwargs):
34
+ if not info.context.user.has_perm("activity_log.list_user_activitylog", self):
35
+ return ActivityLog.objects.none()
36
+ return ActivityLog.objects.filter(user_id=self.pk)
37
+
38
+
39
+ class ProfileActivityLog:
40
+ activity_logs = DjangoFilterConnectionField(
41
+ ActivityLogObjectType,
42
+ visibility=VisibilityTypesEnum(),
43
+ first=graphene.Int(default_value=10),
44
+ max_limit=100,
45
+ )
46
+
47
+ def resolve_activity_logs(self, info, **kwargs):
48
+ if not info.context.user.has_perm("activity_log.list_profile_activitylog", self):
49
+ return ActivityLog.objects.none()
50
+ return ActivityLog.objects.filter(profile_id=self.pk)
@@ -0,0 +1,133 @@
1
+ import graphene
2
+ import swapper
3
+ from django.apps import apps
4
+ from django.contrib.auth import get_user_model
5
+ from graphene.types.generic import GenericScalar
6
+ from graphene_django.filter import DjangoFilterConnectionField
7
+ from pghistory.models import MiddlewareEvents
8
+
9
+ from baseapp_core.graphql import DjangoObjectType
10
+ from baseapp_core.graphql import Node as RelayNode
11
+ from baseapp_core.graphql import get_object_type_for_model
12
+
13
+ from ..models import ActivityLog, VisibilityTypes
14
+ from .filters import ActivityLogFilter, MiddlewareEventFilter
15
+
16
+ User = get_user_model()
17
+ Profile = swapper.load_model("baseapp_profiles", "Profile")
18
+ VisibilityTypesEnum = graphene.Enum.from_enum(VisibilityTypes)
19
+
20
+
21
+ class NodeLogEventObjectType(DjangoObjectType):
22
+ obj = graphene.Field(RelayNode, description="The object of the event.")
23
+ label = graphene.String(description="The event label.")
24
+ data = GenericScalar(description="The raw data of the event.")
25
+ diff = GenericScalar(description="The diff between the previous event of the same label.")
26
+ created_at = graphene.DateTime(description="When the event was created.")
27
+
28
+ class Meta:
29
+ interfaces = (RelayNode,)
30
+ model = MiddlewareEvents
31
+ name = "NodeLogEvent"
32
+ fields = (
33
+ "id",
34
+ "obj",
35
+ "data",
36
+ "created_at",
37
+ "diff",
38
+ "user",
39
+ "label",
40
+ )
41
+ filterset_class = MiddlewareEventFilter
42
+
43
+ def resolve_data(self, info, **kwargs):
44
+ if info.context.user.has_perm("activity_log.view_nodelogevent-data", self):
45
+ return self.pgh_data
46
+
47
+ def resolve_obj(self, info, **kwargs):
48
+ Model = apps.get_model(self.pgh_obj_model)
49
+ try:
50
+ return Model.objects.get(pk=self.pgh_obj_id)
51
+ except Model.DoesNotExist:
52
+ return None
53
+
54
+ def resolve_created_at(self, info, **kwargs):
55
+ return self.pgh_created_at
56
+
57
+ def resolve_diff(self, info, **kwargs):
58
+ if info.context.user.has_perm("activity_log.view_nodelogevent-diff", self):
59
+ return self.pgh_diff
60
+
61
+ def resolve_label(self, info, **kwargs):
62
+ return self.pgh_label
63
+
64
+
65
+ class BaseActivityLogObjectType:
66
+ metadata = GenericScalar()
67
+ events = DjangoFilterConnectionField(lambda: NodeLogEventObjectType)
68
+ user = graphene.Field(get_object_type_for_model(User))
69
+ profile = graphene.Field(get_object_type_for_model(Profile))
70
+ visibility = graphene.Field(VisibilityTypesEnum)
71
+ verb = graphene.String()
72
+ ip_address = graphene.String()
73
+ url = graphene.String()
74
+
75
+ @classmethod
76
+ def get_node(cls, info, id):
77
+ try:
78
+ obj = cls._meta.model.objects.get(id=id)
79
+ if not info.context.user.has_perm("activity_log.view_activitylog", obj):
80
+ return None
81
+ return obj
82
+
83
+ except cls._meta.model.DoesNotExist:
84
+ return None
85
+
86
+ @classmethod
87
+ def get_queryset(cls, queryset, info):
88
+ if not info.context.user.has_perm("activity_log.list_activitylog_any_visibility"):
89
+ queryset = queryset.filter(visibility=VisibilityTypes.PUBLIC)
90
+ return queryset
91
+
92
+ class Meta:
93
+ interfaces = (RelayNode,)
94
+ model = ActivityLog
95
+ fields = (
96
+ "id",
97
+ "pk",
98
+ "user",
99
+ "url",
100
+ "verb",
101
+ "events",
102
+ "visibility",
103
+ "ip_address",
104
+ "created_at",
105
+ "updated_at",
106
+ )
107
+ filterset_class = ActivityLogFilter
108
+
109
+ def resolve_events(self, info, **kwargs):
110
+ return MiddlewareEvents.objects.filter(pgh_context_id=self.pk)
111
+
112
+ def resolve_user(self, info, **kwargs):
113
+ user_id = getattr(self, "user_id", None)
114
+ if user_id is not None:
115
+ try:
116
+ return User.objects.get(pk=user_id)
117
+ except User.DoesNotExist:
118
+ return None
119
+ return getattr(self, "user", None)
120
+
121
+ def resolve_profile(self, info, **kwargs):
122
+ profile_id = getattr(self, "profile_id", None)
123
+ if profile_id is not None:
124
+ try:
125
+ return Profile.objects.get(pk=profile_id)
126
+ except Profile.DoesNotExist:
127
+ return None
128
+ return getattr(self, "profile", None)
129
+
130
+
131
+ class ActivityLogObjectType(BaseActivityLogObjectType, DjangoObjectType):
132
+ class Meta(BaseActivityLogObjectType.Meta):
133
+ pass
@@ -0,0 +1,17 @@
1
+ import graphene
2
+ from graphene_django.filter import DjangoFilterConnectionField
3
+
4
+ from ..models import ActivityLog
5
+ from .object_types import ActivityLogObjectType, VisibilityTypesEnum
6
+
7
+
8
+ class ActivityLogQueries:
9
+ activity_logs = DjangoFilterConnectionField(
10
+ ActivityLogObjectType,
11
+ visibility=VisibilityTypesEnum(),
12
+ first=graphene.Int(default_value=10),
13
+ max_limit=100,
14
+ )
15
+
16
+ def resolve_activity_logs(self, info, visibility=None, **kwargs):
17
+ return ActivityLog.objects.all()
@@ -0,0 +1,49 @@
1
+ import channels_graphql_ws
2
+ import graphene
3
+ from channels.db import database_sync_to_async
4
+
5
+ from baseapp_core.graphql import get_obj_from_relay_id
6
+
7
+ from .object_types import ActivityLogObjectType
8
+
9
+
10
+ class OnNewActivityLogMessage(channels_graphql_ws.Subscription):
11
+ message = graphene.Field(lambda: ActivityLogObjectType._meta.connection.Edge)
12
+
13
+ class Arguments:
14
+ room_id = graphene.ID(required=True)
15
+
16
+ @staticmethod
17
+ def subscribe(root, info, room_id):
18
+ room = database_sync_to_async(get_obj_from_relay_id)(info, room_id)
19
+
20
+ user = info.context.channels_scope["user"]
21
+ if not user.is_authenticated or not database_sync_to_async(user.has_perm)(
22
+ "activity_log.view_activitylog", room
23
+ ):
24
+ return []
25
+ return [room_id]
26
+
27
+ @staticmethod
28
+ def publish(payload, info, room_id):
29
+ message = payload["message"]
30
+ user = info.context.channels_scope["user"]
31
+
32
+ if not user.is_authenticated:
33
+ return None
34
+
35
+ return OnNewActivityLogMessage(
36
+ message=ActivityLogObjectType._meta.connection.Edge(node=message)
37
+ )
38
+
39
+ @classmethod
40
+ def new_message(cls, message, room_id):
41
+ cls.broadcast(
42
+ group=room_id,
43
+ payload={"message": message},
44
+ )
45
+ OnNewActivityLogMessage.new_message(message=message)
46
+
47
+
48
+ class ActivityLogSubscriptions:
49
+ on_new_activity_log = OnNewActivityLogMessage.Field()
@@ -0,0 +1,92 @@
1
+ import pghistory
2
+ from django.core.handlers.asgi import ASGIRequest as DjangoASGIRequest
3
+ from django.core.handlers.wsgi import WSGIRequest as DjangoWSGIRequest
4
+ from ipware import get_client_ip
5
+ from pghistory import config
6
+
7
+ # The default meta precedence order
8
+ IPWARE_META_PRECEDENCE_ORDER = (
9
+ "X_FORWARDED_FOR",
10
+ "HTTP_X_FORWARDED_FOR",
11
+ "HTTP_CLIENT_IP",
12
+ "HTTP_X_REAL_IP",
13
+ "HTTP_X_FORWARDED",
14
+ "HTTP_X_CLUSTER_CLIENT_IP",
15
+ "HTTP_FORWARDED_FOR",
16
+ "HTTP_FORWARDED",
17
+ "HTTP_CF_CONNECTING_IP",
18
+ "X-CLIENT-IP",
19
+ "X-REAL-IP",
20
+ "X-CLUSTER-CLIENT-IP",
21
+ "X_FORWARDED",
22
+ "FORWARDED_FOR",
23
+ "CF-CONNECTING-IP",
24
+ "TRUE-CLIENT-IP",
25
+ "FASTLY-CLIENT-IP",
26
+ "FORWARDED",
27
+ "CLIENT-IP",
28
+ "REMOTE_ADDR",
29
+ )
30
+
31
+
32
+ class DjangoRequest:
33
+ """
34
+ Although Django's auth middleware sets the user in middleware,
35
+ apps like django-rest-framework set the user in the view layer.
36
+ This creates issues for pghistory tracking since the context needs
37
+ to be set before DB operations happen.
38
+
39
+ This special WSGIRequest updates pghistory context when
40
+ the request.user attribute is updated.
41
+ """
42
+
43
+ def __setattr__(self, attr, value):
44
+ if attr == "user":
45
+ pghistory.context(user=value.pk if value and hasattr(value, "pk") else None)
46
+
47
+ return super().__setattr__(attr, value)
48
+
49
+
50
+ class WSGIRequest(DjangoRequest, DjangoWSGIRequest):
51
+ pass
52
+
53
+
54
+ class ASGIRequest(DjangoRequest, DjangoASGIRequest):
55
+ pass
56
+
57
+
58
+ def HistoryMiddleware(get_response):
59
+ def middleware(request):
60
+ if request.method in config.middleware_methods():
61
+ user = (
62
+ request.user.pk
63
+ if hasattr(request, "user") and hasattr(request.user, "pk")
64
+ else None
65
+ )
66
+ profile = (
67
+ request.user.current_profile.pk
68
+ if hasattr(request.user, "current_profile")
69
+ and hasattr(request.user.current_profile, "pk")
70
+ else None
71
+ )
72
+ client_ip, is_routable = get_client_ip(
73
+ request, request_header_order=IPWARE_META_PRECEDENCE_ORDER
74
+ )
75
+
76
+ with pghistory.context(
77
+ user=user,
78
+ profile=profile,
79
+ url=request.path,
80
+ ip_address=client_ip,
81
+ is_ip_routable=is_routable,
82
+ ):
83
+ if isinstance(request, DjangoWSGIRequest): # pragma: no branch
84
+ request.__class__ = WSGIRequest
85
+ elif isinstance(request, DjangoASGIRequest): # pragma: no branch
86
+ request.__class__ = ASGIRequest
87
+
88
+ return get_response(request)
89
+ else:
90
+ return get_response(request)
91
+
92
+ return middleware
@@ -0,0 +1,25 @@
1
+ # Generated by Django 5.0.1 on 2024-11-03 00:29
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+
8
+ initial = True
9
+
10
+ dependencies = [
11
+ ("pghistory", "0006_delete_aggregateevent"),
12
+ ]
13
+
14
+ operations = [
15
+ migrations.CreateModel(
16
+ name="ActivityLog",
17
+ fields=[],
18
+ options={
19
+ "proxy": True,
20
+ "indexes": [],
21
+ "constraints": [],
22
+ },
23
+ bases=("pghistory.context", models.Model),
24
+ ),
25
+ ]
@@ -0,0 +1,29 @@
1
+ # Generated by Django 5.1.4 on 2024-12-16 18:04
2
+
3
+ from django.db import migrations
4
+
5
+ CREATE_SQL = """
6
+ create or replace view v_activity_log as select
7
+ pc.id as id,
8
+ pc.created_at as created_at,
9
+ pc.updated_at as updated_at,
10
+ nullif(metadata->>'user', '')::int8 as user_id,
11
+ nullif(metadata->>'profile', '')::int8 as profile_id,
12
+ metadata->>'url' as url,
13
+ metadata->>'verb' as verb,
14
+ nullif(metadata->>'visibility', '')::int4 as visibility,
15
+ metadata->>'ip_address' as ip_address,
16
+ metadata
17
+ from pghistory_context pc
18
+ """
19
+
20
+ DROP_SQL = "drop view if exists v_activity_log"
21
+
22
+
23
+ class Migration(migrations.Migration):
24
+
25
+ dependencies = [
26
+ ("baseapp_activity_log", "0001_initial"),
27
+ ]
28
+
29
+ operations = [migrations.RunSQL(sql=CREATE_SQL, reverse_sql=DROP_SQL)]
@@ -0,0 +1,38 @@
1
+ # Generated by Django 5.1.4 on 2024-12-16 18:08
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+
8
+ dependencies = [
9
+ ("baseapp_activity_log", "0002_auto_20241216_1804"),
10
+ ]
11
+
12
+ operations = [
13
+ migrations.DeleteModel(
14
+ name="ActivityLog",
15
+ ),
16
+ migrations.CreateModel(
17
+ name="ActivityLog",
18
+ fields=[
19
+ (
20
+ "id",
21
+ models.BigAutoField(
22
+ auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
23
+ ),
24
+ ),
25
+ ("created_at", models.DateTimeField()),
26
+ ("updated_at", models.DateTimeField()),
27
+ ("ip_address", models.TextField()),
28
+ ("verb", models.TextField()),
29
+ ("visibility", models.TextField()),
30
+ ("url", models.TextField()),
31
+ ("metadata", models.JSONField()),
32
+ ],
33
+ options={
34
+ "db_table": "v_activity_log",
35
+ "managed": False,
36
+ },
37
+ ),
38
+ ]
File without changes