Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

managers.py 609B

123456789101112131415161718
  1. from django.db import models
  2. class CommunicationTypeManager(models.Manager):
  3. def get_and_render(self, code, context):
  4. """
  5. Return a dictionary of rendered messages, ready for sending.
  6. This method wraps around whether an instance of this event-type exists
  7. in the database. If not, then an instance is created on the fly and
  8. used to generate the message contents.
  9. """
  10. try:
  11. commtype = self.get(code=code)
  12. except self.model.DoesNotExist:
  13. commtype = self.model(code=code)
  14. return commtype.get_messages(context)