def make_qrcode(self, name):
# Create the QR code
if self.mother:
if self.mother.name.lastname:
newborn_mother_lastname = self.mother.name.lastname + ', '
else:
newborn_mother_lastname = ''
newborn_mother_name = self.mother.name.name or ''
newborn_mother_id = self.mother.puid or ''
else:
newborn_mother_lastname = ''
newborn_mother_name = ''
newborn_mother_id = ''
newborn_name = self.name or ''
newborn_sex = self.sex or ''
newborn_birth_date = self.birth_date or ''
qr_string = 'PUID: ' + newborn_name \
+ '\nMother: ' + newborn_mother_lastname \
+ newborn_mother_name \
+ '\nMother\'s PUID: ' + newborn_mother_id \
+ '\nSex: ' + newborn_sex \
+ '\nDoB: ' + str(newborn_birth_date)
qr_image = qrcode.make(qr_string)
# Make a PNG image from PIL without the need to create a temp file
holder = StringIO.StringIO()
qr_image.save(holder)
qr_png = holder.getvalue()
holder.close()
return bytearray(qr_png)
评论列表
文章目录