Compare commits

..

2 Commits

Author SHA1 Message Date
0d9f5264d4 Merge remote-tracking branch 'origin/main' 2024-10-20 19:16:59 +02:00
1d376d6b56 Change in files organization
Readme updates
fix bu in env.py
2024-10-20 19:14:36 +02:00
4 changed files with 19 additions and 17 deletions

View File

@ -17,20 +17,18 @@ This Python project automates the process of organizing a Secret Santa event. It
```bash
secret-santa/
├── config/
│ └── env.py # Configuration settings (SMTP, file paths, etc.)
├── src/
│ ├── draw.py # Logic for drawing names
│ ├── emailer.py # Email sending functionality
│ ├── file_io.py # File handling (CSV reading/writing)
│ ├── main.py # Main program logic
│ └── utils.py # Utility functions (date, time handling)
│ ├── utils.py # Utility functions (date, time handling)
│ └── env.py # Configuration settings (SMTP, file paths, etc.)
└── README.md # Project readme
```
### `config/env.py`
### `src/env.py`
The configuration file contains SMTP settings, file paths, and customizable parameters for the draw.
@ -40,7 +38,7 @@ Example `env.py`:
SMTP_SERVER = "smtp.example.com"
SMTP_PORT = 25
SENDER_EMAIL = "santa@example.com"
CSV_FILE_PATH = "secret_santa_DB.csv"
CSV_FILE_PATH = r"secret_santa_DB.csv"
DRAW_PER_PERSON = 2 # Choose 1 or 2 recipients per person
# Email content
@ -68,12 +66,15 @@ This email was sent automatically, please do not reply.
1. Clone the repository or download the script files.
2. Ensure you have Python installed on your system. If not, download and install Python from [here](https://www.python.org/downloads/).
3. Set up the `env.py` file in the `config/` directory, adjusting the SMTP settings, CSV file path, and draw parameters as needed.
Example structure of the CSV file:
3. Set up the `env.py` file in the `src/` directory, adjusting the SMTP settings, CSV file path, and draw parameters as needed.
Example structure of the CSV file
with the following colunms
```csv
Name,Email,Last_Year_Recipient_1,Last_Year_Recipient_2
```
```csv
Alice,alice@example.com,Bob,Charlie
Bob,bob@example.com,Alice,David
Charlie,charlie@example.com,David,Alice

View File

@ -12,10 +12,11 @@ def draw_names(previous_draw, draws_per_person):
new_draw = [] # Store new draw results
for i in range(len(participants)):
giver = previous_draw[i][0]
email = previous_draw[i][1]
print(email)
last_year_r1 = previous_draw[i][2]
last_year_r2 = previous_draw[i][3]
giver = previous_draw[i][0]
email = previous_draw[i][1]
available_participants = participants.copy()
try:

View File

@ -1,7 +1,7 @@
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from config.env import SMTP_SERVER, SMTP_PORT, SENDER_EMAIL
from env import SMTP_SERVER, SMTP_PORT, SENDER_EMAIL
def send_email(receiver_email, subject, msg):
"""

View File

@ -1,8 +1,8 @@
from config.env import CSV_FILE_PATH, DRAW_PER_PERSON, EMAIL_SUBJECT, EMAIL_BODY
from src.file_io import open_csv, save_csv
from src.draw import draw_names
from src.emailer import send_email
from src.utils import get_current_time
from env import CSV_FILE_PATH, DRAW_PER_PERSON, EMAIL_SUBJECT, EMAIL_BODY
from file_io import open_csv, save_csv
from draw import draw_names
from emailer import send_email
from utils import get_current_time
from datetime import date
def send_all_emails(new_draw):