first commit

This commit is contained in:
2026-06-13 21:46:37 +03:00
commit 650b69a97d
131 changed files with 5951 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,24 @@
from dataclasses import dataclass
@dataclass
class DocumentsStatus:
NEW = 'new'
ANALISE = 'analise'
IN_PROGRESS = 'in_progress'
WAITING_FOR_PAYMENT = 'waiting_for_payment'
COMPLETED = 'completed'
CANCELED = 'canceld'
@staticmethod
def get_label(status):
mapping = {
DocumentsStatus.NEW: 'Nou',
DocumentsStatus.ANALISE: 'Analiza',
DocumentsStatus.IN_PROGRESS: 'In progres',
DocumentsStatus.WAITING_FOR_PAYMENT: 'Asteptam plata',
DocumentsStatus.COMPLETED: 'Complet',
DocumentsStatus.CANCELED: 'Anulat'
}
return mapping.get(status, status)

139
client/helpers/emails.py Normal file
View File

@@ -0,0 +1,139 @@
import smtplib
from email.message import EmailMessage
import os
def send_email(to_email, subject, body):
smtp_host = os.environ.get("SMTP_HOST")
smtp_port = int(os.environ.get("SMTP_PORT", 587))
smtp_user = os.environ.get("SMTP_USER")
smtp_pass = os.environ.get("SMTP_PASS")
sender_email = os.environ.get("SMTP_FROM", smtp_user)
if not all([smtp_host, smtp_port, smtp_user, smtp_pass]):
raise ValueError("SMTP config incomplete in environment variables.")
msg = EmailMessage()
msg["Subject"] = subject
msg["From"] = sender_email
msg["To"] = to_email
msg.set_content(body)
with smtplib.SMTP(smtp_host, smtp_port) as server:
server.starttls()
server.login(smtp_user, smtp_pass)
server.send_message(msg)
# Send email with attachment
def send_email_with_attachment(to_email, subject, body, attachment_path):
smtp_host = os.environ.get("SMTP_HOST")
smtp_port = int(os.environ.get("SMTP_PORT", 587))
smtp_user = os.environ.get("SMTP_USER")
smtp_pass = os.environ.get("SMTP_PASS")
sender_email = os.environ.get("SMTP_FROM", smtp_user)
if not all([smtp_host, smtp_port, smtp_user, smtp_pass]):
raise ValueError("SMTP config incomplete in environment variables.")
msg = EmailMessage()
msg["Subject"] = subject
msg["From"] = sender_email
msg["To"] = to_email
msg.set_content(body)
if attachment_path and os.path.isfile(attachment_path):
with open(attachment_path, "rb") as f:
file_data = f.read()
file_name = os.path.basename(attachment_path)
msg.add_attachment(file_data, maintype="application", subtype="pdf", filename=file_name)
else:
raise FileNotFoundError(f"Attachment file not found: {attachment_path}")
with smtplib.SMTP(smtp_host, smtp_port) as server:
server.starttls()
server.login(smtp_user, smtp_pass)
server.send_message(msg)
# Send email using Gmail directly
def send_gmail(to_email, subject, body):
smtp_host = "smtp.gmail.com"
smtp_port = 587
smtp_user = 'macamete.robert@gmail.com'
smtp_pass = 'advx yqlv jkaa czvr'
sender_email = 'macamete.robert@gmail.com'
if not all([smtp_user, smtp_pass]):
raise ValueError("GMAIL_USER and GMAIL_PASS must be set in environment variables.")
msg = EmailMessage()
msg["Subject"] = subject
msg["From"] = sender_email
msg["To"] = to_email
msg.set_content(body)
with smtplib.SMTP(smtp_host, smtp_port) as server:
server.starttls()
server.login(smtp_user, smtp_pass)
server.send_message(msg)
# Send email with attachment using Gmail directly
def send_gmail_with_attachment(to_email, subject, body, attachment_path):
smtp_host = "smtp.gmail.com"
smtp_port = 587
smtp_user = 'macamete.robert@gmail.com'
smtp_pass = 'advx yqlv jkaa czvr'
sender_email = 'macamete.robert@gmail.com'
if not all([smtp_user, smtp_pass]):
raise ValueError("GMAIL_USER and GMAIL_PASS must be set in environment variables.")
msg = EmailMessage()
msg["Subject"] = subject
msg["From"] = sender_email
msg["To"] = to_email
msg.set_content(body)
if attachment_path and os.path.isfile(attachment_path):
with open(attachment_path, "rb") as f:
file_data = f.read()
file_name = os.path.basename(attachment_path)
msg.add_attachment(file_data, maintype="application", subtype="pdf", filename=file_name)
else:
raise FileNotFoundError(f"Attachment file not found: {attachment_path}")
with smtplib.SMTP(smtp_host, smtp_port) as server:
server.starttls()
server.login(smtp_user, smtp_pass)
server.send_message(msg)
# Send email with attachment
def send_custom_email_with_attachment(to_email, subject, body, attachment_path, SMTP_HOST, SMTP_PORT, SMTP_USER, SMTP_PASS):
smtp_host = SMTP_HOST
smtp_port = int(SMTP_PORT)
smtp_user = SMTP_USER
smtp_pass = SMTP_PASS
sender_email = smtp_user
if not all([smtp_host, smtp_port, smtp_user, smtp_pass]):
raise ValueError("SMTP config incomplete in environment variables.")
msg = EmailMessage()
msg["Subject"] = subject
msg["From"] = sender_email
msg["To"] = to_email
msg.set_content(body)
if attachment_path and os.path.isfile(attachment_path):
with open(attachment_path, "rb") as f:
file_data = f.read()
file_name = os.path.basename(attachment_path)
msg.add_attachment(file_data, maintype="application", subtype="pdf", filename=file_name)
else:
raise FileNotFoundError(f"Attachment file not found: {attachment_path}")
with smtplib.SMTP(smtp_host, smtp_port) as server:
server.starttls()
server.login(smtp_user, smtp_pass)
server.send_message(msg)

View File

@@ -0,0 +1,6 @@
from dataclasses import dataclass
@dataclass
class PaymentType:
ONE_TIME_ONLY = 'o singura data'
SUBSCRIPTION = 'abonament'

25
client/helpers/roles.py Normal file
View File

@@ -0,0 +1,25 @@
from dataclasses import dataclass
@dataclass
class Roles:
USER = "user"
ADMIN = "admin"
PROPRIETAR = "proprietar"
CENZOR = "cenzor"
ADMINISTRATOR = "administrator"
PRESEDINTE = "presedinte"
EXPERT = "expert"
BA = "ba"
SUPER_USER = 'super_user'
@dataclass
class Priorities:
USER = "0"
PROPRIETAR = "1"
CENZOR = "2"
ADMINISTRATOR = "2"
PRESEDINTE = "2"
EXPERT = "3"
BA = "4"
SUPER_USER = "5"

View File

@@ -0,0 +1,66 @@
import re
class Validations:
def __init__(self, error_message, page):
self.page = page
self.error_message = error_message
def is_valid_email(self, email: str) -> bool:
email_regex = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
if re.fullmatch(email_regex, email) is not None:
self.error_message.value = ""
self.error_message.update()
return True
else:
self.error_message.value = "Va rugam inserati o adresa e email valida!"
self.error_message.update()
return False
def are_all_fields_inserted(self, email=None, password=None, repeat_password=None):
valid = True
self.error_message.value = ''
if not email:
valid = False
if not password:
valid = False
if not repeat_password:
valid = False
if not valid:
self.error_message.value = "Toate campurile sunt obligatorii!"
self.error_message.update()
return valid
def check_repeat_password(self, password, confirm_password):
if password == confirm_password:
self.error_message.value = ""
self.error_message.update()
return True
else:
self.error_message.value = "Parolele nu se potrivesc!"
self.error_message.update()
return False
def is_password_strong(self, password):
self.error_message.value = ""
if len(password) < 8:
self.error_message.value = "Parola trebuie sa aiba cel putin 8 caractere!"
self.error_message.update()
return False
if not re.search(r"[A-Z]", password):
self.error_message.value = "Parola trebuie sa contina cel putin o litera mare!"
self.error_message.update()
return False
if not re.search(r"[a-z]", password):
self.error_message.value = "Parola trebuie sa contina cel putin o litera mica!"
self.error_message.update()
return False
if not re.search(r"[0-9]", password):
self.error_message.value = "Parola trebuie sa contina cel putin o cifra!"
self.error_message.update()
return False
if not re.search(r"[^a-zA-Z0-9]", password):
self.error_message.value = "Parola trebuie sa contina cel putin un caracter special (de exemplu: !@#$%^&*)!"
self.error_message.update()
return False
self.error_message.update()
return True