From 010e1716497a406ae74395f1a0de2d2ed6cb3f24 Mon Sep 17 00:00:00 2001
From: Ayanwola Ayomide <77179231+devvspaces@users.noreply.github.com>
Date: Wed, 21 Aug 2024 04:50:51 +0100
Subject: [PATCH 01/10] Completed
---
.gitignore | 1 +
src/assets/css/main.css | 15 +-
src/assets/js/main.js | 46 ++++
src/config/settings/base.py | 27 +-
src/mailer/forms.py | 4 +-
src/mailer/templates/mailer/base.html | 8 +-
src/mailer/templates/mailer/index.html | 147 ++++++-----
src/mailer/views.py | 17 +-
src/media/x.csv | 344 -------------------------
src/messenger/messager.py | 12 +-
test.html | 109 ++++++++
11 files changed, 294 insertions(+), 436 deletions(-)
create mode 100644 src/assets/js/main.js
delete mode 100644 src/media/x.csv
create mode 100644 test.html
diff --git a/.gitignore b/.gitignore
index b6e4761..8defd49 100644
--- a/.gitignore
+++ b/.gitignore
@@ -60,6 +60,7 @@ coverage.xml
local_settings.py
db.sqlite3
db.sqlite3-journal
+media/
# Flask stuff:
instance/
diff --git a/src/assets/css/main.css b/src/assets/css/main.css
index 41e45a0..70a87dd 100644
--- a/src/assets/css/main.css
+++ b/src/assets/css/main.css
@@ -2,7 +2,7 @@ body {
background-color: var(--bs-dark);
}
-.navbar{
+.navbar {
padding-top: 1.5rem;
padding-bottom: 1.5rem;
background-color: #131518 !important;
@@ -13,25 +13,25 @@ body {
gap: 1rem;
}
-.container-fluid{
+.container-fluid {
max-width: 900px;
margin: 0 auto;
}
-label{
+label {
margin-bottom: 6px;
font-weight: 500;
}
-form{
- max-width: 500px;
+form {
+ max-width: 900px;
margin: auto;
background: white;
padding: 2rem;
border-radius: 10px;
}
-legend{
+legend {
margin: 1rem 0 2rem 0;
font-weight: bold;
}
@@ -43,5 +43,4 @@ form button.btn {
width: 100%;
font-weight: 500;
font-size: 1.1rem;
-}
-
+}
\ No newline at end of file
diff --git a/src/assets/js/main.js b/src/assets/js/main.js
new file mode 100644
index 0000000..bff8a97
--- /dev/null
+++ b/src/assets/js/main.js
@@ -0,0 +1,46 @@
+const fileInput = document.getElementById("csv");
+
+const previewCSVData = async (dataurl) => {
+ const d = await d3.csv(dataurl);
+ console.log({
+ d,
+ });
+ console.log(d.columns);
+
+ const email_key = document.getElementById("email_key");
+ d.columns.map((col) => {
+ email_key.options[email_key.options.length] = new Option(col, col);
+ });
+
+ $(function () {
+ $("#slider-range").slider({
+ range: true,
+ min: 0,
+ max: d.length,
+ values: [0, d.length],
+ slide: function (event, ui) {
+ $("#start").val(ui.values[0]);
+ $("#stop").val(ui.values[1]);
+ },
+ });
+ $("#start").val($("#slider-range").slider("values", 0));
+ $("#stop").val($("#slider-range").slider("values", 1));
+ });
+};
+
+const readFile = (e) => {
+ const file = fileInput.files[0];
+ if (!file) {
+ return;
+ }
+ const reader = new FileReader();
+ reader.onload = () => {
+ const dataUrl = reader.result;
+ previewCSVData(dataUrl);
+ };
+ reader.readAsDataURL(file);
+};
+
+if (fileInput) {
+ fileInput.onchange = readFile;
+}
diff --git a/src/config/settings/base.py b/src/config/settings/base.py
index 2b6fd1d..ddfad26 100644
--- a/src/config/settings/base.py
+++ b/src/config/settings/base.py
@@ -19,7 +19,8 @@
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
- 'mailer'
+ 'mailer',
+ 'django_quill',
]
MIDDLEWARE = [
@@ -149,3 +150,27 @@
TWILIO_SID = config('TWILIO_SID', default='test')
TWILIO_TOKEN = config('TWILIO_TOKEN', default='test')
+
+
+QUILL_CONFIGS = {
+ 'default':{
+ 'theme': 'snow',
+ 'modules': {
+ 'syntax': True,
+ 'toolbar': [
+ [
+ {'font': []},
+ {'header': [1, 2, 3, 4, 5, 6, False]},
+ {'align': []},
+ 'bold', 'italic', 'underline', 'strike', 'blockquote',
+ {'color': []},
+ {'background': []},
+ ],
+ [{ 'list': 'ordered'}, { 'list': 'bullet' }, { 'list': 'check' }],
+ ['code-block', 'link'],
+ ['clean'],
+ ]
+ }
+ }
+}
+
diff --git a/src/mailer/forms.py b/src/mailer/forms.py
index 2ca780f..0f18ea9 100644
--- a/src/mailer/forms.py
+++ b/src/mailer/forms.py
@@ -1,6 +1,7 @@
from django import forms
from django.forms import ValidationError
from django.core.validators import FileExtensionValidator, MinValueValidator
+from django_quill.forms import QuillFormField
from .models import Uploads
@@ -17,7 +18,8 @@ class MailForm(forms.Form):
sender = forms.CharField()
reply_to = forms.EmailField(required=False)
subject = forms.CharField()
- message = forms.CharField(widget=forms.Textarea)
+ content = QuillFormField()
+ email_key = forms.CharField()
start = forms.IntegerField(validators=[validator_start_min])
stop = forms.IntegerField(validators=[validator_stop_min])
diff --git a/src/mailer/templates/mailer/base.html b/src/mailer/templates/mailer/base.html
index f562fe8..e87b04d 100644
--- a/src/mailer/templates/mailer/base.html
+++ b/src/mailer/templates/mailer/base.html
@@ -16,7 +16,7 @@
{% endif %}
-
+
@@ -65,18 +65,18 @@
{% block content %}
-
{% endblock content %}
-
+
+
+
{% block extra_js %}
-
{% endblock extra_js %}