рендерить на картинке с грамотой имя ученика перед отправкой

remotes/origin/feature/signed-user-cert-20-03-19
gzbender 7 years ago
parent 05bb6838ec
commit cd8783b832
  1. 11
      apps/notification/tasks.py
  2. BIN
      web/src/img/signed-user-certificates/1.jpg
  3. BIN
      web/src/img/signed-user-certificates/2.jpg
  4. BIN
      web/src/img/signed-user-certificates/3.jpg
  5. BIN
      web/src/img/signed-user-certificates/4.jpg
  6. BIN
      web/src/img/signed-user-certificates/5.jpg
  7. BIN
      web/src/img/signed-user-certificates/6.jpg
  8. BIN
      web/src/img/signed-user-certificates/7.jpg
  9. BIN
      web/src/img/signed-user-certificates/8.jpg
  10. BIN
      web/src/img/signed-user-certificates/9.jpg
  11. BIN
      web/src/img/user-certificates/1.jpg
  12. BIN
      web/src/img/user-certificates/2.jpg
  13. BIN
      web/src/img/user-certificates/3.jpg
  14. BIN
      web/src/img/user-certificates/4.jpg
  15. BIN
      web/src/img/user-certificates/5.jpg
  16. BIN
      web/src/img/user-certificates/6.jpg
  17. BIN
      web/src/img/user-certificates/7.jpg
  18. BIN
      web/src/img/user-certificates/8.jpg
  19. BIN
      web/src/img/user-certificates/9.jpg
  20. 9
      web/webpack.config.js

@ -25,9 +25,9 @@ def draw_cert(path, email, first_name, last_name):
img = Image.open(path)
draw = ImageDraw.Draw(img)
font = ImageFont.truetype(os.path.join(settings.STATIC_ROOT, 'ProximaNova-Reg.otf'), 170)
text = first_name
text = first_name.capitalize()
if last_name:
text += ' ' + last_name
text += ' ' + last_name.capitalize()
w, h = draw.textsize(text, font=font)
draw.text(((img.width - w) // 2, 900), text, (29, 115, 224), font=font)
fn = os.path.join(settings.MEDIA_ROOT, 'tmp')
@ -43,8 +43,9 @@ def draw_cert(path, email, first_name, last_name):
@app.task
def send_certificates(email=None, date=None, dry_run=False):
path_pattern = 'img/user-certificates/%d.jpg'
signed_path_pattern = 'img/signed-user-certificates/%d.jpg'
if email:
fn = draw_cert(staticfiles_storage.path(path_pattern % 1), email, 'Имя', 'Фамилия')
fn = draw_cert(staticfiles_storage.path(signed_path_pattern % 1), email, 'Имя', 'Фамилия')
file = open(fn, 'rb')
try:
send_email('Грамота от Lil School', email, 'notification/email/certificate.html',
@ -77,9 +78,11 @@ def send_certificates(email=None, date=None, dry_run=False):
un.certificate_number = un.certificate_number + 1 \
if un.certificate_number and staticfiles_storage.exists(path_pattern % (un.certificate_number + 1)) \
else 1
fn = staticfiles_storage.path(path_pattern % un.certificate_number)
if un.user.child_first_name:
fn = staticfiles_storage.path(signed_path_pattern % un.certificate_number)
fn = draw_cert(fn, un.user.email, un.user.child_first_name, un.user.child_last_name)
else:
fn = staticfiles_storage.path(path_pattern % un.certificate_number)
file = open(fn, 'rb')
try:
send_email('Грамота от Lil School', un.user.email, 'notification/email/certificate.html',

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 941 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 MiB

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 941 KiB

After

Width:  |  Height:  |  Size: 1.2 MiB

@ -18,6 +18,7 @@ module.exports = {
sprite: glob('./src/icons/*.svg'),
images: glob('./src/img/*.*'),
imagesCertificates: glob('./src/img/user-certificates/*'),
imagesSignedCertificates: glob('./src/img/signed-user-certificates/*'),
imagesGiftCertificates: glob('./src/img/gift-certificates/*'),
imagesReviews: glob('./src/img/reviews/*'),
fonts: glob('./src/fonts/*'),
@ -90,7 +91,8 @@ module.exports = {
{
test: /\.(png|gif|jpg|svg)$/,
exclude: [path.resolve(__dirname, 'src/icons'), path.resolve(__dirname, 'src/img/user-certificates'),
path.resolve(__dirname, 'src/img/gift-certificates'), path.resolve(__dirname, 'src/img/reviews')],
path.resolve(__dirname, 'src/img/gift-certificates'), path.resolve(__dirname, 'src/img/reviews'),
path.resolve(__dirname, 'src/img/signed-user-certificates')],
loader: 'file-loader?name=[name].[ext]&outputPath=./img/'
},
{
@ -98,6 +100,11 @@ module.exports = {
include: path.resolve(__dirname, 'src/img/user-certificates'),
loader: 'file-loader?name=[name].[ext]&outputPath=./img/user-certificates/'
},
{
test: /\.(png|jpg)$/,
include: path.resolve(__dirname, 'src/img/signed-user-certificates'),
loader: 'file-loader?name=[name].[ext]&outputPath=./img/signed-user-certificates/'
},
{
test: /\.(png|jpg)$/,
include: path.resolve(__dirname, 'src/img/gift-certificates'),

Loading…
Cancel
Save