删除用户时发送通知

时间:2017-08-11 13:51:27

标签: django

如何从列表中删除用户时发送电子邮件通知? 我在网站上有一个表格。有了它,我添加了用户。当添加用户时,我收到邮件通知。如何在删除用户时收到通知? Views.py:

class CreateUser(CreateView):
    template_name = 'staffweb/add_user.html'

    form_class = AddUserForm
    model = StaffPersonal
    context_object_name = 'staff'
    success_url = reverse_lazy('home')

    def form_valid(self, form):
        new_user = form.save()
        new_user_name = new_user.full_name
        msg_args = ['New user added: ' + new_user_name]
        send_to_bot('\n'.join((msg_args)))
        email_text = make_letter(*msg_args)
        send_to_email(settings.ADMIN_EMAIL, email_text)
        return super(CreateUser, self).form_valid(form)


class DetailUser(DetailView):
    template_name = 'staffweb/user.html'
    model = StaffPersonal
    context_object_name = 'user'


class DeleteUser(DeleteView):
    model = StaffPersonal
    success_url = reverse_lazy('home')

谢谢!

0 个答案:

没有答案