automailmarch25

This commit is contained in:
Ubuntu 2025-03-25 04:56:54 +00:00
parent ebec31e61a
commit 04c4b04ba9
59 changed files with 649 additions and 154 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

View File

Binary file not shown.

View File

@ -2,4 +2,5 @@ from django.contrib import admin
from .models import * from .models import *
admin.site.register(emails_creadentials) admin.site.register(emails_creadentials)
admin.site.register(auto_email_function_errors) admin.site.register(auto_email_function_errors)
admin.site.register(Mnf_Notification) admin.site.register(Mnf_Notification)
admin.site.register(Member_News)

View File

@ -2,4 +2,5 @@ from django.apps import AppConfig
class AutoEmailConfig(AppConfig): class AutoEmailConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'auto_email' name = 'auto_email'

Binary file not shown.

View File

@ -0,0 +1,48 @@
# Generated by Django 4.1.13 on 2024-04-08 05:13
from django.db import migrations, models
import uuid
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='auto_email_function_errors',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('email', models.EmailField(blank=True, max_length=254, null=True)),
('error', models.TextField(blank=True, null=True)),
('email_code', models.CharField(blank=True, max_length=150, null=True)),
('key_value', models.TextField(blank=True, null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
],
),
migrations.CreateModel(
name='emails_creadentials',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('email', models.EmailField(blank=True, max_length=254, null=True)),
('password', models.CharField(blank=True, max_length=250, null=True)),
],
),
migrations.CreateModel(
name='Mnf_Notification',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('user', models.CharField(max_length=100)),
('read', models.BooleanField(default=False)),
('title', models.CharField(blank=True, max_length=200, null=True)),
('service_name', models.CharField(blank=True, max_length=200, null=True)),
('image_url', models.CharField(blank=True, max_length=200, null=True)),
('created', models.DateTimeField(auto_now_add=True, null=True)),
('updated', models.DateTimeField(auto_now=True, null=True)),
],
),
]

View File

@ -0,0 +1,18 @@
# Generated by Django 4.1.13 on 2024-07-05 10:43
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('auto_email', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='mnf_notification',
name='content',
field=models.CharField(blank=True, max_length=800, null=True),
),
]

View File

@ -0,0 +1,28 @@
# Generated by Django 4.1.13 on 2024-12-31 11:02
from django.db import migrations, models
import uuid
class Migration(migrations.Migration):
dependencies = [
('auto_email', '0002_mnf_notification_content'),
]
operations = [
migrations.CreateModel(
name='Member_News',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('user', models.CharField(max_length=100)),
('read', models.BooleanField(default=False)),
('title', models.CharField(blank=True, max_length=200, null=True)),
('content', models.CharField(blank=True, max_length=800, null=True)),
('service_name', models.CharField(blank=True, max_length=200, null=True)),
('image_url', models.CharField(blank=True, max_length=200, null=True)),
('created', models.DateTimeField(auto_now_add=True, null=True)),
('updated', models.DateTimeField(auto_now=True, null=True)),
],
),
]

View File

@ -0,0 +1,23 @@
# Generated by Django 4.1.13 on 2025-01-02 11:29
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('auto_email', '0003_member_news'),
]
operations = [
migrations.AlterField(
model_name='member_news',
name='title',
field=models.CharField(blank=True, max_length=800, null=True),
),
migrations.AlterField(
model_name='mnf_notification',
name='title',
field=models.CharField(blank=True, max_length=800, null=True),
),
]

View File

@ -0,0 +1,17 @@
# Generated by Django 4.1.13 on 2025-03-08 11:44
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('auto_email', '0004_alter_member_news_title_alter_mnf_notification_title'),
]
operations = [
migrations.AlterModelOptions(
name='mnf_notification',
options={'ordering': ['-updated']},
),
]

View File

@ -18,15 +18,33 @@ class auto_email_function_errors(models.Model):
key_value = models.TextField(null=True,blank=True) key_value = models.TextField(null=True,blank=True)
created_at = models.DateTimeField(auto_now_add=True) created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True) updated_at = models.DateTimeField(auto_now=True)
class Mnf_Notification(models.Model): class Mnf_Notification(models.Model):
id = models.UUIDField(primary_key=True,editable=False,default=uuid.uuid4) id = models.UUIDField(primary_key=True,editable=False,default=uuid.uuid4)
user = models.CharField(max_length=100) user = models.CharField(max_length=100)
read = models.BooleanField(default = False) read = models.BooleanField(default = False)
title = models.CharField(max_length = 200,blank=True, null=True) title = models.CharField(max_length = 800,blank=True, null=True)
content = models.CharField(max_length = 800,blank=True, null=True)
service_name = models.CharField(max_length = 200,blank=True, null=True) service_name = models.CharField(max_length = 200,blank=True, null=True)
image_url = models.CharField(max_length = 200,blank=True, null=True) image_url = models.CharField(max_length = 200,blank=True, null=True)
created = models.DateTimeField(auto_now_add=True,blank=True, null=True) created = models.DateTimeField(auto_now_add=True,blank=True, null=True)
updated = models.DateTimeField(auto_now=True,blank=True, null=True) updated = models.DateTimeField(auto_now=True,blank=True, null=True)
class Meta:
ordering = ['-updated']
def __str__(self):
return self.user
class Member_News(models.Model):
id = models.UUIDField(primary_key=True,editable=False,default=uuid.uuid4)
user = models.CharField(max_length=100)
read = models.BooleanField(default = False)
title = models.CharField(max_length = 800,blank=True, null=True)
content = models.CharField(max_length = 800,blank=True, null=True)
service_name = models.CharField(max_length = 200,blank=True, null=True)
image_url = models.CharField(max_length = 200,blank=True, null=True)
created = models.DateTimeField(auto_now_add=True,blank=True, null=True)
updated = models.DateTimeField(auto_now=True,blank=True, null=True)

