Giter Club home page Giter Club logo

django-herald's People

Contributors

apoorvaeternity avatar georgmzimmer avatar jordanmkoncz avatar jproffitt avatar mands avatar mluard-worthwhile avatar npardington avatar peterfarrell avatar raiderrobert avatar seanbermejo avatar sudoguy avatar zulupro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-herald's Issues

confusing 'delnotifs' command with optional start and end args

for delnotifs command with start and end args, doc says:

end is up to, but not including that date.

I'd think if I specify the end date being yesterday without start date, it will delete notifications sent before yesterday.

the actual code is

start_date = options['start'] if options['start'] else today

This will set the start date to be today, and end date to be yesterday, it's going to be an invalid range.

Suggestion:

  • if only end date is specified, delete anything sent before date_sent
  • if only start date is specified, delete anything sent after date_sent
  • if both start and end dates are specified, delete the range

Cannot install herald without first installing django

It is impossible to install herald in in an environment that does not have django installed yet. This is because setup.py imports herald.__version__ which then imports from django.utils.module_loading import autodiscover_modules.

I think all we need to do is move the django import down inside the autodiscover function.

Adding attachments is not well documented

As per the readme section, the attachment can be in the form of Django File object.
Now, I have created a Django File object as follows:

    with open('docs/my.pdf', 'r') as f:
        file = File(f)

I am having a hard time figuring out how to use this object in the code to send the email. Anything done outside the with block obviously creates an error as the file is closed.

Here is the full code:

@registry.register_decorator()
class SendThisMail(SomeBaseClass, EmailNotification):
    def __init__(self, user, my_modal: models.MyModal):
        super().__init__(user, my_modal)

        self.subject = "abc"

        with open('docs/my.pdf', 'r') as f:
            file = File(f)

            self.attachments = (
                'abc.pdf', file,
                'application/pdf')

        self.context = {
            'subject': self.subject,
            **self.context,
        }

        self.to_emails = [user.email]

def sendMail():
    SendThisMail(user, my_modal).send(user=my_user) # creates an error on this line as the file object is closed and inaccessible.

Support for push notifications

Hi ,
Have you thought about adding support for push notifications for app.
Basically it would be good to add a template for adding a transmission method.

Thanks
Anand

Can't send mails with attachments

I've been struggling for days to make it work but the lack of documentation and silent failures made it impossible to debug the issues. It seems that the mails are not being sent if I include an attachment in it.


def sendMail():
    SendThisMail(user, my_modal).send(user=my_user) # creates an error on this line as the file object is closed and inaccessible.

@registry.register_decorator()
class SendThisMail(SomeBaseClass, EmailNotification):
    def __init__(self, user, my_modal: models.MyModal):
        super().__init__(user, my_modal)

        self.subject = "abc"

        file = open('.staticfiles/assets/some.pdf', 'rb')

        self.attachments = [('attachment_1', File(file))]

        self.context = {
            **self.context,
            'subject': self.subject,
            'attachment': self.attachments,
        }

        self.to_emails = [user.email]

What's wrong with it?

Allow Herald to Support Multiple Python Webframeworks

At the moment, Herald is squarely a Django package. However, there may be some benefit in making it less dependent on Django specifically and more dependent on having specific components that adhere to Django's API interface for various things.

Should this repo be forked to work on that, or is there openness to supporting this as a long-running branch?

Template directory structure may need some work

Right now, you are forced to make sure your templates are in the following directory structure: herald/html/{notifcation_name}.html or herald/text/{notifcation_name}.txt.

First of all, that should definitely be overridable. Maybe rename NotificationBase.template_name to NotificationBase.template_base_name to avoid confusion, then add the ability to define absolute template paths per render_type. (but the current default would still remain). like the following:

class MyEmail(NotificationBase):
    template_names = {
        'text': 'my/custom/template/path.txt',
        'html': 'my/custom/template/path.html'
    }

Secondly, is the current default even a good default? Rather than herald/html/{notifcation_name}.html or herald/text/{notifcation_name}.txt should it maybe be {app name}/{notifcation_name}.html or {app name}/{notifcation_name}.txt similar to how the django generic class based views find templates by default (for example, {app_name}/{model_name}_create.html is the default for CreateViews.)

Sending group email using `bcc` only not working

I'm trying to send an email to a group of users with the same template and context and they can't be in the same message
so I tried using bcc only with to_emails = []
but it's not sending any emails
here is the init:

 def __init__(self, obj, emails):
        self.context = {'obj': obj}
        self.bcc = emails
        self.to_emails = []

is there any way to make this work?

Configuring email host

Hello! I ask for help! It’s not clear from the description how to set up an email account from where messages will be sent. For example, I have a gmail mailbox. How do I send from there? Where can I set login parameters for my account? Thank!

