-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathload_templates.py
More file actions
140 lines (115 loc) · 5.85 KB
/
load_templates.py
File metadata and controls
140 lines (115 loc) · 5.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import os
import django
# Setup Django environment
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'bulk_email_dashboard.settings')
django.setup()
from django.contrib.auth.models import User
from emails.models import EmailTemplate
def create_templates():
# specialized styles
bg_color = "#F2EDD7"
text_color = "#16194F"
# Common Footer
footer = f"""
<div style="margin-top: 30px; padding-top: 20px; border-top: 1px solid {text_color}; font-size: 12px; color: {text_color};">
<p>
<a href="https://somali-music.vercel.app/contact" style="color: {text_color}; text-decoration: none; font-weight: bold;">Contact Us</a> |
<a href="https://somali-music.vercel.app/download" style="color: {text_color}; text-decoration: none; font-weight: bold;">Download App</a> |
<a href="https://discord.com/invite/ryApNA5WDj" style="color: {text_color}; text-decoration: none; font-weight: bold;">Join Discord</a>
</p>
<p>© 2026 Somali Music. All rights reserved.</p>
<p><a href="#" style="color: {text_color}; text-decoration: underline;">Unsubscribe</a></p>
</div>
"""
# Template 1: Welcome to Somali Music
welcome_body = f"""
<div style="background-color: {bg_color}; padding: 40px; font-family: Arial, sans-serif; color: {text_color};">
<div style="max-width: 600px; margin: 0 auto; background-color: #ffffff; padding: 30px; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.1);">
<h1 style="color: {text_color}; margin-bottom: 20px;">Welcome, {{name}}! 🎵</h1>
<p style="font-size: 16px; line-height: 1.6;">
Hi <strong style="color: {text_color};">{{name}}</strong>,
</p>
<p style="font-size: 16px; line-height: 1.6;">
Thank you for joining <strong>Somali Music</strong>! We're excited to have you on board.
Discover the best tracks, create playlists, and enjoy the rhythm of Somalia.
</p>
<div style="text-align: center; margin: 30px 0;">
<a href="https://somali-music.vercel.app/" style="background-color: {text_color}; color: {bg_color}; padding: 12px 25px; text-decoration: none; border-radius: 5px; font-weight: bold;">Start Listening</a>
</div>
{footer}
</div>
</div>
"""
# Template 2: Download App
app_body = f"""
<div style="background-color: {bg_color}; padding: 40px; font-family: Arial, sans-serif; color: {text_color};">
<div style="max-width: 600px; margin: 0 auto; background-color: #ffffff; padding: 30px; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.1);">
<h1 style="color: {text_color}; margin-bottom: 20px;">Take Your Music Everywhere 📱</h1>
<p style="font-size: 16px; line-height: 1.6;">
Hello <strong style="color: {text_color};">{{name}}</strong>,
</p>
<p style="font-size: 16px; line-height: 1.6;">
Did you know you can listen to your favorite Somali tracks offline?
Download our official mobile app today for the best experience!
</p>
<div style="text-align: center; margin: 30px 0;">
<a href="https://somali-music.vercel.app/download" style="background-color: {text_color}; color: {bg_color}; padding: 12px 25px; text-decoration: none; border-radius: 5px; font-weight: bold;">Download App</a>
</div>
{footer}
</div>
</div>
"""
# Template 3: Discord Invite
discord_body = f"""
<div style="background-color: {bg_color}; padding: 40px; font-family: Arial, sans-serif; color: {text_color};">
<div style="max-width: 600px; margin: 0 auto; background-color: #ffffff; padding: 30px; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.1);">
<h1 style="color: {text_color}; margin-bottom: 20px;">Join Our Community! 💬</h1>
<p style="font-size: 16px; line-height: 1.6;">
Hey <strong style="color: {text_color};">{{name}}</strong>,
</p>
<p style="font-size: 16px; line-height: 1.6;">
Want to discuss the latest hits, request songs, or just hang out with other music lovers?
Join our official Discord server!
</p>
<div style="text-align: center; margin: 30px 0;">
<a href="https://discord.com/invite/ryApNA5WDj" style="background-color: #5865F2; color: white; padding: 12px 25px; text-decoration: none; border-radius: 5px; font-weight: bold;">Join Discord Server</a>
</div>
{footer}
</div>
</div>
"""
# Get the first superuser or user to assign templates to
user = User.objects.filter(is_superuser=True).first()
if not user:
user = User.objects.first()
if not user:
print("No user found! Please create a user first.")
return
# Create templates
templates = [
{
"name": "Somali Music - Welcome",
"subject": "Welcome to Somali Music, {name}!",
"body": welcome_body
},
{
"name": "Somali Music - Download App",
"subject": "Download the Somali Music App 🎵",
"body": app_body
},
{
"name": "Somali Music - Discord Invite",
"subject": "Join our Music Community! 🎧",
"body": discord_body
}
]
for t in templates:
EmailTemplate.objects.create(
user=user,
name=t["name"],
subject=t["subject"],
body=t["body"]
)
print(f"Created template: {t['name']}")
if __name__ == "__main__":
create_templates()