View File

@ -4,4 +4,36 @@ from rest_framework import serializers
class Mnf_NotificationSerializer(serializers.ModelSerializer): class Mnf_NotificationSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = Mnf_Notification model = Mnf_Notification
fields = '__all__' fields = '__all__'
class Member_NewsSerializer(serializers.ModelSerializer):
class Meta:
model = Member_News
fields = '__all__'
class Mnf_getNews(serializers.ModelSerializer):
class Meta:
model = Mnf_Notification
fields = '__all__'
def to_representation(self, instance):
representation = super().to_representation(instance)
replacement_name = self.context.get('replacement_name', 'User')
# Define a reusable replacement function
def replace_words(text,name):
if not text:
return text
# Perform replacements
text = text.replace("your", f"{name}'s").replace("Your", f"{name}'s")
text = text.replace("you", name).replace("You", name)
return text
# Update 'title' field
if 'title' in representation:
representation['title'] = replace_words(representation['title'],replacement_name)
# Update 'content' field
if 'content' in representation:
representation['content'] = replace_words(representation['content'],replacement_name)
return representation

View File

@ -11,14 +11,16 @@
</style> </style>
</head> </head>
<body style="margin: 0; padding: 0; box-sizing: border-box; font-family: 'Poppins', sans-serif;font-size: 16px;"> <body style="margin: 0; padding: 0; box-sizing: border-box; font-family: 'Poppins', sans-serif;font-size: 16px;">
<div style="max-width: 70vw; box-shadow: 0px 4px 27px 0px #00000040; margin: 16px auto;"> <div style="max-width: 100vw; box-shadow: 0px 4px 27px 0px #00000040; margin: 16px auto;">
<img src="https://uidemos.s3.ap-south-1.amazonaws.com/v2_512.png" style="width: 100%;"> <img src="https://uidemos.s3.ap-south-1.amazonaws.com/v2_512.png" style="width: 100%;">
<!-- <h1 style="font-size: 18px; font-weight: 700; text-align: center; margin: auto; color: #33B0CA;">CONGRATULATIONS! <br>Your Premise is now live!!!</h1> --> <!-- <h1 style="font-size: 18px; font-weight: 700; text-align: center; margin: auto; color: #33B0CA;">CONGRATULATIONS! <br>Your Premise is now live!!!</h1> -->
<h1 style="font-size: 1.25em; font-weight: 800; text-align: center; margin: auto; color: #33B0CA;"><b>{{title1}}</b></h1> <h1 style="font-size: 1.25em; font-weight: 800; text-align: center; margin: auto; color: #33B0CA;"><b>{{title1}}</b></h1>
<h2 style="font-size: 1.25em; font-weight: 800; text-align: center; margin: auto; color: #33B0CA;"><b>{{title2}}<br></b></h2> <h2 style="font-size: 1.25em; font-weight: 800; text-align: center; margin: auto; color: #33B0CA;"><b>{{title2}}<br></b></h2>
<div style="padding: 28px"> <div style="padding: 28px">
<div style="text-align: center;"> <div style="text-align: center;">
<img src="{{doodleurl}}" style="width: 235px; height: 245px;"> <a href="{{ doodlelink }}" target="_blank">
<img src="{{ doodleurl }}" style="width: 235px; height: 245px;">
</a>
</div> </div>
<article> <article>
<!-- <h2 style="font-size: 16px; font-weight: 500; color: #252525; margin-bottom: 16px;">Dear {{User}},</h2> <!-- <h2 style="font-size: 16px; font-weight: 500; color: #252525; margin-bottom: 16px;">Dear {{User}},</h2>
@ -31,11 +33,15 @@
{% load custom_filters %} {% load custom_filters %}
{% with pattern="\[(.*?)\]\((.*?)\)" %} {% with pattern="\[(.*?)\]\((.*?)\)" %}
{% with modified_value=invitation|urlize_text|safe %} {% with modified_value=invitation|urlize_text|safe %}
<p>{{ modified_value|safe }}</p> <div>{{ modified_value|safe }}</div>
{% endwith %}
{% with modified_value=additional|urlize_text|safe %}
<p>{{ modified_value|safe }}</p>
{% endwith %} {% endwith %}
{% if additional %}
{% with modified_value=additional|urlize_text|safe %}
<p style:"text-align:center;">{{ modified_value|safe }}</p>
{% endwith %}
{% else %}
<p></p>
{% endif %}
{% endwith %} {% endwith %}
</article> </article>
</div> </div>

View File

