email.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. from django.conf import settings
  2. from glitchtip.email import DetailEmail
  3. from .models import Organization, OrganizationUser
  4. class MetQuotaEmail(DetailEmail):
  5. html_template_name = "organizations/met-quota-drip.html"
  6. text_template_name = "organizations/met-quota-drip.txt"
  7. subject_template_name = "organizations/met-quota-drip-subject.txt"
  8. model = Organization
  9. def get_email(self):
  10. return self.object.email
  11. def get_context_data(self, **kwargs):
  12. context = super().get_context_data(**kwargs)
  13. base_url = settings.GLITCHTIP_URL.geturl()
  14. event_limit = settings.BILLING_FREE_TIER_EVENTS
  15. organization = self.object
  16. subscription_link = f"{base_url}/{organization.slug}/settings/subscription"
  17. context["organization_name"] = organization.name
  18. context["event_limit"] = event_limit
  19. context["subscription_link"] = subscription_link
  20. return context
  21. class InvitationEmail(DetailEmail):
  22. html_template_name = "organizations/invite-user-drip.html"
  23. text_template_name = "organizations/invite-user-drip.txt"
  24. subject_template_name = "organizations/invite-user-drip-subject.txt"
  25. model = OrganizationUser
  26. def get_email(self):
  27. return self.object.email
  28. def get_context_data(self, **kwargs):
  29. context = super().get_context_data(**kwargs)
  30. org_user = context["object"]
  31. context["token"] = self.kwargs["token"]
  32. context["user"] = org_user
  33. context["organization"] = org_user.organization
  34. return context