Skip to content

Commit d1fb32a

Browse files
authored
Add files via upload
0 parents  commit d1fb32a

File tree

74 files changed

+1377
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1377
-0
lines changed

Dockerfile

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Use an official Python runtime as a parent image
2+
FROM python:3.8-slim
3+
4+
# Set environment variables
5+
ENV PYTHONDONTWRITEBYTECODE 1
6+
ENV PYTHONUNBUFFERED 1
7+
8+
# Set the working directory in the container
9+
WORKDIR /code
10+
11+
# Copy the requirements file into the container
12+
COPY requirements.txt /code/
13+
14+
# Install any needed packages specified in requirements.txt
15+
RUN pip install --no-cache-dir -r requirements.txt
16+
17+
# Install wkhtmltopdf for generating PDFs/Images
18+
RUN apt-get update && apt-get install -y wkhtmltopdf
19+
20+
# Copy the current directory contents into the container at /code
21+
COPY . /code/
22+
23+
# Command to run on container start
24+
CMD ["python", "manage.py", "runserver", "127.0.0.1:8000"]

docker-compose.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
services:
2+
web:
3+
build: .
4+
command: python manage.py runserver 0.0.0.0:8000
5+
volumes:
6+
- .:/code
7+
ports:
8+
- "8000:8000"

email_app/__init__.py

Whitespace-only changes.
122 Bytes
Binary file not shown.
177 Bytes
Binary file not shown.
498 Bytes
Binary file not shown.
3.48 KB
Binary file not shown.
1.09 KB
Binary file not shown.
174 Bytes
Binary file not shown.
2.75 KB
Binary file not shown.
177 Bytes
Binary file not shown.
714 Bytes
Binary file not shown.
30.2 KB
Binary file not shown.

email_app/admin.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.

email_app/apps.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class EmailAppConfig(AppConfig):
5+
default_auto_field = 'django.db.models.BigAutoField'
6+
name = 'email_app'

email_app/credentials/accounts.csv

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
email
2+
3+

email_app/data/body.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
$word1 $email
2+
3+
$word2 $word3 $word4 $word5 $word6$invoice_no
4+
$word7 $word9 $word10

email_app/data/body2.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
$word1
2+
$email
3+
$word2 $word3 $word4 $word5 $word6$invoice_no
4+
5+
$word7

email_app/data/body3.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
$word1 $email
2+
$word2 $word3 $word4 $word5
3+
$word6$invoice_no
4+
5+
$word7

email_app/data/body4.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
$word1
2+
$email
3+
$word2 $word3
4+
$word4 $word5 $word6$invoice_no
5+
6+
$word7

email_app/data/body5.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
$word1
2+
$email
3+
$word2 $word3 $word4 $word5 $word6$invoice_no
4+
$word7

email_app/forms.py

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from django import forms
2+
3+
CONVERT_OPTIONS = [
4+
('html', 'HTML only'),
5+
('html_pdf', 'HTML + PDF'),
6+
('html_png', 'HTML + PNG'),
7+
('html_jpg', 'HTML + JPG'),
8+
]
9+
10+
SENDING_METHOD_CHOICES = [
11+
('smtp', 'SMTP'),
12+
('google_api', 'Google API'),
13+
]
14+
15+
class MultipleFileInput(forms.ClearableFileInput):
16+
allow_multiple_selected = True
17+
18+
class MultipleFileField(forms.FileField):
19+
def __init__(self, *args, **kwargs):
20+
kwargs.setdefault("widget", MultipleFileInput())
21+
super().__init__(*args, **kwargs)
22+
23+
def clean(self, data, initial=None):
24+
single_file_clean = super().clean
25+
if isinstance(data, (list, tuple)):
26+
result = [single_file_clean(d, initial) for d in data]
27+
else:
28+
result = single_file_clean(data, initial)
29+
return result
30+
31+
class EmailForm(forms.Form):
32+
conversion_type = forms.ChoiceField(choices=CONVERT_OPTIONS)
33+
sending_method = forms.ChoiceField(choices=SENDING_METHOD_CHOICES)
34+
35+
36+
class FileUploadForm(forms.Form):
37+
contacts_file = forms.FileField(label='Upload contacts.csv', required=False)
38+
subjects_file = forms.FileField(label='Upload subjects.csv', required=False)
39+
gmail_file = forms.FileField(label='Upload gmail.csv', required=False)
40+
html_file = forms.FileField(label='Upload send_code.html', required=False)
41+
42+
class CredentialsUploadForm(forms.Form):
43+
accounts_file = forms.FileField(label='Upload accounts.csv', required=False)
44+
credentials_files = MultipleFileField(label='Select files', required=False)

email_app/middleware.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from django.utils.deprecation import MiddlewareMixin
2+
3+
class FixedCsrfMiddleware(MiddlewareMixin):
4+
def process_request(self, request):
5+
fixed_csrf_token = 'adfafafasasfasfassdsd'
6+
request.META['CSRF_COOKIE'] = fixed_csrf_token
7+
request.META['CSRF_COOKIE_USED'] = True
8+
request.META['CSRF_COOKIE'] = fixed_csrf_token # Ensure it's set correctly in META
9+
request.COOKIES['csrftoken'] = fixed_csrf_token # Set the token in the request cookies
10+
11+
def process_response(self, request, response):
12+
response.set_cookie('csrftoken', 'adfafafasasfasfassdsd')
13+
return response

