<s> from django import template <EOL> from django . contrib . contenttypes . models import ContentType <EOL> from django . conf import settings <EOL> from . . utils import is_queued_or_sent <EOL> register = template . Library ( ) <EOL> def mailchimp_send_for_object ( context , object ) : <EOL> is_sent = is_queued_or_sent ( object ) <EOL> sent_date = None <EOL> campaign_id = None <EOL> if is_sent and hasattr ( is_sent , '<STR_LIT>' ) : <EOL> sent_date = is_sent . sent_date <EOL> campaign_id = is_sent . campaign_id <EOL> if hasattr ( object , '<STR_LIT>' ) : <EOL> objchck = object . mailchimp_allow_send <EOL> else : <EOL> objchck = lambda r : True <EOL> request = context [ '<STR_LIT>' ] <EOL> return { <EOL> '<STR_LIT>' : ContentType . objects . get_for_model ( object ) . pk , <EOL> '<STR_LIT:primary_key>' : object . pk , <EOL> '<STR_LIT>' : request . user . has_perm ( '<STR_LIT>' ) and objchck ( request ) , <EOL> '<STR_LIT>' : is_sent , <EOL> '<STR_LIT>' : sent_date , <EOL> '<STR_LIT>' : campaign_id , <EOL> '<STR_LIT>' : sent_date and request . user . has_perm ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : settings . ADMIN_MEDIA_PREFIX , <EOL> '<STR_LIT>' : bool ( request . user . email ) , <EOL> } <EOL> register . inclusion_tag ( '<STR_LIT>' , takes_context = True ) ( mailchimp_send_for_object ) </s>
