diff --git a/.gitignore b/.gitignore index e15106e..8263906 100644 --- a/.gitignore +++ b/.gitignore @@ -214,3 +214,4 @@ __marimo__/ # Streamlit .streamlit/secrets.toml +config* diff --git a/TODO.txt b/TODO.txt index e1e4a5f..b7b8bf6 100644 --- a/TODO.txt +++ b/TODO.txt @@ -13,10 +13,10 @@ DOMINIC --- [x] list user api endpoint [x] CSS [x] Assets -[ ] Pick better anonymous avatar -[ ] figure out backing up DB -[ ] soft-release -[ ] Domain +[x] Pick better anonymous avatar +[x] figure out backing up DB +[x] soft-release +[x] GET Domain [ ] email notifications when user signs up: disroot email [ ] maybe start sending emails to users automatically too [ ] full-release diff --git a/cwr/settings.py b/cwr/settings.py index 9bdf66e..bd37622 100644 --- a/cwr/settings.py +++ b/cwr/settings.py @@ -1,6 +1,8 @@ import os from pathlib import Path +from config import ADMIN_EMAIL_PASSWORD + # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent @@ -121,3 +123,9 @@ LOGOUT_REDIRECT_URL = "login" DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' +EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' +EMAIL_HOST = 'smtp.purelymail.com' +EMAIL_PORT = 587 +EMAIL_USE_TLS = True +EMAIL_HOST_USER = 'admin@christian-webring.org' +EMAIL_HOST_PASSWORD = ADMIN_EMAIL_PASSWORD diff --git a/cwr/urls.py b/cwr/urls.py index 2548015..e812174 100644 --- a/cwr/urls.py +++ b/cwr/urls.py @@ -1,7 +1,7 @@ from django.contrib import admin from django.urls import path, include -from web.views import signup, forum_threads, thread, custom_logout, profile, user_profile, denied, users +from web.views import signup, forum_threads, thread, custom_logout, profile, user_profile, denied, users, code_of_ethics, test_email urlpatterns = [ path('markdownx/', include('markdownx.urls')), @@ -12,9 +12,10 @@ urlpatterns = [ path("accounts/profile/", profile, name="profile"), path("accounts/user/", user_profile, name="user"), path("accounts/denied/", denied, name="denied"), + path("code_of_ethics", code_of_ethics, name="code_of_ethics"), path('logout/', custom_logout, name='custom_logout'), path("", forum_threads, name='index'), path("forum/threads/", forum_threads, name='forum_threads'), path("forum/thread/", thread, name='thread'), - # path("test/", test_endpoint, name='test'), + path("test/", test_email, name='test'), ] diff --git a/web/templates/base.html b/web/templates/base.html index 08311c8..03cb375 100644 --- a/web/templates/base.html +++ b/web/templates/base.html @@ -191,6 +191,7 @@
Forum Profile + Code of Ethics Logout
diff --git a/web/templates/code_of_ethics.html b/web/templates/code_of_ethics.html new file mode 100644 index 0000000..e294c90 --- /dev/null +++ b/web/templates/code_of_ethics.html @@ -0,0 +1,82 @@ + +{% extends "base.html" %} +{% block content %} +

Code Of Ethics

+

Code of Ethics has been borrowed from SQLite's Code of Ethics

