def changelist_view(self, request, extra_context=None, **kwargs): if extra_context is None: extra_context = {} extra_context['users_to_welcome'] = WelcomeEmail.get_users_to_welcome() return super(WelcomeEmailAdmin, self).changelist_view(request, extra_context=extra_context, **kwargs)
def create_welcome_emails(request): """figure out what people to send welcome emails to and then send them. The people to consider for this is those who haven't received an email and are younger than a day. """ users = WelcomeEmail.get_users_to_welcome() count = 0 for user in users: welcome_email = create_welcome_email(user, request) if welcome_email is not None: count += 1 if count: if count == 1: msg = 'Created 1 welcome email' else: msg = 'Created %s welcome emails' % count else: msg = 'No welcome emails this time' return HttpResponse(msg)
def changelist_view(self, request, extra_context=None, **kwargs): if extra_context is None: extra_context = {} extra_context["users_to_welcome"] = WelcomeEmail.get_users_to_welcome() return super(WelcomeEmailAdmin, self).changelist_view(request, extra_context=extra_context, **kwargs)