cineclub-site/server/myapi/services/com_service.py

29 lines
759 B
Python
Raw Normal View History

2022-04-03 01:20:54 +02:00
from django.template import Template, Context
2022-04-03 01:20:54 +02:00
from django.template.loader import render_to_string
from myapi.models import Film
2022-04-03 01:20:54 +02:00
prices = {"one_cof": 4, "one_exte": 5, "card_cof": 30, "card_exte": 35}
2022-04-03 01:20:54 +02:00
def render_com(template_name, film: Film) -> str:
2022-04-03 01:20:54 +02:00
return render_to_string(template_name, {"film": film, "prices": prices}).strip()
2022-04-03 01:20:54 +02:00
def bocal(film: Film) -> str:
2022-04-03 01:20:54 +02:00
return render_com("bocal.tex", film)
2022-04-03 01:20:54 +02:00
def facebook_text(film: Film) -> str:
return render_com("facebook.txt", film)
2022-04-03 01:20:54 +02:00
def facebook_title(film: Film) -> str:
template = Template("{{ film.title }} - {{ film.director }}")
ctx = Context({"film": film, "prices": prices})
return template.render(ctx)
def mail(film: Film) -> str:
return render_com("mail.html", film)