コード例 #1
0
    def form_valid(self, form):
        self.form = form
        form.save()
        messages.success(self.request, _('The member was added, please edit additional details if applicable.'))
        form.instance.log(self, '.created')

        responses = new_member.send_robust(sender=form.instance)
        for module, response in responses:
            if isinstance(response, Exception):
                messages.warning(self.request, _('Some post processing steps could not be completed: ') + str(response))
        config = Configuration.get_solo()

        if config.welcome_member_template and form.instance.email:
            context = {
                'name': config.name,
                'contact': config.mail_from,
                'number': form.instance.number,
                'member_name': form.instance.name,
            }
            responses = [r[1] for r in new_member_mail_information.send_robust(sender=form.instance) if r]
            context['additional_information'] = '\n'.join(responses).strip()
            config.welcome_member_template.to_mail(email=form.instance.email, context=context)
        if config.welcome_office_template:
            context = {'member_name': form.instance.name}
            responses = [r[1] for r in new_member_office_mail_information.send_robust(sender=form.instance) if r]
            context['additional_information'] = '\n'.join(responses).strip()
            config.welcome_office_template.to_mail(email=config.backoffice_mail, context=context)
        return super().form_valid(form)
コード例 #2
0
ファイル: members.py プロジェクト: grince/byro
    def form_valid(self, form):
        self.form = form
        form.save()
        messages.success(
            self.request,
            _('The member was added, please edit additional details if applicable.'
              ))

        new_member.send_robust(sender=form.instance)
        config = Configuration.get_solo()

        if config.welcome_member_template:
            context = {
                'name': config.name,
                'contact': config.mail_from,
                'number': form.instance.number,
                'member_name': form.instance.name,
            }
            responses = [
                r[1] for r in new_member_mail_information.send_robust(
                    sender=form.instance) if r
            ]
            context['additional_information'] = '\n'.join(responses).strip()
            config.welcome_member_template.to_mail(email=form.instance.email,
                                                   context=context)
        if config.welcome_office_template:
            context = {'member_name': form.instance.name}
            responses = [
                r[1] for r in new_member_office_mail_information.send_robust(
                    sender=form.instance) if r
            ]
            context['additional_information'] = '\n'.join(responses).strip()
            config.welcome_office_template.to_mail(
                email=config.backoffice_mail, context=context)
        return super().form_valid(form)
コード例 #3
0
    def form_valid(self, form):
        self.form = form
        form.save()
        messages.success(
            self.request,
            _("The member was added, please edit additional details if applicable."
              ),
        )
        form.instance.log(self, ".created")

        responses = new_member.send_robust(sender=form.instance)
        for _receiver, response in responses:
            if isinstance(response, Exception):
                messages.warning(
                    self.request,
                    _("Some post processing steps could not be completed: ") +
                    str(response),
                )
        config = Configuration.get_solo()

        if config.welcome_member_template and form.instance.email:
            context = {
                "name": config.name,
                "contact": config.mail_from,
                "number": form.instance.number,
                "member_name": form.instance.name,
            }
            responses = [
                r[1] for r in new_member_mail_information.send_robust(
                    sender=form.instance) if r
            ]
            context["additional_information"] = "\n".join(responses).strip()
            config.welcome_member_template.to_mail(email=form.instance.email,
                                                   context=context)
        if config.welcome_office_template:
            context = {"member_name": form.instance.name}
            responses = [
                r[1] for r in new_member_office_mail_information.send_robust(
                    sender=form.instance) if r
            ]
            context["additional_information"] = "\n".join(responses).strip()
            config.welcome_office_template.to_mail(
                email=config.backoffice_mail, context=context)
        return super().form_valid(form)