Ver Fonte

Synchronizing repositories

TonyKurts há 1 semana atrás
pai
commit
82d10bf3d0

+ 14 - 1
core/_settings_vars.py

@@ -24,6 +24,19 @@ DB_PASSWORD = None
 DB_HOST = None
 DB_PORT = 5432
 
+########
+#
+# Email
+#
+########
+
+EMAIL_HOST = None
+EMAIL_PORT = 587
+EMAIL_USE_TLS = True
+EMAIL_HOST_USER = None
+EMAIL_HOST_PASSWORD = None
+DEFAULT_FROM_EMAIL = None
+
 ########
 #
 # Gunicorn
@@ -46,4 +59,4 @@ EJ_SERVICE = "chat.ej.sharix-app.org"
 EJ_HOST = "ej.sharix-app.org"
 
 # Service name that is used in generating ejabber rooms
-WEBSERVICE_NAME = "open" 
+WEBSERVICE_NAME = "open" 

+ 9 - 0
core/settings.py

@@ -402,3 +402,12 @@ GRAPH_MODELS = {
     'all_applications': True,
     'group_models': True,
 }
+
+# Email
+EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
+EMAIL_HOST = sv.EMAIL_HOST
+EMAIL_PORT = sv.EMAIL_PORT
+EMAIL_USE_TLS = sv.EMAIL_USE_TLS
+EMAIL_HOST_USER = sv.EMAIL_HOST_USER 
+EMAIL_HOST_PASSWORD = sv.EMAIL_HOST_PASSWORD
+DEFAULT_FROM_EMAIL = sv.DEFAULT_FROM_EMAIL

+ 5 - 1
sharix_admin/static/sharix_admin/css/base.css

@@ -28,6 +28,10 @@ p {
     color: var(--bs-secondary-color);
 }
 
+ul {
+    color: var(--bs-secondary-color);
+}
+
 .text-primary {
     color: var(--primary) !important;
 }
@@ -266,4 +270,4 @@ a:hover {
   
 .drop-container  input[type=file]::file-selector-button:hover {
     background: var(--btn-hover-color);
-}
+}

+ 9 - 0
sharix_admin/static/sharix_admin/js/base.js

@@ -0,0 +1,9 @@
+// Функция, запрещающая нажатие кнопки отправки формы", пока пользователь поставит галочки в указанные чекбоксы
+function makeCheckboxesMandatory(submitBtnEl, ...checkboxEls) {
+    checkboxEls.forEach(checkboxEl => {
+        checkboxEl.addEventListener('change', function() {
+            if (checkboxEls.every(el => el.checked)) submitBtnEl.removeAttribute('disabled');
+            else submitBtnEl.setAttribute('disabled', 'disabled');
+        });
+    });
+}

+ 8 - 16
sharix_admin/templates/sharix_admin/auth/signup.html

@@ -37,22 +37,14 @@
         <small class="text-muted">&#169; ShariX Open {% now "Y" %}</small>
     </div>
 </div>
+{% endblock %}
 
+{% block extra_js %}
 <script>
-    // Логика, запрещающая нажатие на кнопку "Зарегистрироваться", пока пользователь не согласится с "Пользовательским соглашением"
-    document.addEventListener('DOMContentLoaded', function() {
-        const checkboxEls = [
-            document.getElementById('checkbox-fourteen-years'),
-            document.getElementById('checkbox-user-agreement')
-        ];
-        const submitBtnEl = document.getElementById('btn-submit-signup');
-
-        checkboxEls.forEach(checkboxEl => {
-            checkboxEl.addEventListener('change', function() {
-                if (checkboxEls.every(el => el.checked)) submitBtnEl.removeAttribute('disabled');
-                else submitBtnEl.setAttribute('disabled', 'disabled');
-            });
-        });
-    });
+    makeCheckboxesMandatory(
+        document.getElementById('btn-submit-signup'),
+        document.getElementById('checkbox-fourteen-years'),
+        document.getElementById('checkbox-user-agreement')
+    );
 </script>
-{% endblock %}
+{% endblock %}

+ 4 - 1
sharix_admin/templates/sharix_admin/base.html

@@ -26,5 +26,8 @@
     {% block content %}{% endblock %}
     
     <script src="{% static 'sharix_admin/js/bootstrap.bundle.min.js' %}"></script>
+    <script src="{% static 'sharix_admin/js/base.js' %}"></script>
+
+    {% block extra_js %}{% endblock %}
 </body>
-</html>
+</html>

+ 20 - 0
sharix_admin/utils/other.py

@@ -0,0 +1,20 @@
+from django.conf import settings
+from django.template.loader import render_to_string
+from django.utils.html import strip_tags
+from django.core.mail import send_mail
+
+
+def send_notify_mail(subject: str, message_template: str, recipient_list: list, context: dict):
+    try:
+        html_message = render_to_string(message_template, context)
+        plain_message = strip_tags(html_message)
+
+        send_mail(
+            subject,
+            plain_message,
+            settings.DEFAULT_FROM_EMAIL,
+            recipient_list,
+            html_message=html_message
+        )
+    except Exception as e:
+        print(f"Error when sending an e-mail: {e}")