+
    +
  1. First of all, love the Lord God with your whole heart, your whole soul, and your whole strength.
  2. +
  3. Then, love your neighbor as yourself.
  4. +
  5. Do not murder.
  6. +
  7. Do not commit adultery.
  8. +
  9. Do not steal.
  10. +
  11. Do not covet.
  12. +
  13. Do not bear false witness.
  14. +
  15. Honor all people.
  16. +
  17. Do not do to another what you would not have done to yourself.
  18. +
  19. Deny oneself in order to follow Christ.
  20. +
  21. Chastise the body.
  22. +
  23. Do not become attached to pleasures.
  24. +
  25. Love fasting.
  26. +
  27. Relieve the poor.
  28. +
  29. Clothe the naked.
  30. +
  31. Visit the sick.
  32. +
  33. Bury the dead.
  34. +
  35. Be a help in times of trouble.
  36. +
  37. Console the sorrowing.
  38. +
  39. Be a stranger to the world's ways.
  40. +
  41. Prefer nothing more than the love of Christ.
  42. +
  43. Do not give way to anger.
  44. +
  45. Do not nurse a grudge.
  46. +
  47. Do not entertain deceit in your heart.
  48. +
  49. Do not give a false peace.
  50. +
  51. Do not forsake charity.
  52. +
  53. Do not swear, for fear of perjuring yourself.
  54. +
  55. Utter only truth from heart and mouth.
  56. +
  57. Do not return evil for evil.
  58. +
  59. Do no wrong to anyone, and bear patiently wrongs done to yourself.
  60. +
  61. Love your enemies.
  62. +
  63. Do not curse those who curse you, but rather bless them.
  64. +
  65. Bear persecution for justice's sake.
  66. +
  67. Be not proud.
  68. +
  69. Be not addicted to wine.
  70. +
  71. Be not a great eater.
  72. +
  73. Be not drowsy.
  74. +
  75. Be not lazy.
  76. +
  77. Be not a grumbler.
  78. +
  79. Be not a detractor.
  80. +
  81. Put your hope in God.
  82. +
  83. Attribute to God, and not to self, whatever good you see in yourself.
  84. +
  85. Recognize always that evil is your own doing, and to impute it to yourself.
  86. +
  87. Fear the Day of Judgment.
  88. +
  89. Be in dread of hell.
  90. +
  91. Desire eternal life with all the passion of the spirit.
  92. +
  93. Keep death daily before your eyes.
  94. +
  95. Keep constant guard over the actions of your life.
  96. +
  97. Know for certain that God sees you everywhere.
  98. +
  99. When wrongful thoughts come into your heart, dash them against Christ immediately.
  100. +
  101. Disclose wrongful thoughts to your spiritual mentor.
  102. +
  103. Guard your tongue against evil and depraved speech.
  104. +
  105. Do not love much talking.
  106. +
  107. Speak no useless words or words that move to laughter.
  108. +
  109. Do not love much or boisterous laughter.
  110. +
  111. Listen willingly to holy reading.
  112. +
  113. Devote yourself frequently to prayer.
  114. +
  115. Daily in your prayers, with tears and sighs, confess your past sins to God, and amend them for the future.
  116. +
  117. Fulfill not the desires of the flesh; hate your own will.
  118. +
  119. + Obey in all things the commands of those whom God has placed in authority over you even though they (which God forbid) should act otherwise, mindful of the Lord's precept, "Do what they say, but not what they do." +
  120. +
  121. Do not wish to be called holy before one is holy; but first to be holy, that you may be truly so called.
  122. +
  123. Fulfill God's commandments daily in your deeds.
  124. +
  125. Love chastity.
  126. +
  127. Hate no one.
  128. +
  129. Be not jealous, nor harbor envy.
  130. +
  131. Do not love quarreling.
  132. +
  133. Shun arrogance.
  134. +
  135. Respect your seniors.
  136. +
  137. Love your juniors.
  138. +
  139. Pray for your enemies in the love of Christ.
  140. +
  141. Make peace with your adversary before the sun sets.
  142. +
  143. Never despair of God's mercy.
  144. + +{% endblock %} diff --git a/web/views.py b/web/views.py index 10e124b..0a1e163 100644 --- a/web/views.py +++ b/web/views.py @@ -1,11 +1,11 @@ import base64 -import json from io import BytesIO from PIL import Image from django.contrib.auth import login, logout from django.contrib.auth.decorators import login_required, user_passes_test from django.contrib import messages +from django.core.mail import send_mail from django.http import JsonResponse from django.shortcuts import render, redirect, get_object_or_404 from django.urls import reverse @@ -16,11 +16,25 @@ from web.models.forum_subcategory import ForumSubcategory from web.models.forum_post import ForumPost from web.models.custom_user import CustomUser +def test_email(request): + send_mail( + subject='test email', + message='test email', + from_email='noreply@christian-webring.org', + recipient_list=['me@domdit.com'], + fail_silently=False, + ) + return redirect('index') -# def send_email(subject, body, recipients=None): -# if not recipients: -# recipients = [x[0] for x in CustomUser.objects.filter(is_superuser=True).all().values_list('email') if x[0] != ''] -# send_mail(subject, body, 'domdit@gmail.com', recipients, fail_silently=False) + +def send_email(subject, message, recipients=None): + send_mail( + subject=subject, + message=message, + from_email='noreply@christian-webring.org', + recipient_list=recipients or ['domdit@gmail.com', 'me@domdit.com'], + fail_silently=False, + ) def is_member(user): @@ -29,11 +43,6 @@ def is_member(user): return False -# def test_endpoint(request): -# send_email('this is a subject', 'this is a body') -# return render(request, 'index.html') - - # ACCOUNT MANAGEMENT ###################################### def signup(request): if request.method == 'POST': @@ -43,6 +52,17 @@ def signup(request): login(request, user) messages.success(request, "You have successfully applied for membership, we will review your submission and send you an email once we have added you as a member! In the meantime, please start setting up the webring widget on your website!") + send_email( + subject='New User Sign Up Alert', + message=f'A new user has signed up for the webring, please review the user in the admin portal! \n\n ID: {user.id}, EMAIL: {user.email}, USERNAME: {user.username}' + ) + + send_email( + subject='Christian Web Ring - Thanks for Joining', + message=f'Hello {user.username}! \n Thank you for signing up for the Christian Web Ring. We will reach out to you soon once we have approved your account. In the meantime, please add the widget to your page. Instructions can be found here: https://christian-webring.nekoweb.org/widget.html \n Remember, we cannot add you to the webring until you have completed this step! \n\n Thanks, \n Christian Webring Admins', + recipients=[user.email] + ) + return redirect(reverse('login')) else: form = SignupForm() @@ -104,6 +124,10 @@ def user_profile(request, user_id): return render(request, 'user.html', context) +def code_of_ethics(request): + return render(request, 'code_of_ethics.html') + + # FORUM ################################################### @login_required @user_passes_test(is_member, login_url='/accounts/denied/')