コード例 #1
0
ファイル: models.py プロジェクト: oeegor/pong
 def send_stage_created_email(self):
     for group in self.groups.all().prefetch_related("participants"):
         mails = [p.email for p in group.participants.all()]
         template_name = "stage_has_been_created"
         try:
             send_templated_mail(
                 template_name=template_name,
                 context={"group": {"name": group.name, "table": group.get_table()}},
                 recipients=mails,
                 sender="*****@*****.**",
             )
         except NoTemplateError:
             logger.error("no template for {}".format(template_name), exc_info=True)
コード例 #2
0
ファイル: models.py プロジェクト: ekirill/pong
 def send_tournament_started_email(self):
     for group in self.groups.all().prefetch_related('participants'):
         mails = [p.email for p in group.participants.all()]
         send_templated_mail(
             template_name='tournament_has_started',
             context={
                 'group': {
                     'name': group.name,
                     'table': group.get_table()
                 }
             },
             recipients=mails,
             sender='*****@*****.**',
         )
コード例 #3
0
ファイル: models.py プロジェクト: oeegor/pong
    def send_tournament_ended_email(self):
        stage = self.stages.all().order_by("-pk").first()
        group = stage.groups.all().prefetch_related("participants").first()

        mails = [p.email for p in self.participants.all()]
        template_name = "tournament_has_ended"
        try:
            send_templated_mail(
                template_name=template_name,
                context={"group": {"name": group.name, "table": group.get_table()}},
                recipients=mails,
                sender="*****@*****.**",
            )
        except NoTemplateError:
            logger.error("no template for {}".format(template_name), exc_info=True)
コード例 #4
0
ファイル: models.py プロジェクト: ekirill/pong
    def send_approve_notification(self, sender_id):
        opponent = self.player1
        if self.player1.pk == sender_id:
            opponent = self.player2

        mails = [opponent.email]
        send_templated_mail(
            template_name='need_result_approve',
            context={
                'player1_name': self.player1.short_email,
                'player2_name': self.player2.short_email,
                'score': self.get_score(is_player1=True).score,
                'match_id': self.pk,
            },
            recipients=mails,
            sender='*****@*****.**',
        )
コード例 #5
0
ファイル: models.py プロジェクト: ekirill/pong
 def send_group_notification(self):
     mails = [p.email for p in self.group.participants.all()]
     group = self.group
     send_templated_mail(
         template_name='new_result_added',
         context={
             'player1_name': self.player1.short_email,
             'player2_name': self.player2.short_email,
             'score': self.get_score(is_player1=True).score,
             'group': {
                 'name': group.name,
                 'table': group.get_table()
             }
         },
         recipients=mails,
         sender='*****@*****.**',
     )
コード例 #6
0
ファイル: models.py プロジェクト: oeegor/pong
 def send_group_notification(self, approve_base_url):
     mails = [p.email for p in self.group.participants.all()]
     group = self.group
     template_name = "new_result_added"
     try:
         send_templated_mail(
             template_name=template_name,
             context={
                 "player1_name": self.player1.short_email,
                 "player2_name": self.player2.short_email,
                 "score": self.get_score(is_player1=True).score,
                 "group": {"name": group.name, "table": group.get_table()},
                 "approve_base_url": approve_base_url,
             },
             recipients=mails,
             sender="*****@*****.**",
         )
     except NoTemplateError:
         logger.error("no template for {}".format(template_name), exc_info=True)
コード例 #7
0
ファイル: models.py プロジェクト: oeegor/pong
    def send_approve_notification(self, sender_id):
        opponent = self.player1
        if self.player1.pk == sender_id:
            opponent = self.player2

        mails = [opponent.email]
        template_name = "need_result_approve"
        try:
            send_templated_mail(
                template_name="need_result_approve",
                context={
                    "player1_name": self.player1.short_email,
                    "player2_name": self.player2.short_email,
                    "score": self.get_score(is_player1=True).score,
                    "match_id": self.pk,
                },
                recipients=mails,
                sender=settings.EMAIL_HOST_USER,
            )
        except NoTemplateError:
            logger.error("no template for {}".format(template_name), exc_info=True)