def action(self, sender, instance, created, **kwargs):
     if (created):
         mail_sender = MailSender()
         data = SortedDict()
         try:
             for notification_field in instance._meta.notification_fields:
                 field = instance._meta.get_field(notification_field)
                 data[field.verbose_name] =  get_field_value(instance, field)
         except AttributeError:
             pass
         context={'obj': instance,
                  'data': data, 
                  'obj_verbose_name':instance._meta.verbose_name, 
                  'obj_name': instance._meta.object_name, 
                  'obj_app_label':instance._meta.app_label, 
                  'SITE_URL':settings.SITE_URL
                  }
         content_type = ContentType.objects.get_for_model(instance)
         codename = 'can_receive_notification_%s' % content_type.model
         perm = Permission.objects.get(content_type=content_type, codename=codename)
         mail_sender.send_admin_mail(_(u'It was created a new item'), 'mail/admin/notification.html', context, perm=perm)
 def handle(self, *args, **options):
     mail_sender = MailSender()
     self.stdout.write(mail_sender.send_batch()+"\n")
 def action(self, sender, instance, created, **kwargs):
     if (created):
         mail_sender = MailSender()
         recip = getattr(instance, self.models_data[instance._meta.db_table]['email_field'])
         context={'obj': instance,}
         mail_sender.send_mail(_(self.models_data[instance._meta.db_table]['subject']), recip, self.models_data[instance._meta.db_table]['template'], context)