@ -0,0 +1,134 @@
<style>
body,
table,
td,
a {
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
table,
td {
mso-table-lspace: 0pt;
mso-table-rspace: 0pt;
}
img {
-ms-interpolation-mode: bicubic;
}
img {
border: 0;
height: auto;
line-height: 100%;
outline: none;
text-decoration: none;
}
table {
border-collapse: collapse !important;
}
body {
height: 100% !important;
margin: 0 !important;
padding: 0 !important;
width: 100% !important;
}
a[x-apple-data-detectors] {
color: inherit !important;
text-decoration: none !important;
font-size: inherit !important;
font-family: inherit !important;
font-weight: inherit !important;
line-height: inherit !important;
}
div[style*="margin: 16px 0;"] {
margin: 0 !important;
}
</style>
<body style="background-color: #f7f5fa; margin: 0 !important; padding: 0 !important;">
{% block message %}
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td bgcolor="#33B0CA" align="center">
<table border="0" cellpadding="0" cellspacing="0" width="480">
<tr>
<td align="center" valign="top" style="padding: 40px 10px 20px 10px;">
<div style="display: block; font-family: Helvetica, Arial, sans-serif; color: #ffffff; font-size: 25px;"border="0"><b>My Next Film</b></div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor="#33B0CA" align="center" style="padding: 0px 10px 0px 10px;">
<table border="0" cellpadding="5" cellspacing="0" width="480" style="width: 60%">
<tr>
<td bgcolor="#ffffff" align="center" valign="top" style="border-radius:4px 4px 0px 0px; color: #111111; font-family: Helvetica, Arial, sans-serif; font-size: 48px; font-weight: 400; line-height: 48px;">
<h1 style="font-size: 25px; font-weight: 400;font-family: Helvetica, Arial, sans-serif; margin: 0; color: #ee3c4d;"><b>{{title1}}</b></h1>
<h2 style="font-size: 22px; font-weight: 400;font-family: Helvetica, Arial, sans-serif; margin: 0; color: #ee3c4d;"><b>{{title2}}<br></b></h2>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor="#f4f4f4" align="center" style="padding: 0px 10px 0px 10px;">
<table border="0" cellpadding="0" cellspacing="0" width="480" style="width: 60%">
<tr>
<td bgcolor="#ffffff" align="left">
<table width="100%" border="0" cellspacing="10" cellpadding="1" padding:"5px">
<tr>
<td style="padding:20px;">
{% load custom_filters %}
{% with pattern="\[(.*?)\]\((.*?)\)" %}
{% with modified_value=invitation|urlize_text|safe %}
<p>{{ modified_value|safe }}</p>
{% endwith %}
{% with modified_value=additional|urlize_text|safe %}
<p>{{ modified_value|safe }}</p>
{% endwith %}
{% endwith %}
<br>
<br>
<a href="{{pageurl}}"><img src="{{poster}}" alt="{{poster}}" style="max-width:100%;height:auto;" ></a>
<br>
<br>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor="#ffffff" align="center">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#ffffff" align="center"
style="padding: 30px 30px 30px 30px; border-top:1px solid #dddddd;">
<table border="0" cellspacing="0" cellpadding="0" style= "margin-top:-25px">
<tr>
<td bgcolor="" align="left"
style="color: #666666; font-family: Helvetica, Arial, sans-serif; font-size: 14px; font-weight: 400; line-height: 18px;">
<p style="margin: 0;">For any related queries, please reach out to ."<a href="mailto:support@mynextfilm.ai" target="_blank"
style="color: #111111; font-weight: 700;">MY NEXT FILM PRIVATE LIMITED<a>".</p><div style="opacity:0.05">{{emailcode}}<div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
{% endblock message %}
</body>

Binary file not shown.

View File

@ -6,5 +6,16 @@ register = template.Library()
@register.filter @register.filter
def urlize_text(value): def urlize_text(value):
if not value:
return ""
url_pattern = re.compile(r'\[([^]]+)\]\(([^)]+)\)') url_pattern = re.compile(r'\[([^]]+)\]\(([^)]+)\)')
print("##############",value,"###############")
if "Register" in value and "Embrace" in value:
matches = re.findall(r"\[([^\]]+)]\(([^)]+)\)", value)
sender_name, sender_url = matches[0]
receiver_name, receiver_url = matches[1]
return f''' <p style="text-align: center; font-size:34px;"> <a href="{sender_url}" target="_blank">{sender_name}</a> to <a href="{receiver_url}" target="_blank">{receiver_name}</a> </p> '''
elif "Embrace" in value or "Message" in value or "Masterpiece" in value:
return mark_safe(url_pattern.sub(r'<table width="100%" cellspacing="0" cellpadding="0" style="text-align: center;"> <tr> <td align="center"> <a href="\2" style="display: inline-block; padding: 10px 20px; font-size: 34px; border-radius: 5px;">\1</a> </td> </tr></table>', value))
return mark_safe(url_pattern.sub(r'<a href="\2">\1</a>', value)) return mark_safe(url_pattern.sub(r'<a href="\2">\1</a>', value))

View File

@ -8,6 +8,6 @@ urlpatterns = [
path('mnfnotification/', views.mnf_notification, name="mnfnotification"), path('mnfnotification/', views.mnf_notification, name="mnfnotification"),
path('mnfnotification/<str:pk>/', views.mnf_notification, name="mnfnotification"), path('mnfnotification/<str:pk>/', views.mnf_notification, name="mnfnotification"),
path('getnews/<str:pk>/', views.getNews, name="getnews"),
] ]

View File

