This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import template | |
from django.contrib.admin.views.main import PAGE_VAR | |
from django.utils.html import format_html | |
register = template.Library() | |
DOT = "." | |
@register.simple_tag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- templates/admin/pagination.html --> | |
{% load admin_list %} | |
{% load i18n %} | |
{% load content_extras %} | |
<p class="paginator"> | |
{% if pagination_required %} | |
{% for i in page_range %} | |
{% if forloop.first %} | |
{% back_url cl i %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'admin/change_form.html' %} | |
{% block submit_buttons_bottom %} | |
<input type="submit" value="Send Email" name="_send_email"> | |
</div> | |
{{ block.super }} | |
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MessageEventAdmin(admin.ModelAdmin): | |
#... | |
def response_change(self, request, obj): | |
if "_send_email" in request.POST: | |
message_text = str(obj.msg_text) | |
if obj.msg_html: | |
email = EmailMultiAlternatives( | |
subject=obj.msg_subject, | |
body=message_text, | |
to=[obj.msg_envelope_recipient], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf import settings | |
from django.core.mail import EmailMessage | |
from django.dispatch import receiver | |
from django.utils import timezone | |
from anymail.signals import inbound | |
@receiver(inbound) | |
def handle_inbound(sender, event, esp_name, **kwargs): | |
"""Very basic mail forwarding. Ignores attachments.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MessageEvent(models.Model): | |
"""Wrapper around Anymail's inbound events, for sending and forwarding messages. | |
Assumes you've already installed anymail. | |
Ignores attachments. | |
""" | |
# event_... will only have values if was received by ESP, and even then, probably not. | |
event_event_id = models.CharField(max_length=100, null=True, blank=True) | |
event_timestamp = models.DateTimeField(null=True, blank=True) | |
event_esp_event = models.CharField(max_length=100, null=True, blank=True) |