fixed crud list

fixed payments
upload -a
This commit is contained in:
2025-07-23 11:08:25 +03:00
parent a4a91e0053
commit 4603953458
53 changed files with 1512 additions and 1078 deletions
+47 -1
View File
@@ -1,5 +1,12 @@
import re
from django.template.loader import render_to_string
from django.utils.html import strip_tags
from containers.models import Container
from preinfo.models import Preinfo
from django.conf import settings
from django.core.mail import send_mail, EmailMessage
def filter_queryset_by_user(queryset, user):
@@ -40,4 +47,43 @@ def get_container_by_number(number):
try:
return Container.objects.get(number=number, expedited=False)
except Container.DoesNotExist:
return None
return None
CALC_STRING = "0123456789A.BCDEFGHIJK.LMNOPQRSTU.VWXYZ"
def check_container_number_validity(container_number):
if not re.search(r"[A-Z]{4}[0-9]{7}", container_number):
return False
subtotal = 0
delta = 1
for i in range(0, 10):
subtotal = subtotal + CALC_STRING.find(container_number[i]) * delta
delta = delta * 2
subtotal = (subtotal % 11) % 10
if not subtotal == CALC_STRING.find(container_number[10]):
return False
return True
ADMIN_USER_EMAIL= settings.ADMIN_USER_EMAIL
EMAIL_HOST_USER = settings.EMAIL_HOST_USER
def send_test_email(user_email, urls):
subject='Welcome to Our Platform'
html_message = render_to_string('email.html', {
'site_name': 'Our Platform',
'user_email': user_email,
'link1': urls['pay_epay'],
'link2': urls['pay_credit_card'],
})
plain_message = strip_tags(html_message)
email = EmailMessage(
subject=subject,
body=html_message,
from_email=EMAIL_HOST_USER,
to=[user_email],
)
email.content_subtype = 'html' # This tells Django to send HTML email
email.send()