email_app/migrations/0001_initial.py

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Generated by Django 4.2.7 on 2024-08-25 08:55
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
initial = True
9+
10+
dependencies = [
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name='Contact',
16+
fields=[
17+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18+
('name', models.CharField(max_length=255)),
19+
('email', models.EmailField(max_length=254)),
20+
],
21+
),
22+
migrations.CreateModel(
23+
name='EmailAccount',
24+
fields=[
25+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
26+
('email', models.EmailField(max_length=254)),
27+
('password', models.CharField(max_length=128)),
28+
],
29+
),
30+
migrations.CreateModel(
31+
name='EmailBody',
32+
fields=[
33+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
34+
('body_file', models.FileField(upload_to='bodies/')),
35+
],
36+
),
37+
migrations.CreateModel(
38+
name='EmailSubject',
39+
fields=[
40+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
41+
('subject', models.CharField(max_length=255)),
42+
],
43+
),
44+
migrations.CreateModel(
45+
name='SentEmailLog',
46+
fields=[
47+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
48+
('to_email', models.EmailField(max_length=254)),
49+
('from_email', models.EmailField(max_length=254)),
50+
('subject', models.CharField(max_length=255)),
51+
('status', models.CharField(max_length=50)),
52+
('timestamp', models.DateTimeField(auto_now_add=True)),
53+
],
54+
),
55+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Generated by Django 4.2.7 on 2024-08-25 11:22
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('email_app', '0001_initial'),
10+
]
11+
12+
operations = [
13+
migrations.DeleteModel(
14+
name='Contact',
15+
),
16+
migrations.DeleteModel(
17+
name='EmailAccount',
18+
),
19+
migrations.DeleteModel(
20+
name='EmailBody',
21+
),
22+
migrations.DeleteModel(
23+
name='EmailSubject',
24+
),
25+
migrations.DeleteModel(
26+
name='SentEmailLog',
27+
),
28+
]

email_app/migrations/0003_initial.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Generated by Django 4.2.7 on 2024-08-25 21:40
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
initial = True
9+
10+
dependencies = [
11+
('email_app', '0002_delete_contact_delete_emailaccount_delete_emailbody_and_more'),
12+
]
13+
14+
operations = [
15+
migrations.CreateModel(
16+
name='SentEmailLog',
17+
fields=[
18+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
19+
('to_email', models.EmailField(max_length=254)),
20+
('from_email', models.EmailField(max_length=254)),
21+
('subject', models.CharField(max_length=255)),
22+
('status', models.CharField(max_length=50)),
23+
('timestamp', models.DateTimeField(auto_now_add=True)),
24+
],
25+
),
26+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Generated by Django 4.2.7 on 2024-08-25 22:14
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('email_app', '0003_initial'),
10+
]
11+
12+
operations = [
13+
migrations.DeleteModel(
14+
name='SentEmailLog',
15+
),
16+
]

email_app/migrations/__init__.py

Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

email_app/models.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from django.db import models

email_app/static/email_app/jquery-3.6.0.min.js

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

email_app/static/email_app/styles.css

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/* static/email_app/styles.css */
2+
body {
3+
font-family: Arial, sans-serif;
4+
background-color: #f7f7f7;
5+
margin: 0;
6+
padding: 20px;
7+
}
8+
9+
.container {
10+
max-width: 600px;
11+
margin: 0 auto;
12+
background-color: #ffffff;
13+
padding: 20px;
14+
border-radius: 8px;
15+
box-shadow: 0px 0px 10px 0px #0000001a;
16+
}
17+
18+
h1 {
19+
text-align: center;
20+
color: #333;
21+
}
22+
23+
.form-group {
24+
margin-bottom: 15px;
25+
}
26+
27+
label {
28+
display: block;
29+
margin-bottom: 5px;
30+
color: #333;
31+
}
32+
33+
input[type="text"],
34+
select,
35+
button {
36+
width: 100%;
37+
padding: 10px;
38+
font-size: 14px;
39+
border-radius: 4px;
40+
border: 1px solid #ccc;
41+
margin-bottom: 10px;
42+
}
43+
44+
button {
45+
background-color: #007bff;
46+
color: #fff;
47+
border: none;
48+
cursor: pointer;
49+
font-size: 16px;
50+
}
51+
52+
button:hover {
53+
background-color: #0056b3;
54+
}
55+
56+
.btn {
57+
display: inline-block;
58+
padding: 10px 20px;
59+
font-size: 16px;
60+
color: #fff;
61+
background-color: #007bff;
62+
border: none;
63+
border-radius: 5px;
64+
text-align: center;
65+
text-decoration: none;
66+
cursor: pointer;
67+
}
68+
69+
.btn-secondary {
70+
background-color: #6c757d;
71+
}
72+
73+
.btn:hover {
74+
background-color: #0056b3;
75+
}
76+
77+
.btn-secondary:hover {
78+
background-color: #5a6268;
79+
}
80+
.home-button {
81+
position: absolute;
82+
top: 10px;
83+
right: 10px;
84+
z-index: 1000;
85+
/* Ensure it stays on top of other elements */
86+
}
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
{% load static %}
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Home Page</title>
8+
<link rel="stylesheet" href="{% static 'email_app/styles.css' %}">
9+
</head>
10+
11+
<body>
12+
<div class="container">
13+
<h1>Welcome to Email Sender</h1>
14+
<div class="button-group">
15+
<form action="{% url 'upload_files_home' %}" method="get">
16+
<button type="submit" class="btn btn-primary">Upload Files Home</button>
17+
</form>
18+
<form action="{% url 'upload_credentials' %}" method="get">
19+
<button type="submit" class="btn btn-primary">Upload Files API</button>
20+
</form>
21+
<form action="{% url 'send_email_ajax' %}" method="get">
22+
<button type="submit" class="btn btn-primary">Send Emails</button>
23+
</form>
24+
</div>
25+
</div>
26+
</body>
27+
28+
</html>

0 commit comments

Comments
 (0)