How to send notification via SMS and email

I'm wondering how you would recommended using django-herald so that notifications are sent via both SMS and email.

The users in my system will always have an email address, and 90% of them will also have a mobile phone number; both of these are set on my 'User' model. I will have many different types of notifications, and it would be good if I could define them once and have the notification always sent via email, and also via SMS if the user has a mobile phone number set. I plan to use Twilio for sending SMS messages.

Ideally I would want to be able to define the message/content of the notification in just one one place too, with the SMS message being just this plain text message, while the email gets rendered into a HTML email template with the message rendered in this template.

I'm trying to figure out the best way to approach this so that I don't have to create 2 copies of every notification type (one for email and one for SMS) and trigger 2 notifications every time I want to send a notification to a user. Any recommendations?

Templates From Database

I'm building an application that allows users to customize email templates before sending out messages to users.

Given that the docs only allow for specifying a directory for the email template, is there a way to utilize this library for pulling a template record directly from the database instead?

Buglets in notification browsing view

When viewing the HTML content of an Email class, the encoding is not properly set (utf8 in my case) so the text is garbled.

In text view, it's the content-type which seems abnormal, text/text should be text/plain, so the content gets downloaded as unknown instead of displayed as raw text.

Separate notification content from the sending of the notification

Right now, each notification class basically does it all. It specifies WHAT to send and HOW to send it. I think it would be a much more flexible API if the notification classes just specified WHAT to send. Then we would have different backends that could be specified on the notification that tell HOW to send it.

That way you could, for example, have one notification that gets sent a bunch of different ways:

class BlogPostLikedNotification(Notification):
    backends = [EmailBackend, TwillioTextBacked, APNSBackend, GCMBackend]

Of course, that will come with a bunch of complications. Each backend will need separate info for who to send to, (the push notification backends need device identifiers, the twilio backend needs a phone number, and the email backend needs an email, etc.) and what to send. (The email backend needs html, the others just plain text, etc)

Something to think about... would of course be a huge refactor.

View in Browser link

Would be nice if herald could provide a "view in browser" link so that users can view the email in a browser like most email services do like mail chimp, etc.

Since the email html is cached in the database, it shouldn't be too difficult to add that feature.

Increase field max_length for Notification.notification_class

The Notification model has a field notification_class = models.CharField(max_length=80, unique=True). This max_length restriction of 80 characters is causing an issue for me, because I'm trying to create a notification class that happens to be 83 characters long, so I'm getting an error django.db.utils.DataError: (1406, "Data too long for column 'notification_class' at row 1").

The SentNotification model also has a field notification_class, but with a less restrictive max_length of 255 characters.

Is there a reason why the Notification model has an inconsistent and much more restrictive max_length for its notification_class field than that of the SentNotification model? If not, can we increase it to match the SentNotification model, otherwise you have to artificially limit the names of your notification classes in order to fit within this restriction.

support for autogenerating text/ascii notifications

Hello everyone! Great project!

I'm using it in production for one our SaaS and it's working nicely.

One of the things I've just learned about today is https://pypi.python.org/pypi/html2text.

There is a big hassle in creating and maintaining two sets of templates, one for html and one for txt. Perhps we could integrate with html2text and auto-generate the text emails, when the txt template is not available?

I can contribute, but I would like to know how you feel about that, before starting it.

django-herald on django 3.2 or above raises ImproperlyConfigured exception

The issue occurs when herald.contrib.auth is added to INSTALLED_APPS. The issue only occurs in django versions 3.2 or above.
Here's the traceback when running the tests:

Traceback (most recent call last):
  File "/Users/apoorva/Desktop/django-herald/runtests.py", line 14, in <module>
    runtests()
  File "/Users/apoorva/Desktop/django-herald/runtests.py", line 10, in runtests
    execute_from_command_line(argv)
  File "/Users/apoorva/Desktop/venvdjango3/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/Users/apoorva/Desktop/venvdjango3/lib/python3.9/site-packages/django/core/management/__init__.py", line 395, in execute
    django.setup()
  File "/Users/apoorva/Desktop/venvdjango3/lib/python3.9/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Users/apoorva/Desktop/venvdjango3/lib/python3.9/site-packages/django/apps/registry.py", line 91, in populate
    app_config = AppConfig.create(entry)
  File "/Users/apoorva/Desktop/venvdjango3/lib/python3.9/site-packages/django/apps/config.py", line 255, in create
    return app_config_class(app_name, app_module)
  File "/Users/apoorva/Desktop/venvdjango3/lib/python3.9/site-packages/django/apps/config.py", line 38, in __init__
    raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: The app label 'herald.contrib.auth' is not a valid Python identifier.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.