Conversion_Kitchen_Code/kitchen_counter/lpp/views_working.py

874 lines
31 KiB
Python
Executable File

from users.models import ReferUser
from django.shortcuts import redirect
from django.shortcuts import render
from pathlib import Path
from django.contrib.auth.models import User
from django.core.files.storage import FileSystemStorage
import os
import simplejson as json
from django.conf import settings
from django.shortcuts import render
from django.http import HttpResponse
from django.urls import reverse
import os
from django.utils.dateparse import parse_date
from django.contrib.auth.decorators import login_required
from datetime import datetime
from datetime import date
from django.contrib import messages
from .LPP.selected_or_not_selected import selected_or_not_selected
from .models import MNFLPPDDatabase, LPPTASKDatabase
from django.core.mail import EmailMessage
from django.conf import settings
from users.models import ReferUser
from subtitling.views import lppupload
country_list = {
"AD": "Andorra",
"AE": "United Arab Emirates",
"AF": "Afghanistan",
"AG": "Antigua & Barbuda",
"AI": "Anguilla",
"AL": "Albania",
"AM": "Armenia",
"AN": "Netherlands Antilles",
"AO": "Angola",
"AQ": "Antarctica",
"AR": "Argentina",
"AS": "American Samoa",
"AT": "Austria",
"AU": "Australia",
"AW": "Aruba",
"AZ": "Azerbaijan",
"BA": "Bosnia and Herzegovina",
"BB": "Barbados",
"BD": "Bangladesh",
"BE": "Belgium",
"BF": "Burkina Faso",
"BG": "Bulgaria",
"BH": "Bahrain",
"BI": "Burundi",
"BJ": "Benin",
"BM": "Bermuda",
"BN": "Brunei Darussalam",
"BO": "Bolivia",
"BR": "Brazil",
"BS": "Bahama",
"BT": "Bhutan",
"BU": "Burma (no longer exists)",
"BV": "Bouvet Island",
"BW": "Botswana",
"BY": "Belarus",
"BZ": "Belize",
"CA": "Canada",
"CC": "Cocos (Keeling) Islands",
"CF": "Central African Republic",
"CG": "Congo",
"CH": "Switzerland",
"CI": "Côte D'ivoire (Ivory Coast)",
"CK": "Cook Iislands",
"CL": "Chile",
"CM": "Cameroon",
"CN": "China",
"CO": "Colombia",
"CR": "Costa Rica",
"CS": "Czechoslovakia (no longer exists)",
"CU": "Cuba",
"CV": "Cape Verde",
"CX": "Christmas Island",
"CY": "Cyprus",
"CZ": "Czech Republic",
"DD": "German Democratic Republic (no longer exists)",
"DE": "Germany",
"DJ": "Djibouti",
"DK": "Denmark",
"DM": "Dominica",
"DO": "Dominican Republic",
"DZ": "Algeria",
"EC": "Ecuador",
"EE": "Estonia",
"EG": "Egypt",
"EH": "Western Sahara",
"ER": "Eritrea",
"ES": "Spain",
"ET": "Ethiopia",
"FI": "Finland",
"FJ": "Fiji",
"FK": "Falkland Islands (Malvinas)",
"FM": "Micronesia",
"FO": "Faroe Islands",
"FR": "France",
"FX": "France, Metropolitan",
"GA": "Gabon",
"GB": "United Kingdom (Great Britain)",
"GD": "Grenada",
"GE": "Georgia",
"GF": "French Guiana",
"GH": "Ghana",
"GI": "Gibraltar",
"GL": "Greenland",
"GM": "Gambia",
"GN": "Guinea",
"GP": "Guadeloupe",
"GQ": "Equatorial Guinea",
"GR": "Greece",
"GS": "South Georgia and the South Sandwich Islands",
"GT": "Guatemala",
"GU": "Guam",
"GW": "Guinea-Bissau",
"GY": "Guyana",
"HK": "Hong Kong",
"HM": "Heard & McDonald Islands",
"HN": "Honduras",
"HR": "Croatia",
"HT": "Haiti",
"HU": "Hungary",
"ID": "Indonesia",
"IE": "Ireland",
"IL": "Israel",
"IN": "India",
"IO": "British Indian Ocean Territory",
"IQ": "Iraq",
"IR": "Islamic Republic of Iran",
"IS": "Iceland",
"IT": "Italy",
"JM": "Jamaica",
"JO": "Jordan",
"JP": "Japan",
"KE": "Kenya",
"KG": "Kyrgyzstan",
"KH": "Cambodia",
"KI": "Kiribati",
"KM": "Comoros",
"KN": "St. Kitts and Nevis",
"KP": "Korea, Democratic People's Republic of",
"KR": "Korea, Republic of",
"KW": "Kuwait",
"KY": "Cayman Islands",
"KZ": "Kazakhstan",
"LA": "Lao People's Democratic Republic",
"LB": "Lebanon",
"LC": "Saint Lucia",
"LI": "Liechtenstein",
"LK": "Sri Lanka",
"LR": "Liberia",
"LS": "Lesotho",
"LT": "Lithuania",
"LU": "Luxembourg",
"LV": "Latvia",
"LY": "Libyan Arab Jamahiriya",
"MA": "Morocco",
"MC": "Monaco",
"MD": "Moldova, Republic of",
"MG": "Madagascar",
"MH": "Marshall Islands",
"ML": "Mali",
"MN": "Mongolia",
"MM": "Myanmar",
"MO": "Macau",
"MP": "Northern Mariana Islands",
"MQ": "Martinique",
"MR": "Mauritania",
"MS": "Monserrat",
"MT": "Malta",
"MU": "Mauritius",
"MV": "Maldives",
"MW": "Malawi",
"MX": "Mexico",
"MY": "Malaysia",
"MZ": "Mozambique",
"NA": "Namibia",
"NC": "New Caledonia",
"NE": "Niger",
"NF": "Norfolk Island",
"NG": "Nigeria",
"NI": "Nicaragua",
"NL": "Netherlands",
"NO": "Norway",
"NP": "Nepal",
"NR": "Nauru",
"NT": "Neutral Zone (no longer exists)",
"NU": "Niue",
"NZ": "New Zealand",
"OM": "Oman",
"PA": "Panama",
"PE": "Peru",
"PF": "French Polynesia",
"PG": "Papua New Guinea",
"PH": "Philippines",
"PK": "Pakistan",
"PL": "Poland",
"PM": "St. Pierre & Miquelon",
"PN": "Pitcairn",
"PR": "Puerto Rico",
"PT": "Portugal",
"PW": "Palau",
"PY": "Paraguay",
"QA": "Qatar",
"RE": "Réunion",
"RO": "Romania",
"RU": "Russian Federation",
"RW": "Rwanda",
"SA": "Saudi Arabia",
"SB": "Solomon Islands",
"SC": "Seychelles",
"SD": "Sudan",
"SE": "Sweden",
"SG": "Singapore",
"SH": "St. Helena",
"SI": "Slovenia",
"SJ": "Svalbard & Jan Mayen Islands",
"SK": "Slovakia",
"SL": "Sierra Leone",
"SM": "San Marino",
"SN": "Senegal",
"SO": "Somalia",
"SR": "Suriname",
"ST": "Sao Tome & Principe",
"SU": "Union of Soviet Socialist Republics (no longer exists)",
"SV": "El Salvador",
"SY": "Syrian Arab Republic",
"SZ": "Swaziland",
"TC": "Turks & Caicos Islands",
"TD": "Chad",
"TF": "French Southern Territories",
"TG": "Togo",
"TH": "Thailand",
"TJ": "Tajikistan",
"TK": "Tokelau",
"TM": "Turkmenistan",
"TN": "Tunisia",
"TO": "Tonga",
"TP": "East Timor",
"TR": "Turkey",
"TT": "Trinidad & Tobago",
"TV": "Tuvalu",
"TW": "Taiwan, Province of China",
"TZ": "Tanzania, United Republic of",
"UA": "Ukraine",
"UG": "Uganda",
"UM": "United States Minor Outlying Islands",
"US": "United States of America",
"UY": "Uruguay",
"UZ": "Uzbekistan",
"VA": "Vatican City State (Holy See)",
"VC": "St. Vincent & the Grenadines",
"VE": "Venezuela",
"VG": "British Virgin Islands",
"VI": "United States Virgin Islands",
"VN": "Viet Nam",
"VU": "Vanuatu",
"WF": "Wallis & Futuna Islands",
"WS": "Samoa",
"YD": "Democratic Yemen (no longer exists)",
"YE": "Yemen",
"YT": "Mayotte",
"YU": "Yugoslavia",
"ZA": "South Africa",
"ZM": "Zambia",
"ZR": "Zaire",
"ZW": "Zimbabwe",
"ZZ": "Unknown or unspecified country",
}
def MNFLPP(request):
if MNFLPPDDatabase.objects.filter(user_id=request.user).exists():
return render(request, "lpp/alreadyRegister.html", {})
if request.method == "POST":
x = MNFLPPDDatabase()
x.user_id = request.user
x.countryCode = request.POST.get("code")
x.contact = request.POST.get("number")
x.country = country_list[str(request.POST.get("country")).upper()]
x.province = request.POST.get("state")
x.city = request.POST.get("city")
x.firstLanguage = request.POST.get("firstLanguage")
x.firstLangMedium = request.POST.get("mediumOfInstructionL1")
x.firstLangReason = request.POST.get("firstLangReason")
x.secondLanguage = request.POST.get("secondLanguage")
x.secondLangReason = request.POST.get("secondLangReason")
x.secondLangMedium = request.POST.get("mediumOfInstructionL2")
x.motherTongue = request.POST.get("motherTongue")
x.firstLangDegree = request.POST.get("firstLangDegree")
x.secondLangDegree = request.POST.get("secondLangDegree")
x.isCertification = "Yes"
x.firstLangAwardedBy = request.POST.get("firstLangAwardedBy")
x.secondLangAwardedBy = request.POST.get("secondLangAwardedBy")
x.certificationL1L2 = request.POST.get("certificationL1L2")
x.certttificationAwardedByL1L2 = request.POST.get(
"certttificationAwardedByL1L2"
)
x.durationCertificationL1L2 = request.POST.get("durationCertificationL1L2")
x.modeCertificationL1L2 = request.POST.get("modeCertificationL1L2")
x.firstLangDegreeFile = request.FILES["firstLangDegreeFile"]
x.secondLangDegreeFile = request.FILES["secondLangDegreeFile"]
x.scriptWrittenFirstLang = request.POST.get("scriptWrittenFirstLang")
x.noScriptTransFromL1toL2 = request.POST.get("noScriptTransFromL1toL2")
x.noArticleTransFromL1toL2 = request.POST.get("noArticleTransFromL1toL2")
x.scriptWrittenSecondLang = request.POST.get("scriptWrittenSecondLang")
x.noScriptTransFromL2toL1 = request.POST.get("noScriptTransFromL2toL1")
x.noArticleTransFromL2toL1 = request.POST.get("noArticleTransFromL2toL1")
x.fathersMotherTongue = request.POST.get("fathersMotherToungue")
x.mothersMotherTongue = request.POST.get("mothersMotherToungue")
x.certificationFile = request.FILES["certificationFile"]
x.noScriptTransFromL2toL1 = request.POST.get("noScriptTransFromL2toL1")
x.noScriptTransFromL2toL1Link = request.POST.get("noScriptTransFromL2toL1Link")
x.noArticleTransFromL1toL2Link = request.POST.get(
"noArticleTransFromL1toL2Link"
)
x.noArticleTransFromL2toL1Link = request.POST.get(
"noArticleTransFromL2toL1Link"
)
x.expFirstLang = request.POST.get("expFirstLang")
x.expSecondLang = request.POST.get("expSecondLang")
x.noScriptTransFromL1toL2Link = request.POST.get("noScriptTransFromL1toL2Link")
result, score = selected_or_not_selected(
x.province,
x.motherTongue,
x.fathersMotherTongue,
x.mothersMotherTongue,
x.firstLanguage,
x.firstLangReason,
x.firstLangMedium,
x.secondLanguage,
x.secondLangReason,
x.secondLangMedium,
x.firstLangDegree,
x.secondLangDegree,
x.isCertification,
x.expFirstLang,
x.expSecondLang,
x.scriptWrittenFirstLang,
x.noScriptTransFromL1toL2,
x.noArticleTransFromL1toL2,
x.scriptWrittenSecondLang,
x.noScriptTransFromL2toL1,
x.noArticleTransFromL2toL1,
)
x.score = score
if (
MNFLPPDDatabase.objects.filter(firstLanguage=x.firstLanguage)
.filter(secondLanguage=x.secondLanguage)
.exists()
):
print(x.firstLanguage, x.secondLanguage)
var1 = MNFLPPDDatabase.objects.filter(firstLanguage=x.firstLanguage).filter(
secondLanguage=x.secondLanguage
)
l1 = []
for i in var1:
l1.append(i.score)
minVal = min(l1)
print(var1)
# var2=var1.filter(score < score)
# print(var2)
if x.score <= minVal:
x.status = "Rejected"
else:
x.status = "Shortlisted by Algo"
else:
x.status = "Shortlisted by Algo"
x.save()
print(x.firstLanguage)
print(x.secondLanguage)
email_message = EmailMessage(
"LPP Registration Successful",
"Hi "
+ str(request.user.first_name)
+ " "
+ str(request.user.last_name)
+ ",\nYou have successfully registered for our Language Pair Partner programme.\nYour application is under review and your LPP application status will be sent to you via email it will reflected on your MNF profile too."
+ "\n\nHappy Filming\nMyNextFilm",
settings.EMAIL_HOST_USER,
[request.user.email],
)
email_message.send()
return HttpResponse(
"Thanks your application has successfully registered, we will notify you via email about your application status."
)
# z = xyz()
# print(z)
return render(request, "lpp/lppreg.html", {})
return render(request, "lpp/lppreg.html", {})
def agreement(request):
return render(request, "lpp/agreement.html", {})
def beALpp(request):
return render(request, "lpp/joinlpp.html", {})
def NDA(request):
return render(request, "lpp/NDA.html", {})
def Table1(request):
x = MNFLPPDDatabase.objects.all()
context = {"data": x}
return render(request, "lpp/minortable.html", context)
def majorTable(request, id):
x = MNFLPPDDatabase.objects.get(id=id)
context = {"data": x}
return render(request, "lpp/majortable.html", context)
def lppdelete(request, id):
x = MNFLPPDDatabase.objects.get(id=id).delete()
return redirect("/lpp/adminpanel/")
def Update(request):
if request.method == "POST":
pk = request.POST["lppid"]
if request.POST["status"] == "Shortlist":
if MNFLPPDDatabase.objects.filter(id=pk).exists():
x = MNFLPPDDatabase.objects.get(id=pk)
x.status = "Shortlisted"
x.save()
email_message = EmailMessage(
"LPP Application Status",
"Hi "
+ str(request.user.first_name)
+ " "
+ str(request.user.last_name)
+ ",\nYour Language Pair Partner application has been reviwed and we found you can join us. \nFor the next step you have to read and sign the NDA and upload it by going on LPP Dashboard."
+ "\nHappy Filming\nMyNextFilm",
settings.EMAIL_HOST_USER,
[request.user.email],
)
email_message
return redirect("/lpp/adminpanel/")
if request.POST["status"] == "Select":
if MNFLPPDDatabase.objects.filter(id=pk).exists():
x = MNFLPPDDatabase.objects.get(id=pk)
x.status = "Selected"
x.save()
email_message = EmailMessage(
"LPP Application Selected",
"Hi "
+ str(request.user.first_name)
+ " "
+ str(request.user.last_name)
+ ",\nCongratulation! You are selected as Language Pair Partner(LPP) in final selection. \nNow you can find you assigned task on you LPP Dashboard."
+ "\nHappy Filming\nMyNextFilm",
settings.EMAIL_HOST_USER,
[request.user.email],
)
email_message.send()
return redirect("/lpp/adminpanel/")
if request.POST["status"] == "Reject":
if MNFLPPDDatabase.objects.filter(id=pk).exists():
x = MNFLPPDDatabase.objects.get(id=pk)
x.status = "Rejected"
x.save()
email_message = EmailMessage(
"LPP Application Rejected",
"Hi "
+ str(request.user.first_name)
+ " "
+ str(request.user.last_name)
+ ",\nThank you for your application for Language Pair Partner.We really appreciate your interest in joining our company and we want to thank you for the time and energy you invested in your application.\nWe really appreciate your interest in joining My Next Film."
+ "\nAfter reviewing your application, we have to inform you that this time we won't be able to offer you to join you as LPP.\nWe wish you all the best in your career.\n Happy Filming\nMyNextFilm",
settings.EMAIL_HOST_USER,
[request.user.email],
)
email_message.send()
return redirect("/lpp/adminpanel/")
if request.POST["status"] == "Terminate":
if MNFLPPDDatabase.objects.filter(id=pk).exists():
x = MNFLPPDDatabase.objects.get(id=pk)
x.status = "Terminated"
x.save()
email_message = EmailMessage(
"LPP Termination",
"Hi "
+ str(request.user.first_name)
+ " "
+ str(request.user.last_name)
+ "\nWe are terminating you as our Language Pair Partner"
"\nThis termination is a temporialy block you won't be getting any task till we look into matter.\n Happy Filming\nMyNextFilm",
settings.EMAIL_HOST_USER,
[request.user.email],
)
email_message.send()
return redirect("/lpp/adminpanel/")
if request.POST["status"] == "Promote":
if MNFLPPDDatabase.objects.filter(id=pk).exists():
x = MNFLPPDDatabase.objects.get(id=pk)
if x.level == "Beginner":
x.level = "Proficient"
elif x.level == "Proficient":
x.level = "Expert"
elif x.level == "Expert":
x.level = "Expert"
else:
x.level = "Beginner"
x.save()
email_message = EmailMessage(
"LPP Rejected",
"Hi "
+ str(request.user.first_name)
+ " "
+ str(request.user.last_name)
+ "\nCongratulations you have been promoted to "
+ str(x.level)
+ "on the basis of feedbacks your completed assignment. We are happy to have you with us.\nHappy Filming \nMyNextFilm.",
settings.EMAIL_HOST_USER,
[request.user.email],
)
email_message.send()
return redirect("/lpp/adminpanel/")
def task_assigner(request):
if request.method == "POST":
eligiblelpp = []
X = LPPTASKDatabase()
X.user_id = request.user
X.taskname = request.FILES["UploadScreenPlay"]
X.firstLanguage = request.POST.get("SourceLanguage")
X.secondLanguage = request.POST.get("TargetLanguage")
X.usernote = request.POST.get("UserNote")
X.save()
if (
MNFLPPDDatabase.objects.filter(firstLanguage=X.firstLanguage)
.filter(secondLanguage=X.secondLanguage)
.exists()
):
LanguagePair = MNFLPPDDatabase.objects.filter(
firstLanguage=X.firstLanguage
).filter(secondLanguage=X.secondLanguage)
ExpertRating = {}
ProficientRating = {}
BeginnerRating = {}
Expertcount = 0
Proficientcount = 0
Beginnercount = 0
for i in LanguagePair:
if i.level == "Expert":
ExpertRating[i.id] = i.rating
Expertcount += 1
elif i.level == "Proficient":
ProficientRating[i.id] = i.rating
Proficientcount += 1
elif i.level == "Beginner":
BeginnerRating[i.id] = i.rating
Beginnercount += 1
if Expertcount > 0:
Keymax = max(ExpertRating, key=ExpertRating.get)
# print(Keymax)
X.assignedlpp = Keymax
for x in ExpertRating:
if x != Keymax:
eligiblelpp.append(x)
for x in ProficientRating:
if x != Keymax:
eligiblelpp.append(x)
for x in BeginnerRating:
if x != Keymax:
eligiblelpp.append(x)
# print(eligiblelpp)
# Str = eligiblelpp[0]
# for i in eligiblelpp(1, len(eligiblelpp)):
# Str = Str + f',{i}'
# print(Str)
X.eligiblelpp = eligiblelpp
X.save()
return HttpResponse("This is Rendered")
elif Proficientcount > 0:
Keymax = max(ProficientRating, key=ProficientRating.get)
X.assignedlpp = Keymax
for x in ProficientRating:
if x != Keymax:
eligiblelpp.append(x)
for x in BeginnerRating:
if x != Keymax:
eligiblelpp.append(x)
X.eligiblelpp = eligiblelpp
X.save()
return HttpResponse("Rendered")
else:
Keymax = max(BeginnerRating, key=BeginnerRating.get)
X.assignedlpp = Keymax
for x in BeginnerRating:
if x != Keymax:
eligiblelpp.append(x)
X.eligiblelpp = eligiblelpp
X.save()
return HttpResponse(
f"Your script {X.taskname} has been sent to our language pair partner"
)
else:
return HttpResponse(
f"No LPP found for {X.firstLanguage}, {X.secondLanguage} pair"
)
X.save()
return HttpResponse(f"Rendered")
return render(request, "lpp/vetting.html", {})
def vetting(request):
return render(request, "lpp/vetting.html")
# def lpptask_dashboard(request):
# x = LPPTASKDatabase.objects.all()
# for i in x:
# Y = MNFLPPDDatabase.objects.get(user_id=i.assignedlpp)
# print(Y)
# temp = i.assignedlpp
# P = Y.user_id
# if request.user == P:
# context = {"data": x, "Data1": Y}
# return render(request, "lpp/lpptask_dashboard.html", context)
# else:
# context = {"Data1": Y}
# return render(request, "lpp/lpptask_dashboard.html", context)
# return render(request, "lpp/lpptask_dashboard.html")
def lpptask_dashboard(request):
# x = LPPTASKDatabase.objects.all()
if MNFLPPDDatabase.objects.filter(user_id=request.user).exists():
Y = MNFLPPDDatabase.objects.filter(user_id=request.user)[0]
else:
print("You are not a LPP")
context = {"data": [], "Data1": []}
return render(request, "lpp/lpptask_dashboard.html", context)
num_of_tasks = LPPTASKDatabase.objects.filter(assignedlpp=Y.id).count()
if num_of_tasks > 0:
x = LPPTASKDatabase.objects.filter(assignedlpp=Y.id)
else:
x = []
print("No task is assigned")
# print("$" * 50)
# print("This is the LPP Task Table for user: ", request.user)
# print(x)
# print("This is the LPP Database entry: ", request.user)
# print(Y)
# print("*" * 50)
# # Y = MNFLPPDDatabase.objects.get(user_id=i.assignedlpp)
# # Y = MNFLPPDDatabase.objects.filter(user_id=i.assignedlpp)
# Y = MNFLPPDDatabase.objects.filter(user_id=i.assignedlpp)
# print(Y)
# temp = i.assignedlpp
# P = Y.user_id
# # if request.user == P:
# if request.user.user_id == P:
context = {"data": x, "Data1": Y}
return render(request, "lpp/lpptask_dashboard.html", context)
def updatebankdetails(request):
if request.method == "POST":
pk = request.POST["id"]
x = MNFLPPDDatabase.objects.get(id=pk)
x.accountno = request.POST.get("accountno")
x.ifsccode = request.POST.get("ifsccode")
x.nameofaccount = request.POST.get("nameofaccount")
x.save()
return redirect("lpptask_dashboard")
def availabity(request):
if request.method == "POST":
pk = request.POST["id"]
x = MNFLPPDDatabase.objects.get(id=pk)
x.availabity = request.POST.get("availabity")
x.save()
return redirect("lpptask_dashboard")
def NonDisclosureAgreement(request):
if request.method == "POST":
pk = request.POST["id"]
x = MNFLPPDDatabase.objects.get(id=pk)
print(x)
x.nda = request.FILES["nda"]
x.save()
return redirect("lpptask_dashboard")
def vetted_task(request):
if LPPTASKDatabase.objects.filter(user_id=request.user.id).exists():
y = LPPTASKDatabase.objects.filter(user_id=request.user.id)
context = {"data": y}
return render(request, "lpp/vetted_task.html", context)
else:
return HttpResponse("Your have not placed any order for vetting")
# def completed_task(request):
# if LPPTASKDatabase.objects.filter(user_id=request.user).exists():
# y = LPPTASKDatabase.objects.filter(user_id = request.user)
# context = {
# 'data': y
# }
# return render(request, 'lpp/completed_task.html', context)
# else:
# return HttpResponse("You have no completed tasks!!")
Declined_ID = []
Declined_Time = []
count = []
CompletionTime = []
def LPPAction(request):
if request.method == "POST":
pk = request.POST.get("id")
print("This is id: ", pk)
if request.POST["actiontype"] == "Accept":
count = LPPTASKDatabase.objects.filter(id=pk).count()
print("This is the count:", count)
if LPPTASKDatabase.objects.filter(id=pk).exists():
x = LPPTASKDatabase.objects.get(id=pk)
if request.FILES.get("convertedfile"):
email_message = EmailMessage(
"Update on your translation request",
"Hi "
+ str(request.user.first_name)
+ " "
+ str(request.user.last_name)
+ ",\nYour Conversion "
+ str(x.taskname)
+ " for traslation from "
+ str(x.firstLanguage)
+ " to "
+ str(x.secondLanguage)
+ " is converted by our language pair partner",
settings.EMAIL_HOST_USER,
[x.user_id.email],
)
email_message.send()
print("Ye bhi send ho gya hai")
Date = datetime.today()
dt_string = Date.strftime("%d/%m/%Y %H:%M:%S")
CompletionTime.append(dt_string)
x.completiontime = CompletionTime
# x.status = "InProgress"
x.status = "Completed"
x.ratingonmachinetranslation = request.POST.get(
"ratingonmachinetranslation"
)
x.mistakeperpage = request.POST.get("mistakes")
# if request.POST['getfile'] == 'yes':
x.outputfile = request.FILES["convertedfile"]
x.save()
else:
email_message = EmailMessage(
"Update on your translation request",
"Hi "
+ str(request.user.first_name)
+ " "
+ str(request.user.last_name)
+ ",\nYour Conversion"
+ str(x.taskname)
+ " is being vetted by our language pair expert",
settings.EMAIL_HOST_USER,
[x.user_id.email],
)
print("message send nhi ho rha!!!")
email_message.send()
print("Email sent")
x.status = "InProgress"
x.ratingonmachinetranslation = request.POST.get(
"ratingonmachinetranslation"
)
x.mistakeperpage = request.POST.get("mistakes")
x.save()
return redirect("/lpp/lpptask_dashboard/")
if request.POST["Action"] == "Decline":
if LPPTASKDatabase.objects.filter(id=pk).exists():
x = LPPTASKDatabase.objects.get(id=pk)
x.status = "NotAccepted"
Date = datetime.today()
dt_string = Date.strftime("%d/%m/%Y %H:%M:%S")
Declined_Time.append(dt_string)
x.declinereason = request.POST.get("Decline")
x.declinetime = Declined_Time
x.ratingonmachinetranslation = request.POST.get("rating")
x.mistakeperpage = request.POST.get("mistakes")
x.outputfile = request.FILES["convertedfile"]
x.save()
Declined_ID.append(x.assignedlpp)
Temp = x.eligiblelpp[1:-1]
Temp = Temp.replace(",", "")
Temp = Temp.split(" ")
print(len(Temp))
if len(count) == 0:
x.assignedlpp = Temp[0]
x.declinedby = Declined_ID
x.eligiblelpp = Temp
x.save()
Temp.remove(Temp[0])
if len(Temp) == 0:
count.append(1)
else:
print("THis is kartik")
email_message = EmailMessage(
"Update on your translation request",
"Hi "
+ str(request.user.first_name)
+ " "
+ str(request.user.last_name)
+ ",\nYour Conversion "
+ str(x.taskname)
+ " is being declined by our language pair expert and there is no more lpp for this language",
settings.EMAIL_HOST_USER,
[x.user_id],
)
email_message.send()
print("Email sent")
return HttpResponse(
"You declined the task, so you have no assign task!"
)
# x.ratingonmachinetranslation = request.POST.get('rating')
# x.mistakeperpage = request.POST.get('mistakes')
# x.outputfile = request.FILES['convertedfile']
x.save()
return redirect("/lpp/lpptask_dashboard/")
# if request.POST["Action"] == "Cancel":
# if LPPTASKDatabase.objects.filter(id=pk).exists():
# x = LPPTASKDatabase.objects.get(id=pk)
# x.status = 'Canceled'
# x.save()
# email_message = EmailMessage(
# "Update on your translation request",
# "Hi "+str(x.user.first_name)+' '+str(x.user.last_name) +
# ",\nYour Conversion"+str(x.taskname)+" is being vetted by our language pair expert",
# settings.EMAIL_HOST_USER,
# [x.user.email]
# )
# email_message
# return redirect('/lpp/adminpanel/')
return redirect("/lpp/lpptask_dashboard/")