@ -1,32 +1,23 @@
from .models import * from .models import *
from .serializer import * from .serializers import *
from rest_framework.response import Response from rest_framework.response import Response
from rest_framework.decorators import (api_view, authentication_classes, from rest_framework.decorators import (api_view, authentication_classes,
permission_classes) permission_classes)
from rest_framework_simplejwt.authentication import JWTAuthentication from rest_framework_simplejwt.authentication import JWTAuthentication
from rest_framework.permissions import AllowAny, IsAuthenticated from rest_framework.permissions import AllowAny, IsAuthenticated
from django.core.mail import EmailMultiAlternatives from django.core.mail import EmailMultiAlternatives
from django.utils.html import strip_tags
from django.template.loader import render_to_string from django.template.loader import render_to_string
from django.conf import settings
from MNF.settings import BasePath
from django.core.mail import send_mail , get_connection from django.core.mail import send_mail , get_connection
from payment.models import privilegedUser1
from django.contrib.auth.models import User from django.contrib.auth.models import User
#from viewerLounge.models import VideoIntroduction
from lpp.models import MNFLPPDDatabase
#from harkat.models import HarkatClubDatabase
from mnfapp.models import centralDatabase from mnfapp.models import centralDatabase
import os import os
from threading import Thread from threading import Thread
import pandas as pd import pandas as pd
from auto_email.models import emails_creadentials , auto_email_function_errors from auto_email.models import emails_creadentials , auto_email_function_errors
from MNF.settings import BasePath from MNF.settings import BasePath
from users.models import UserCredentialsForBlockchain import MNF.settings as setting
#from ScriptPad2.models import SPProject from django.conf import settings
from scriptAudit.models import ScriptAuditModel import re
#from ideamall2.models import Premise
from mnfapp.models import ReferUser
basepath = BasePath() basepath = BasePath()
@ -40,40 +31,46 @@ def newfunc(list):
def poster(user,email_code=None): def poster(user,email_code=None):
try: try:
data = User.objects.filter(email = user).values() # data = User.objects.filter(email = user).values()
id = data[0]['id'] # id = data[0]['id']
if email_code.startswith("MR"): if email_code.startswith("MR"):
return '1' return '1'
elif email_code.startswith("IM"): elif email_code.startswith("IM"):
return '2' return '2'
elif email_code.startswith("SD"): elif email_code.startswith("SD"):
return '3' return '3'
elif email_code.startswith("SB"): elif email_code.startswith("SB"):
return '4' return '4'
elif email_code.startswith("CP"): elif email_code.startswith("CP"):
return '5' return '5'
# elif email_code.startswith("PP"): # elif email_code.startswith("PP"):
# return '6' # return '6'
elif email_code.startswith("PP"): elif email_code.startswith("PP"):
return '7' return '7'
elif email_code.startswith("ID"): elif email_code.startswith("ID"):
return '8' return '8'
# elif email_code.startswith("ID"): elif email_code.startswith("IP"):
# return '9' return '9'
elif email_code.startswith("GT"): elif email_code.startswith("GT"):
return '10' return '10'
elif email_code.startswith("RM"): elif email_code.startswith("RM"):
return '11' return '11'
elif email_code.startswith("RN"): elif email_code.startswith("RN"):
return '12' return '12'
elif email_code.startswith("TN"): elif email_code.startswith("TN"):
return '13' return '13'
elif email_code.startswith("BL"): elif email_code.startswith("BL"):
return '14' return '14'
elif email_code.startswith("PM"): elif email_code.startswith("PM"):
return '15' return '15'
elif email_code.startswith("VW"): elif email_code.startswith("VW"):
return '16' return '16'
elif email_code.startswith("JP"):
return '18'
elif email_code.startswith("SS"):
return '19'
elif email_code.startswith("PB"):
return '3'
else : else :
pass pass
except Exception as e: except Exception as e:
@ -92,12 +89,12 @@ def mailer(all_email,email_code,key_value,filePath):
name = centralDatabase.objects.filter(email = to_email) name = centralDatabase.objects.filter(email = to_email)
if name.exists(): if name.exists():
name = name[0] name = name[0]
userName = name.firstName if name.firstName else name.email userName = name.firstName.capitalize() if name.firstName else name.email
except: except:
name = User.objects.filter(email = to_email) name = User.objects.filter(email = to_email)
if name.exists(): if name.exists():
name = name[0] name = name[0]
userName = name.first_name if name.first_name else name.email userName = name.first_name.capitalize() if name.first_name else name.email
except: except:
userName = to_email userName = to_email
key_value.update({"User":userName}) key_value.update({"User":userName})
@ -106,131 +103,264 @@ def mailer(all_email,email_code,key_value,filePath):
s1 = slice(0, 2) s1 = slice(0, 2)
string = email_code[s1] string = email_code[s1]
value = fileexcel[fileexcel['sheet code'] == string] value = fileexcel[fileexcel['sheet code'] == string]
if len(value) <= 0: if len(value) <= 0:
auto_email_function_errors.objects.create(email = to_email,email_code=email_code,key_value=key_value,error="Email code does not match with any sheet ") auto_email_function_errors.objects.create(email = to_email,email_code=email_code,key_value=key_value,error="Email code does not match with any sheet ")
return print(('Email code does not match with any sheet')) return print(('Email code does not match with any sheet'))
sheet_name = value.iloc[0, 1] sheet_name = value.iloc[0, 1]
file_path = f"{basepath}/auto_email/email/EMAILSheet39.xlsx"
file_path = f"{basepath}/auto_email/email/EMAILSheet40.xlsx"
file = pd.read_excel(file_path, sheet_name=sheet_name, header=1) file = pd.read_excel(file_path, sheet_name=sheet_name, header=1)
row_data = file[file['Email Code'] == str(email_code)] row_data = file[file['Email Code'] == str(email_code)]
if len(row_data) <= 0: if len(row_data) <= 0:
auto_email_function_errors.objects.create(email = to_email,email_code=email_code,key_value=key_value,error="Email code is not present in any sheet") auto_email_function_errors.objects.create(email = to_email,email_code=email_code,key_value=key_value,error="Email code is not present in any sheet")
return print('Email code is not present in any sheet') return print('Email code is not present in any sheet')
row_data = row_data.fillna('') row_data = row_data.fillna('')
#from_email = row_data.iloc[0, 3] if row_data.iloc[0,7]:
from_email = 'noreply@mynextfilm.ai' additional_option_code = row_data.iloc[0, 7]
additional_option_code = row_data.iloc[0, 7] print(additional_option_code,"option code")
option_file = pd.read_excel( option_file = pd.read_excel(
file_path, sheet_name='Common Options', header=1) file_path, sheet_name='Common Options', header=1)
option_details = option_file[option_file['CODE'] == str( option_details = option_file[option_file['CODE'] == str(
additional_option_code)] additional_option_code)]
if len(option_details) <= 0: value = option_details['Language of the option'].iloc[0]
auto_email_function_errors.objects.create(email = to_email,email_code=email_code,key_value=key_value,error='options code does not match with sheet options code') print(value,"fkjsdljfsl")
return print('options code does not match with sheet options code') try:
poster_file = pd.read_excel(file_path, sheet_name='poster', header=1) match = re.search(r'\((.*?)\)', str(value))
poster_code = poster(user=to_email,email_code = email_code) if match:
postercode = 'P'+str(poster_code) value_in_parentheses = match.group(1)
if poster_code == '11': else:
auto_email_function_errors.objects.create(email = to_email,email_code=email_code,key_value=key_value,error="user has not any priority to send poster") value_in_parentheses="#"
return print('user has not any priority to send poster') except:
poster_url = poster_file[poster_file['Poster code'] == str(postercode)] value_in_parentheses="#"
posterurl = poster_url.iloc[0, 2] print(option_details)
page_url = poster_url.iloc[0,3]
doodle_url = poster_url.iloc[0,4]
dic_subject = str(row_data.iloc[0, 4]).replace('{}','').format_map(key_value)
dic_invitation = str(row_data.iloc[0, 6]).replace('{}','').format_map(key_value)
dic_additional = str(option_details.iloc[0, 2]).replace('{}','').format_map(key_value)
title = str(row_data.iloc[0, 5]).replace('{}','').format_map(key_value).split('/')
print("title", title)
message = {'subject': dic_subject,
'title1': title[0],
'title2': title[1],
'invitation':dic_invitation,
'additional': dic_additional,
'poster': posterurl,
'pageurl':page_url,
'doodleurl':doodle_url,
'emailcode':email_code
}
msg_html = render_to_string('email_template.html', message)
excel_file = f"{basepath}/auto_email/email/EmailCredentials.xlsx"
details = pd.read_excel(excel_file)
email_data = details[details['email'] == str(from_email)]
host = email_data.iloc[0, 1]
port = int(email_data.iloc[0, 2])
password = emails_creadentials.objects.get(email=from_email)
print("before connection")
#connection = get_connection(host=host,port=port,username=from_email,password=password.password,use_tls=True)
from_email1 = "mynextfilm <noreply@mynextfilm>"
# send_mail(message['subject'],title[1],from_email=from_email,recipient_list=[to_email],html_message=msg_html,connection=connection)
sendMail = EmailMultiAlternatives(message['subject'],title[1],from_email1,[to_email])
print("after connection")
sendMail.attach_alternative(msg_html,"text/html")
if filePath is not None:
sendMail.attach_file(f'{filePath}')
# if sheet_name == "Rendz (traction)":
# notification=Mnf_Notification(user=to_email,title=title[1],service_name = sheet_name,image_url = "/media/Notification_image/build_team.png")
# elif sheet_name == "membershipReferences":
# notification=Mnf_Notification(user=to_email,title=title[1],service_name = sheet_name,image_url = "/media/Notification_image/pitchdeck.png")
# elif sheet_name == "Misc.":cd
# notification=Mnf_Notification(user=to_email,title=title[1],service_name = sheet_name,image_url = "/media/Notification_image/ideamall.png")
if "Idea Mall" in sheet_name:
mnf_notification=Mnf_Notification(user=to_email,title=title[1],service_name = "Idea Mall",image_url = "/static/Notification_image/Idea_Mall.png")
elif "Conversion - LPP" in sheet_name:
mnf_notification=Mnf_Notification(user=to_email,title=title[1],service_name = "Conversion - LPP",image_url = "/static/Notification_image/Conversion_LPP.png")
elif "Script Builder" in sheet_name:
mnf_notification=Mnf_Notification(user=to_email,title=title[1],service_name = "Script Builder",image_url = "/static/Notification_image/Script_Builder.png")
elif "Messiah" in sheet_name:
mnf_notification=Mnf_Notification(user=to_email,title=title[1],service_name = "Messiah",image_url = "/static/Notification_image/Messiah.png")
elif "Project Centre" in sheet_name:
mnf_notification=Mnf_Notification(user=to_email,title=title[1],service_name = "Project Centre",image_url = "/static/Notification_image/Project_Centre.png")
elif "Harkat" in sheet_name:
mnf_notification=Mnf_Notification(user=to_email,title=title[1],service_name = "Harkat",image_url = "/static/Notification_image/Harkat.png")
elif "Pitchdeck Bundle" in sheet_name:
mnf_notification=Mnf_Notification(user=to_email,title=title[1],service_name = "Pitchdeck Bundle",image_url = "/static/Notification_image/Pitchdeck_Bundle.png")
elif "Script page" in sheet_name:
mnf_notification=Mnf_Notification(user=to_email,title=title[1],service_name = "Script Page",image_url = "/static/Notification_image/Script_page.png")
elif "subtitle" in sheet_name:
mnf_notification=Mnf_Notification(user=to_email,title=title[1],service_name = "Subtitle",image_url = "/static/Notification_image/subtitle.png")
elif "script pad" in sheet_name:
mnf_notification=Mnf_Notification(user=to_email,title=title[1],service_name = "script pad",image_url = "/static/Notification_image/scriptpad.png")
elif "narration" in sheet_name:
mnf_notification=Mnf_Notification(user=to_email,title=title[1],service_name = "Narration",image_url = "/static/Notification_image/narration.png")
elif "Institutional Membership" in sheet_name:
mnf_notification=Mnf_Notification(user=to_email,title=title[1],service_name = "Institutional Membership",image_url = "/static/Notification_image/Institutional_Membership.png")
elif "LPP - Admininstration" in sheet_name:
mnf_notification=Mnf_Notification(user=to_email,title=title[1],service_name = "LPP - Admininstration",image_url = "/static/Notification_image/LPP_Admininstration.png")
elif "Conversion ppt" in sheet_name:
mnf_notification=Mnf_Notification(user=to_email,title=title[1],service_name = "Conversion PPT",image_url = "/static/Notification_image/Conversion_ppt.png")
elif "viewers lounge" in sheet_name:
mnf_notification=Mnf_Notification(user=to_email,title=title[1],service_name = "Viewers Lounge",image_url = "/static/Notification_image/viewers_lounge.png")
elif "Ask a question" in sheet_name:
mnf_notification=Mnf_Notification(user=to_email,title=title[1],service_name = "Ask a question",image_url = "/static/Notification_image/subtitle.png")
elif "Payment" in sheet_name:
mnf_notification=Mnf_Notification(user=to_email,title=title[1],service_name = "Payment",image_url = "/static/Notification_image/payment.png")
elif "blockchain" in sheet_name:
mnf_notification=Mnf_Notification(user=to_email,title=title[1],service_name = "blockchain",image_url = "/static/Notification_image/blockchain.png")
elif "Sheet14" in sheet_name:
mnf_notification=Mnf_Notification(user=to_email,title=title[1],service_name = "Sheet14",image_url = "/static/Notification_image/subtitle.png")
elif "Institutional Membership" in sheet_name:
mnf_notification=Mnf_Notification(user=to_email,title=title[1],service_name = "Institutional Membership",image_url = "/static/Notification_image/subtitle.png")
elif "membershipReferences" in sheet_name:
mnf_notification=Mnf_Notification(user=to_email,title=title[1],service_name = "membershipReferences",image_url = "/static/Notification_image/subtitle.png")
else: else:
mnf_notification=Mnf_Notification(user=to_email,title=title[1],service_name = sheet_name) value_in_parentheses="#"
# from plyer import notification
# notification.notify(title = sheet_name,message = title[1],timeout=100,app_icon = f'{basepath}/media/Notification_image/Conversion_ppt.png',app_name=sheet_name ) # if len(option_details) <= 0:
print('mnf_not') # auto_email_function_errors.objects.create(email = to_email,email_code=email_code,key_value=key_value,error='options code does not match with sheet options code')
mnf_notification.save() # return print('options code does not match with sheet options code')
print("sendmail1")
print("before send mail") # poster_file = pd.read_excel(file_path, sheet_name='poster', header=1)
sendMail.send() # poster_code = poster(user=to_email,email_code = email_code)
# postercode = 'P'+str(poster_code)
# print("POSTER CODE:---------------",postercode)
# if poster_code == '11':
# auto_email_function_errors.objects.create(email = to_email,email_code=email_code,key_value=key_value,error="user has not any priority to send poster")
# return print('user has not any priority to send poster')
# poster_url = poster_file[poster_file['Poster code'] == str(postercode)]
# posterurl = poster_url.iloc[0, 2]
# page_url = poster_url.iloc[0,3]
# doodle_url = poster_url.iloc[0,4]
# print("poster id ##########################8888888#")
if row_data.iloc[0, 4]:
doodle_url = str(row_data.iloc[0, 12])
posterurl = str(row_data.iloc[0, 13])
dic_subject = str(row_data.iloc[0, 4]).replace('{}','').format_map(key_value)
dic_invitation = str(row_data.iloc[0, 6]).replace('{}','').format_map(key_value)
if len(option_details) <= 0:
dic_additional=None
else:
dic_additional = str(option_details.iloc[0, 2]).replace('{}','').format_map(key_value)
title = str(row_data.iloc[0, 5]).replace('{}','').format_map(key_value).split('/')
message = {'subject': dic_subject,
'title1': title[0],
'title2': title[1],
'invitation':dic_invitation,
'additional': dic_additional,
'poster': posterurl,
'doodlelink':value_in_parentheses,
'doodleurl':doodle_url,
'emailcode':email_code
}
msg_html = render_to_string('email_template.html', message)
print(message['subject'],'------------------',dic_invitation,dic_additional)
from_email = settings.EMAIL_HOST_USER_NAME
sendMail = EmailMultiAlternatives(message['subject'],title[1],from_email,[to_email])
sendMail.attach_alternative(msg_html,"text/html")
if filePath is not None:
sendMail.attach_file(f'{filePath}')
try:
sendMail.send()
print("mail sent")
except Exception as e:
auto_email_function_errors.objects.create(
email=to_email,
email_code=email_code,
key_value=key_value,
error=f"Failed to send email: {str(e)}"
)
print(f"Error while sending email to {to_email}: {e}")
print('done compete notification')
notification_title=False
news=False
if row_data.iloc[0, 10]:
notification_title = str(row_data.iloc[0, 10]).replace('{}','').format_map(key_value)
if row_data.iloc[0, 11]:
news = str(row_data.iloc[0, 11]).replace('{}','').format_map(key_value)
print("dgdfd",notification_title,news,"fddddddddddddddddddddddddd")
mnf_notification=False
mnf_news=False
if "Idea Mall" in sheet_name:
if notification_title:
mnf_notification=Mnf_Notification(user=to_email,title=notification_title,service_name = "Idea Mall",image_url = "/static/Notification_image/Idea_Mall.png")
if news:
mnf_news=Member_News(user=to_email,title=news,service_name = "Idea Mall",image_url = "/static/Notification_image/Idea_Mall.png")
elif "Conversion - LPP" in sheet_name:
if notification_title:
mnf_notification=Mnf_Notification(user=to_email,title=notification_title,service_name = "Conversion - LPP",image_url = "/static/Notification_image/Conversion_LPP.png")
if news:
mnf_news=Member_News(user=to_email,title=news,service_name = "Conversion - LPP",image_url = "/static/Notification_image/Conversion_LPP.png")
elif "Script Builder" in sheet_name:
if notification_title:
mnf_notification=Mnf_Notification(user=to_email,title=notification_title,service_name = "Script Builder",image_url = "/static/Notification_image/Script_Builder.png")
if news:
mnf_news=Member_News(user=to_email,title=news,service_name = "Script Builder",image_url = "/static/Notification_image/Script_Builder.png")
elif "Messiah" in sheet_name:
if notification_title:
mnf_notification=Mnf_Notification(user=to_email,title=notification_title,service_name = "Messiah",image_url = "/static/Notification_image/Messiah.png")
if news:
mnf_news=Member_News(user=to_email,title=news,service_name = "Messiah",image_url = "/static/Notification_image/Messiah.png")
elif "Project Centre" in sheet_name:
if notification_title:
mnf_notification=Mnf_Notification(user=to_email,title=notification_title,service_name = "Project Centre",image_url = "/static/Notification_image/Project_Centre.png")
if news:
mnf_news=Member_News(user=to_email,title=news,service_name = "Project Centre",image_url = "/static/Notification_image/Project_Centre.png")
elif "Harkat" in sheet_name:
if notification_title:
mnf_notification=Mnf_Notification(user=to_email,title=notification_title,service_name = "Harkat",image_url = "/static/Notification_image/Harkat.png")
if news:
mnf_news=Member_News(user=to_email,title=news,service_name = "Harkat",image_url = "/static/Notification_image/Harkat.png")
elif "Pitchdeck Bundle" in sheet_name:
if notification_title:
mnf_notification=Mnf_Notification(user=to_email,title=notification_title,service_name = "Pitchdeck Bundle",image_url = "/static/Notification_image/Pitchdeck_Bundle.png")
if news:
mnf_news=Member_News(user=to_email,title=news,service_name = "Pitchdeck Bundle",image_url = "/static/Notification_image/Pitchdeck_Bundle.png")
elif "Script page" in sheet_name:
if notification_title:
mnf_notification=Mnf_Notification(user=to_email,title=notification_title,service_name = "Script Page",image_url = "/static/Notification_image/Script_page.png")
if news:
mnf_news=Member_News(user=to_email,title=news,service_name = "Script Page",image_url = "/static/Notification_image/Script_page.png")
elif "subtitle" in sheet_name:
if notification_title:
mnf_notification=Mnf_Notification(user=to_email,title=notification_title,service_name = "Subtitle",image_url = "/static/Notification_image/subtitle.png")
if news:
mnf_news=Member_News(user=to_email,title=news,service_name = "Subtitle",image_url = "/static/Notification_image/subtitle.png")
elif "script pad" in sheet_name:
if notification_title:
mnf_notification=Mnf_Notification(user=to_email,title=notification_title,service_name = "script pad",image_url = "/static/Notification_image/subtitle.png")
if news:
mnf_news=Member_News(user=to_email,title=news,service_name = "script pad",image_url = "/static/Notification_image/subtitle.png")
elif "narration" in sheet_name:
if notification_title:
mnf_notification=Mnf_Notification(user=to_email,title=notification_title,service_name = "Narration",image_url = "/static/Notification_image/narration.png")
if news:
mnf_news=Member_News(user=to_email,title=news,service_name = "narration",image_url = "/static/Notification_image/narration.png")
elif "Institutional Membership" in sheet_name:
if notification_title:
mnf_notification=Mnf_Notification(user=to_email,title=notification_title,service_name = "Institutional Membership",image_url = "/static/Notification_image/Institutional_Membership.png")
if news:
mnf_news=Member_News(user=to_email,title=news,service_name = "Institutional Membership",image_url = "/static/Notification_image/Institutional_Membership.png")
elif "LPP - Admininstration" in sheet_name:
if notification_title:
mnf_notification=Mnf_Notification(user=to_email,title=notification_title,service_name = "LPP - Admininstration",image_url = "/static/Notification_image/LPP_Admininstration.png")
if news:
mnf_news=Member_News(user=to_email,title=news,service_name = "LPP - Admininstration",image_url = "/static/Notification_image/LPP_Admininstration.png")
elif "Conversion ppt" in sheet_name:
if notification_title:
mnf_notification=Mnf_Notification(user=to_email,title=notification_title,service_name = "Conversion PPT",image_url = "/static/Notification_image/Conversion_ppt.png")
if news:
mnf_news=Member_News(user=to_email,title=news,service_name = "Conversion PPT",image_url = "/static/Notification_image/Conversion_ppt.png")
elif "viewers lounge" in sheet_name:
if notification_title:
mnf_notification=Mnf_Notification(user=to_email,title=notification_title,service_name = "Viewers Lounge",image_url = "/static/Notification_image/viewers_lounge.png")
if news:
mnf_news=Member_News(user=to_email,title=news,service_name = "Viewers Lounge",image_url = "/static/Notification_image/viewers_lounge.png")
elif "Ask a question" in sheet_name:
if notification_title:
mnf_notification=Mnf_Notification(user=to_email,title=notification_title,service_name = "Ask a question",image_url = "/static/Notification_image/subtitle.png")
if news:
mnf_news=Member_News(user=to_email,title=news,service_name = "Ask a question",image_url = "/static/Notification_image/subtitle.png")
elif "Payment" in sheet_name:
if notification_title:
mnf_notification=Mnf_Notification(user=to_email,title=notification_title,service_name = "Payment",image_url = "/static/Notification_image/payment.png")
if news:
mnf_news=Member_News(user=to_email,title=news,service_name = "Payment",image_url = "/static/Notification_image/payment.png")
elif "blockchain" in sheet_name:
if notification_title:
mnf_notification=Mnf_Notification(user=to_email,title=notification_title,service_name = "blockchain",image_url = "/static/Notification_image/blockchain.png")
if news:
mnf_news=Member_News(user=to_email,title=news,service_name = "blockchain",image_url = "/static/Notification_image/blockchain.png")
elif "Sheet14" in sheet_name:
if notification_title:
mnf_notification=Mnf_Notification(user=to_email,title=notification_title,service_name = "Sheet14",image_url = "/static/Notification_image/subtitle.png")
if news:
mnf_news=Member_News(user=to_email,title=news,service_name = "Sheet14",image_url = "/static/Notification_image/subtitle.png")
elif "Institutional Membership" in sheet_name:
if notification_title:
mnf_notification=Mnf_Notification(user=to_email,title=notification_title,service_name = "Institutional Membership",image_url = "/static/Notification_image/subtitle.png")
if news:
mnf_news=Member_News(user=to_email,title=news,service_name = "Institutional Membership",image_url = "/static/Notification_image/subtitle.png")
elif "membershipReferences" in sheet_name:
if notification_title:
mnf_notification=Mnf_Notification(user=to_email,title=notification_title,service_name = "membershipReferences",image_url = "/static/Notification_image/subtitle.png")
if news:
mnf_news=Member_News(user=to_email,title=news,service_name = "membershipReferences",image_url = "/static/Notification_image/subtitle.png")
elif "Juggernaut" in sheet_name:
if notification_title:
mnf_notification=Mnf_Notification(user=to_email,title=notification_title,service_name = "Juggernaut",image_url = "/static/Notification_image/Juggernaut.png")
if news:
mnf_news=Member_News(user=to_email,title=news,service_name = "Juggernaut",image_url = "/static/Notification_image/Juggernaut.png")
elif "giftsubscription" in sheet_name:
if notification_title:
mnf_notification=Mnf_Notification(user=to_email,title=notification_title,service_name = "giftsubscription",image_url = "/static/Notification_image/Juggernaut.png")
if news:
mnf_news=Member_News(user=to_email,title=news,service_name = "giftsubscription",image_url = "/static/Notification_image/Juggernaut.png")
elif "storytoscript" in sheet_name:
if notification_title:
mnf_notification=Mnf_Notification(user=to_email,title=notification_title,service_name = "storytoscript",image_url = "/static/Notification_image/Juggernaut.png")
if news:
mnf_news=Member_News(user=to_email,title=news,service_name = "storytoscript",image_url = "/static/Notification_image/Juggernaut.png")
elif "Script Stall" in sheet_name:
if notification_title:
mnf_notification=Mnf_Notification(user=to_email,title=notification_title,service_name = "Script Stall",image_url = "/static/Notification_image/Juggernaut.png")
if news:
mnf_news=Member_News(user=to_email,title=news,service_name = "Script Stall",image_url = "/static/Notification_image/Juggernaut.png")
elif "referfriend" in sheet_name:
if notification_title:
mnf_notification=Mnf_Notification(user=to_email,title=notification_title,service_name = "referfriend",image_url = "/static/Notification_image/Juggernaut.png")
if news:
mnf_news=Member_News(user=to_email,title=news,service_name = "referfriend",image_url = "/static/Notification_image/Juggernaut.png")
# else:
# else:
# mnf_notification=Mnf_Notification(user=to_email,title=notification_title,service_name = sheet_name)
if mnf_notification:
mnf_notification.save()
print('notification sent')
if mnf_news:
mnf_news.save()
print('news sent')
return return
except Exception as error: except Exception as error:
print(error) print(error,"-------------------------ERROR")
import sys, os
exc_type, exc_obj, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
print(f"Exception type: {exc_type}, Function Name: {fname}, Line NO: {exc_tb.tb_lineno}")
auto_email_function_errors.objects.create(email = to_email,email_code=email_code,key_value=key_value,error=str(error)) auto_email_function_errors.objects.create(email = to_email,email_code=email_code,key_value=key_value,error=str(error))
pass pass
@ -249,9 +379,8 @@ def sendmail(to_email,email_code,key_value=None,filePath=None):
def mnf_notification(request,pk=None): def mnf_notification(request,pk=None):
if request.method == "GET": if request.method == "GET":
if pk is not None: if pk is not None:
main = Mnf_Notification.objects.all().filter(user=pk) main = Mnf_Notification.objects.all().filter(user=pk).order_by('-created')
if main: if main:
serializer = Mnf_NotificationSerializer(main,many=True) serializer = Mnf_NotificationSerializer(main,many=True)
return Response(serializer.data) return Response(serializer.data)
else: else:
@ -274,3 +403,32 @@ def mnf_notification(request,pk=None):
# main = MemberProfile.objects.filter(projectid=pk) # main = MemberProfile.objects.filter(projectid=pk)
main.delete() main.delete()
return Response("data deleted") return Response("data deleted")
@api_view(["GET"])
@authentication_classes([JWTAuthentication])
@permission_classes([IsAuthenticated])
def getNews(request,pk=None):
if request.method == "GET":
if pk is not None:
if centralDatabase.objects.filter(user_id=pk).exists():
target_user = centralDatabase.objects.get(user_id=pk)
main = Member_News.objects.all().filter(user=target_user.email).order_by('-created')
if main:
serializer = Member_NewsSerializer(main,many=True)
return Response(serializer.data)
else:
return Response([])
# if centralDatabase.objects.filter(user_id=pk).exists():
# target_user = centralDatabase.objects.get(user_id=pk)
# main = Member_News.objects.all().filter(user=target_user.email).order_by('-created')
# if main:
# serializer = Member_News(main,many=True,context={'replacement_name': target_user.firstName})
# return Response(serializer.data)
# else:
# return Response([])
# else:
# return Response({"msg":"user not found"})