emails and COE
This commit is contained in:
parent
6b77037e81
commit
f52a3801b2
7 changed files with 133 additions and 16 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -214,3 +214,4 @@ __marimo__/
|
||||||
|
|
||||||
# Streamlit
|
# Streamlit
|
||||||
.streamlit/secrets.toml
|
.streamlit/secrets.toml
|
||||||
|
config*
|
||||||
|
|
|
||||||
8
TODO.txt
8
TODO.txt
|
|
@ -13,10 +13,10 @@ DOMINIC ---
|
||||||
[x] list user api endpoint
|
[x] list user api endpoint
|
||||||
[x] CSS
|
[x] CSS
|
||||||
[x] Assets
|
[x] Assets
|
||||||
[ ] Pick better anonymous avatar
|
[x] Pick better anonymous avatar
|
||||||
[ ] figure out backing up DB
|
[x] figure out backing up DB
|
||||||
[ ] soft-release
|
[x] soft-release
|
||||||
[ ] Domain
|
[x] GET Domain
|
||||||
[ ] email notifications when user signs up: disroot email
|
[ ] email notifications when user signs up: disroot email
|
||||||
[ ] maybe start sending emails to users automatically too
|
[ ] maybe start sending emails to users automatically too
|
||||||
[ ] full-release
|
[ ] full-release
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from config import ADMIN_EMAIL_PASSWORD
|
||||||
|
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
|
|
||||||
|
|
@ -121,3 +123,9 @@ LOGOUT_REDIRECT_URL = "login"
|
||||||
|
|
||||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
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
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path, include
|
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 = [
|
urlpatterns = [
|
||||||
path('markdownx/', include('markdownx.urls')),
|
path('markdownx/', include('markdownx.urls')),
|
||||||
|
|
@ -12,9 +12,10 @@ urlpatterns = [
|
||||||
path("accounts/profile/", profile, name="profile"),
|
path("accounts/profile/", profile, name="profile"),
|
||||||
path("accounts/user/<user_id>", user_profile, name="user"),
|
path("accounts/user/<user_id>", user_profile, name="user"),
|
||||||
path("accounts/denied/", denied, name="denied"),
|
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('logout/', custom_logout, name='custom_logout'),
|
||||||
path("", forum_threads, name='index'),
|
path("", forum_threads, name='index'),
|
||||||
path("forum/threads/", forum_threads, name='forum_threads'),
|
path("forum/threads/", forum_threads, name='forum_threads'),
|
||||||
path("forum/thread/<thread_id>", thread, name='thread'),
|
path("forum/thread/<thread_id>", thread, name='thread'),
|
||||||
# path("test/", test_endpoint, name='test'),
|
path("test/", test_email, name='test'),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -191,6 +191,7 @@
|
||||||
<center>
|
<center>
|
||||||
<a href="{% url 'forum_threads' %}">Forum</a>
|
<a href="{% url 'forum_threads' %}">Forum</a>
|
||||||
<a href="{% url 'profile' %}">Profile</a>
|
<a href="{% url 'profile' %}">Profile</a>
|
||||||
|
<a href="{% url 'code_of_ethics' %}">Code of Ethics</a>
|
||||||
<a href="{% url 'custom_logout' %}">Logout</a>
|
<a href="{% url 'custom_logout' %}">Logout</a>
|
||||||
</center>
|
</center>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
82
web/templates/code_of_ethics.html
Normal file
82
web/templates/code_of_ethics.html
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
{% extends "base.html" %}
|
||||||
|
{% block content %}
|
||||||
|
<h2>Code Of Ethics</h2>
|
||||||
|
<p>Code of Ethics has been borrowed from <a href="https://sqlite.org/codeofethics.html">SQLite's Code of Ethics</a></p>
|
||||||
|
<ol>
|
||||||
|
<li>First of all, love the Lord God with your whole heart, your whole soul, and your whole strength.</li>
|
||||||
|
<li>Then, love your neighbor as yourself.</li>
|
||||||
|
<li>Do not murder.</li>
|
||||||
|
<li>Do not commit adultery.</li>
|
||||||
|
<li>Do not steal.</li>
|
||||||
|
<li>Do not covet.</li>
|
||||||
|
<li>Do not bear false witness.</li>
|
||||||
|
<li>Honor all people.</li>
|
||||||
|
<li>Do not do to another what you would not have done to yourself.</li>
|
||||||
|
<li>Deny oneself in order to follow Christ.</li>
|
||||||
|
<li>Chastise the body.</li>
|
||||||
|
<li>Do not become attached to pleasures.</li>
|
||||||
|
<li>Love fasting.</li>
|
||||||
|
<li>Relieve the poor.</li>
|
||||||
|
<li>Clothe the naked.</li>
|
||||||
|
<li>Visit the sick.</li>
|
||||||
|
<li>Bury the dead.</li>
|
||||||
|
<li>Be a help in times of trouble.</li>
|
||||||
|
<li>Console the sorrowing.</li>
|
||||||
|
<li>Be a stranger to the world's ways.</li>
|
||||||
|
<li>Prefer nothing more than the love of Christ.</li>
|
||||||
|
<li>Do not give way to anger.</li>
|
||||||
|
<li>Do not nurse a grudge.</li>
|
||||||
|
<li>Do not entertain deceit in your heart.</li>
|
||||||
|
<li>Do not give a false peace.</li>
|
||||||
|
<li>Do not forsake charity.</li>
|
||||||
|
<li>Do not swear, for fear of perjuring yourself.</li>
|
||||||
|
<li>Utter only truth from heart and mouth.</li>
|
||||||
|
<li>Do not return evil for evil.</li>
|
||||||
|
<li>Do no wrong to anyone, and bear patiently wrongs done to yourself.</li>
|
||||||
|
<li>Love your enemies.</li>
|
||||||
|
<li>Do not curse those who curse you, but rather bless them.</li>
|
||||||
|
<li>Bear persecution for justice's sake.</li>
|
||||||
|
<li>Be not proud.</li>
|
||||||
|
<li>Be not addicted to wine.</li>
|
||||||
|
<li>Be not a great eater.</li>
|
||||||
|
<li>Be not drowsy.</li>
|
||||||
|
<li>Be not lazy.</li>
|
||||||
|
<li>Be not a grumbler.</li>
|
||||||
|
<li>Be not a detractor.</li>
|
||||||
|
<li>Put your hope in God.</li>
|
||||||
|
<li>Attribute to God, and not to self, whatever good you see in yourself.</li>
|
||||||
|
<li>Recognize always that evil is your own doing, and to impute it to yourself.</li>
|
||||||
|
<li>Fear the Day of Judgment.</li>
|
||||||
|
<li>Be in dread of hell.</li>
|
||||||
|
<li>Desire eternal life with all the passion of the spirit.</li>
|
||||||
|
<li>Keep death daily before your eyes.</li>
|
||||||
|
<li>Keep constant guard over the actions of your life.</li>
|
||||||
|
<li>Know for certain that God sees you everywhere.</li>
|
||||||
|
<li>When wrongful thoughts come into your heart, dash them against Christ immediately.</li>
|
||||||
|
<li>Disclose wrongful thoughts to your spiritual mentor.</li>
|
||||||
|
<li>Guard your tongue against evil and depraved speech.</li>
|
||||||
|
<li>Do not love much talking.</li>
|
||||||
|
<li>Speak no useless words or words that move to laughter.</li>
|
||||||
|
<li>Do not love much or boisterous laughter.</li>
|
||||||
|
<li>Listen willingly to holy reading.</li>
|
||||||
|
<li>Devote yourself frequently to prayer.</li>
|
||||||
|
<li>Daily in your prayers, with tears and sighs, confess your past sins to God, and amend them for the future.</li>
|
||||||
|
<li>Fulfill not the desires of the flesh; hate your own will.</li>
|
||||||
|
<li>
|
||||||
|
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."
|
||||||
|
</li>
|
||||||
|
<li>Do not wish to be called holy before one is holy; but first to be holy, that you may be truly so called.</li>
|
||||||
|
<li>Fulfill God's commandments daily in your deeds.</li>
|
||||||
|
<li>Love chastity.</li>
|
||||||
|
<li>Hate no one.</li>
|
||||||
|
<li>Be not jealous, nor harbor envy.</li>
|
||||||
|
<li>Do not love quarreling.</li>
|
||||||
|
<li>Shun arrogance.</li>
|
||||||
|
<li>Respect your seniors.</li>
|
||||||
|
<li>Love your juniors.</li>
|
||||||
|
<li>Pray for your enemies in the love of Christ.</li>
|
||||||
|
<li>Make peace with your adversary before the sun sets.</li>
|
||||||
|
<li>Never despair of God's mercy.</li>
|
||||||
|
</ul>
|
||||||
|
{% endblock %}
|
||||||
44
web/views.py
44
web/views.py
|
|
@ -1,11 +1,11 @@
|
||||||
import base64
|
import base64
|
||||||
import json
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
from django.contrib.auth import login, logout
|
from django.contrib.auth import login, logout
|
||||||
from django.contrib.auth.decorators import login_required, user_passes_test
|
from django.contrib.auth.decorators import login_required, user_passes_test
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
|
from django.core.mail import send_mail
|
||||||
from django.http import JsonResponse
|
from django.http import JsonResponse
|
||||||
from django.shortcuts import render, redirect, get_object_or_404
|
from django.shortcuts import render, redirect, get_object_or_404
|
||||||
from django.urls import reverse
|
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.forum_post import ForumPost
|
||||||
from web.models.custom_user import CustomUser
|
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:
|
def send_email(subject, message, recipients=None):
|
||||||
# recipients = [x[0] for x in CustomUser.objects.filter(is_superuser=True).all().values_list('email') if x[0] != '']
|
send_mail(
|
||||||
# send_mail(subject, body, 'domdit@gmail.com', recipients, fail_silently=False)
|
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):
|
def is_member(user):
|
||||||
|
|
@ -29,11 +43,6 @@ def is_member(user):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
# def test_endpoint(request):
|
|
||||||
# send_email('this is a subject', 'this is a body')
|
|
||||||
# return render(request, 'index.html')
|
|
||||||
|
|
||||||
|
|
||||||
# ACCOUNT MANAGEMENT ######################################
|
# ACCOUNT MANAGEMENT ######################################
|
||||||
def signup(request):
|
def signup(request):
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
|
|
@ -43,6 +52,17 @@ def signup(request):
|
||||||
login(request, user)
|
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!")
|
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'))
|
return redirect(reverse('login'))
|
||||||
else:
|
else:
|
||||||
form = SignupForm()
|
form = SignupForm()
|
||||||
|
|
@ -104,6 +124,10 @@ def user_profile(request, user_id):
|
||||||
return render(request, 'user.html', context)
|
return render(request, 'user.html', context)
|
||||||
|
|
||||||
|
|
||||||
|
def code_of_ethics(request):
|
||||||
|
return render(request, 'code_of_ethics.html')
|
||||||
|
|
||||||
|
|
||||||
# FORUM ###################################################
|
# FORUM ###################################################
|
||||||
@login_required
|
@login_required
|
||||||
@user_passes_test(is_member, login_url='/accounts/denied/')
|
@user_passes_test(is_member, login_url='/accounts/denied/')
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue