Skip to content

Instantly share code, notes, and snippets.

@jion
Created December 18, 2020 13:24
Show Gist options
  • Save jion/a31b3421b3600090ed7fc45284e9aab7 to your computer and use it in GitHub Desktop.
Save jion/a31b3421b3600090ed7fc45284e9aab7 to your computer and use it in GitHub Desktop.
from django.http import HttpResponse
from django.shortcuts import get_object_or_404
from . import models
from . import utils
def send_messages(request, merchant_id):
merchant = get_object_or_404(models.Merchant, id=merchant_id)
customers = models.Customer.objects.filter(merchant=merchant)
for customer in customers:
message = utils.generate_message(customer)
utils.send_message(customer, message)
return HttpResponse('{} messages sent for merchant: {}'.format(customers.count(), merchant.name))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment