Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. # This should return None rather than 404
  2. def get_sending_domain(company, domain):
  3. """
  4. Retrieve sending domain details from company's Sparkpost subaccount.
  5. """
  6. sparkpost_subaccount = get_sparkpost_subaccount(company)
  7. if not sparkpost_subaccount:
  8. return http.HttpResponse(status=404)
  9.  
  10. # So if it doesn't return an error, I need to throw an error on the parent method, which is:
  11. def get_company_email_sending_domain(request, pk):
  12. """
  13. Get specific sending domain details for company on Sparkpost
  14. """
  15. domain = request.body
  16. company = get_object_or_404(comp_models.Company, pk=pk)
  17. result = sparkpost.get_sending_domain(company, domain)
  18. return http.JsonResponse({
  19. 'success': True,
  20. 'domain': result,
  21. }, status=200)
  22.  
  23. # Soooo... do I just throw a 404 here?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement