Update barcode.py

This commit is contained in:
zainab2097 2024-07-31 17:14:52 +03:00 committed by GitHub
parent 63e54d7d76
commit 7fa9e09ca3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 10 deletions

View File

@ -43,13 +43,6 @@ class Transaction(models.Model):
img = Image.new("RGBA", (500, 420), "white")
draw = ImageDraw.Draw(img)
font = ImageFont.truetype(font_path, font_size)
transaction_text = " رقم المعاملة : " + (self.name or '')
subject_text = " موضوع : " + (self.subject or '')
h_date =" تاريخ المعاملة الهجري : " +(str(self.transaction_date) if self.transaction_date else '')
datem = " تاريخ المعاملة الميلادي : "+ (str(self.transaction_date) if self.transaction_date else '')
rank = " رتبة المعاملة : "+(str(self.attachment_num) if self.attachment_num else '0')
full_text = transaction_text + "\n" + subject_text.center(100)+"\n"+h_date+'\n'+datem+'\n'+rank.center(60)
def draw_text(draw, text, position, font, alignment="left"):
text_size = draw.textsize(text, font=font)
@ -61,9 +54,10 @@ class Transaction(models.Model):
draw.text(position, text, "black", font=font)
draw_text(draw, full_text, (10, 20), font)
draw_text(draw, " رقم المعاملة : " + (self.name or ''), (10, 20), font)
draw_text(draw, " تاريخ المعاملة الهجري : " + (self.transaction_date_hijri or '').replace('-', '/'), (10, 60), font)
draw_text(draw, " تاريخ المعاملة الميلادي : " + (str(self.transaction_date) if self.transaction_date else '').replace('-', '/'), (10, 100), font)
draw_text(draw, " الموضوع : " + (str(self.subject) if self.subject else ''), (120, 140), font)
# Generate barcode