jtauber-archive / django-notification Goto Github PK
View Code? Open in Web Editor NEWuser notification management for the Django web framework
user notification management for the Django web framework
The official repo is https://github.com/pinax/django-notification
It would be great if this app had a solid test suite, especially for those that want to add features without breaking the code elsewhere.
http://code.google.com/p/django-notification/issues/detail?id=19
Reported by jdemoor, Nov 07, 2008
The attached patch adds support for anonymous users - instances of
AnonymousUser with at least an
to send()/send_now()/queue() and anonymous users can't read their
notifications on the site.notification-anonymous.diff
3.2 KB Download
http://code.google.com/p/django-notification/issues/detail?id=20
Reported by carl.j.meyer, Dec 01, 2008
The included ObservedItem class and associated helper methods are excellent
for letting users subscribe to notifications of changes to a single object.I also have a need to allow users to turn on/off "observation" of an entire
model class, so they will be notified anytime a new object of that type is
created.This could be handled with a separate ObservedModel or ObservedType class,
or it could be handled by allowing null values for the object_id field in
ObservedItem, and handling that as a special case (this seems a bit ugly,
as it breaks the GFK). I think I prefer the former, and since I need it
now, I'll implement it outside of django-notification and post a patch here
for possible inclusion.Comment 1 by carl.j.meyer, Dec 01, 2008
Ahh, silly me. If I'd done the work before posting the issue, I'd have realized
that ObservedItem can handle this case just fine, since observed_object can itself be
a ContentType object. Having a GFK point to a ContentType is an unnecessary extra
level of redirection, but that's probably worth it for the code simplicity.Comment 2 by eduardo.padoan, Dec 02, 2008
Yes, but this possibility is a bit non-obvious, right?
There are a few places that assume http:// during url generation. If you want https:// , presently have to locally modify feeds.py and models.py. A global settings.NOTIFICATION_USE_HTTPS might do, people are hardly likely to want a mix of http:// and https://
get_tag_uri in atomformat.py might also need to say '^https?://' when substituting.
Right now, there is no way to render a "full.html" template. When you send(), your context is completely lost after the email is gone. The "single" view is completely useless because all you can do is display the "short" message for the notification.
Would be a good feature for email notifications, allowing a user to have all notifications added to one email to receive once per day.
Looking at https://github.com/jtauber/django-notification/blob/master/notification/models.py#L108, I don't see how qs is filtered for archived messages. Since filter() clones the query set, isn't this line ineffective?
http://code.google.com/p/django-notification/issues/detail?id=18
Reported by aarond10, Oct 23, 2008
What steps will reproduce the problem?
- Send a reply message with a UTF-8 body to a friend using the pinax
messaging framework.- Error.
What is the expected output? What do you see instead?
Get an encoding error:
UnicodeEncodeError at /messages/reply/2/ 'ascii' codec can't encode characters in position 124-126: ordinal not in range(128) Request Method: POST Request URL: http://.../messages/reply/2/ Exception Type: UnicodeEncodeError Exception Value: 'ascii' codec can't encode characters in position 124-126: ordinal not in range(128) Exception Location: /var/lib/python- support/python2.5/MySQLdb/connections.py in string_literal, line 180
What version of the product are you using? On what operating system?
Pinax SVN-1061, Django SVN-9246
Please provide any additional information below.
Reproducable each time.
Comment 1 by aarond10, Oct 23, 2008
Easily fixed by appending .encode('utf8') to body and subject fields before the
send_mail call - not sure if this is the root of the problem though - didn't look too
deeply into it. Will try later if I have time.Comment 2 by jarek.zgoda, Oct 24, 2008
I think this is related to MySQLdb bug with handling Unicode subclasses. I'm getting such errors when I try to
save model with one of its attributes being SafeUnicode (plain Unicode works ok).See: http://sourceforge.net/tracker2/?func=detail&aid=2001850&group_id=22307&atid=374932
I suppose most of the users are treating django-notification as a library instead of a front-end, and its views/methods aren't really exposed to the user directly. There are calls of get_or_404 in the code which, if a notice type doesn't exist, triggers a 404 error. If the user (and developer) are showing a particular object (which does exist), and django-notification throws a 404 error for its own (valid) reasons, then this is confusing, and not easy to handle.
Bottom line: we should be throwing a NoticeTypeDoesNotExist exception or something.
http://code.google.com/p/django-notification/issues/detail?id=23
Reported by soupless.spoon, Dec 28, 2008
The ability to connect an observation/notification to any object would be awesome.
(example: 'watched items' on http://badlist.co.uk)
Comment 1 by brosner, Dec 28, 2008
Yeah, right now the wiki app handles this on its own. Which is fine, since it has more work to do around the
actual call to notification.observe. We should at least provide a super generic view for the general case.Status: Accepted
http://code.google.com/p/django-notification/issues/detail?id=13
Reported by n.leush, Sep 04, 2008
I can't explain problem in detail as I actually don't understand it. But
attached patch solves it to me.Maybe it because of using old django version (some july revision).
If you understand could you explain please where is bug?
unicode_patch.patch
806 bytes Download
http://code.google.com/p/django-notification/issues/detail?id=17
Reported by eallik, Sep 30, 2008
Basically did the standard code reusability/portability routine.
make_templates_overridable.diff
1.0 KB DownloadComment 1 by eallik, Oct 04, 2008
I have a use case in which I want to store the template code in the database for the user to be able to edit the
templates for e-mails that are sent out. So I actually made more changes to django-notification to enable the
passing of Template objects as the subject_template and body_template parameters to notification.send. The
changes are trivial, but I'm wondering if this is the right way of doing it. It works, it's backwards compatible,
it's not complex, but I'm thinking maybe I should be using django-dbtemplates instead. But then again, I
want to expose the template code through satchmo.configuration because a full-fledged templates app
would be an overkill in my situation and satchmo.configuration is much more user friendly.I think this is a legit use case so I hope someone will look into this problem and my diff.
Comment 2 by eallik, Oct 04, 2008
(No comment was entered for this change.)
make_templates_overridable.2.diff
2.8 KB Download
The html_mailer app (http://recurser.com/code/p/django-html-mailer/) works like a dream and allows the sending of plain-text and HTML emails. I've basically amended the notification send_now method to include an HTML version if the app is installed. Otherwise, just send the notification as normal.
I don't have the time to amend the code through git right now, but it's a really simple change.
Change the notification models.py file in the following 3 places:
1)
if 'mailer' in settings.INSTALLED_APPS:
from mailer import send_mail
else:
from django.core.mail import send_mail
to:
if 'html_mailer' in settings.INSTALLED_APPS:
from html_mailer import send_mail
else:
if 'mailer' in settings.INSTALLED_APPS:
from mailer import send_mail
else:
from django.core.mail import send_mail
body = render_to_string('notification/email_body.txt', {
'message': messages['full.txt'],
}, context)
to:
message_text = render_to_string('notification/email_body.txt', {
'message': messages['full.txt'],
}, context)
# Only if the html mailer is installed, can the html version be attached to the mail sent. The html_mailer version
# of send_mail checks to see if the message parameter is a dictionary with two messages types (for HTML mails)
# or a string (for plain text-only mails).
if 'html_mailer' in settings.INSTALLED_APPS:
message_html = render_to_string('notification/email_body.html', {
'message': messages['full.html'],
}, context)
message = {"text":message_text, "html":message_html}
else:
message = message_text
Lastly, you also need a new file called email_body.html in the templates folder that looks something like email_body.txt and then you're all good for HTML notifications.
Must I learn to use Git and get the change in, or is it sufficient to simply put it here?
Hi there,
I'm bringing up old topic but we really need this. The purpose of show_to_user field is to separate notices shown to user and admins. The problem is basically the same as described here:
Lauri from Transifex
http://code.google.com/p/django-notification/issues/detail?id=16
Reported by eallik, Sep 30, 2008
Not sure if the title of this issue is correct, or even if I have correctly understood the intended
use of django-notification, but...I'm trying to set up a scenario in which users get notified by e-mail when certain events occur
(i.e. a user gets subscribed to an event). I don't need on site notifications or notification feeds or
anything. The problem is when calling notification.send, I get:Reverse for 'notification_notices' with arguments '()' and keyword arguments '{}' not found.
On closer investigation, I discovered that I hadn't included notification.urls in my URLconf. Even
though I don't need any notification URLs whatsoever, I did an include('notification.urls') in my
URLconf to satisfy the requirement to be able to reverse('notification_notices'), only to get:No module named atomformat
That's because notification.urls imports notification.views which in turn does "from atomformat
import Feed".Basically my suggestion is to not require the ability to do reverse('notification_notices') for cases
in which the views are not needed.Comment 1 by eallik, Sep 30, 2008
The title should have been: "Not possible to use django-notification without atomformat"
Comment 2 by eallik, Sep 30, 2008
I've done some modifications to the source to eliminate the issue above. Basically I catch the NoReverseMatch
exception and do a {% if notices_url %} check in the template. These cahnges are backwards compatible except
for translatable strings.remove_atomformat_dependency.diff
1.7 KB DownloadComment 3 by brosner, Sep 30, 2008
Ok, you very original instinct is correct. It is wrong of us to always assume on_site notifications will be used. This
should be fixed. You then go down the wrong path in fixing that single issue. :)I will take a look into this a bit more and come up with a fix. You should not need to be including the urls.py
since you don't need them so don't do that any more :)Status: Accepted
Comment 4 by eallik, Sep 30, 2008
Well, yeah, one might consider it hackish to simply "swallow" the NoReverseMatch error as someone could have
forgotten to include notification.urls but still wants to be able to have on_site notifications. I don't like settings
either so I avoided adding another setting for that.Comment 5 by eallik, Oct 04, 2008
Any ideas yet, Brian?
Comment 6 by brosner, Oct 04, 2008
We are working on a pluggable-backends branch that will allow you to control how send works. Keep an eye out
for it. Right now it is not in a functional state, but I plan on working on it soon.Comment 7 by chris.leemesser, Jan 03, 2009
I've started django-notification myself and tripped over this issue. I eagerly await the pluggable-backends
branch. (An SMS and pager backend would be great.)In the meantime, I added settings switches to turn off the dependency on the notices urls and feeds. I
also added a docs/installation.txt to guide me in the future. In case it's useful to someone else, I've put
my branch on bitbucket, at http://www.bitbucket.org/cleemesser/django-notification-clm/overview/
http://code.google.com/p/django-notification/issues/detail?id=7
Reported by eduardo.padoan, Jun 14, 2008
observer.patch adds support for registering a user as a observer for
changes in a object. wikiobserve.patch is an example of integration with
this feature for WikiApp. It is not actually working (I change the article
and the notification dont appear, but I can ), but I'm a bit tired to debug
it right now, so I hope somebody can help with it if I dont manage to find
the error myself before (thanks!).
http://django-notification.googlecode.com/issues/attachment?aid=1158977199180925166&name=wikiobserve.patch
http://django-notification.googlecode.com/issues/attachment?aid=-5869580965379842942&name=observe.patch
http://code.google.com/p/django-notification/issues/detail?id=8
Reported by winhamwr, Jun 26, 2008
I'm using django-notification on a project where users need the option to
receive their notification emails (which are reasonably frequent) at a
separate email address from their primary email address (Hospital
administrators want their assistants getting all of the messages except for
the most important stuff). I can see this being a possible use case also
for people with one "important" email account and one for everyone else.I've created a patch that adds this feature through the use of an optional
"notification email callback" parameter to the send() function. I've also
added two optional settings, one to use if someone wants to use the special
notification email as the default and one for pointing to the view where
the user can edit their notification email.If the settings aren't set, notifications function exactly as it does
currently. If a callback is passed to send, then that particular send uses
the email function. If the settings are set, all notifications, by default
are sent to the email address returned by the function indicated (but can
be over-ridden with specific send() calls).I also created a patch towards pinax to best-demonstrate how this feature
might work in a real project (other than the project I need it for, of
course).I'm hoping other people might find this useful.
I was getting some database errors today on emit_notices command. Here is the end of the traceback:
...
OperationalError: (1054, "Unknown column 'recipient_id' in 'field list'")
What? The notification model says there is recipient_id (as well as sender_id), but my database have user_id field instead in notification_notice table...
Hmm, my version is 0.2, but my database structure differs. Finally, I checked the model of 0.1 and there it was: user_id.
So, I had to do:
ALTER TABLE `notification_notice` CHANGE `user_id` `recipient_id` INT( 11 ) NOT NULL;
ALTER TABLE `notification_notice` ADD `sender_id` INT NULL AFTER `recipient_id`;
No South migration was supplied for upgrading from 0.1 to 0.2. But I guess everyone is using "fresh" 0.2 install, so no one complained before. I'm just reporting this in case anyone did a late upgrade like I did and had the same trouble.
http://code.google.com/p/django-notification/issues/detail?id=15
Reported by eallik, Sep 30, 2008
I'm trying to set up django-notification. My user data is not stored in the contrib.auth models but
instead one of my own apps (I know this sucks but I'm writing an admin back end for a legacy
database). So the problem is not being able to call notification.send with user objects other than the
ones in django.contrib.auth.My option is to simply duplicate the data in my custom user model to auth.user to make this work,
but I was thinking that maybe this is something that I should be able to solve in a more elegant
way.Comment 1 by eallik, Oct 04, 2008
Can't this be solved using the get_model() approach James Bennet described in his DjangoCon 2008 speech?
It would be great for users to be able to opt to receive digest emails, and have all of the notifications for of a set type grouped into a daily email.
I have an application[1] based on Pinax, with django-notification, and have a problem with it. In this application, a user can send a message to other user, and the recipient gets a notice, both on site and by email. English is the main language of the server.
I have two templates, full.txt and notice.html, that use i18n, trans, and blocktrans tags. Two users have "Spanish" as their language in their Accounts. When the first user sends a message to the second one, he receives the notice, but it's not translated to Spanish.
Everything in the application is correctly translated except notice texts. Even the "notice type" is translated.
Am I missing something? I don't know where is the problem.
Thanks.
[1]: You can see the code in my github projects (condottieri).
On Google code and with regards to the issue system, the jtauber repository of django-notification is the one being used. It should be the pinax version since that's where all the mainline development is happening.
from django.contrib.syndication.views import feed
in trunk version of django there is no feed view in django.contrib.syndication.views
Hi,
I am getting the following traceback when I am trying to access notices feeds page:
Traceback:
File "/home/rtnpro/.virtualenvs/test/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/core/handlers/base.py" in get_response
response = callback(request, _callback_args, *_callback_kwargs)
return view_func(request, _args, *_kwargs)
"feed": NoticeUserFeed,
instance = f()
Exception Type: TypeError at /notices/feed/
Exception Value: init() takes exactly 3 arguments (1 given)
A more detailed traceback can be found at http://pastebin.com/AyRdQRWD. Is this really a bug?
Thanks
http://code.google.com/p/django-notification/issues/detail?id=29
Reported by bob.haugen, Mar 31, 2009
Email subject line now uses the prefix [{{ current_site }}].
Shd obey settings.EMAIL_SUBJECT_PREFIX if it exists.
http://code.google.com/p/django-notification/issues/detail?id=3
Reported by jjconti, May 20, 2008
Test for some elements of django-notification. Also include fixtures with
data for testing.django-notifications-tests1-conti-puccinelli.diff
3.7 KB Download
http://code.google.com/p/django-notification/issues/detail?id=22
Reported by lfrodrigues, Dec 22, 2008
Hello,
In my project I'm using the sites framework so I can't have a global
DEFAULT_FROM_EMAIL.Here is a patch to calculate the sender email using the sites framework if
DEFAULT_FROM_EMAIL is not available.patch.diff
737 bytes DownloadComment 1 by brosner, Dec 22, 2008
It sounds like you are using the sites framework incorrectly. Each site record you have in the sites app must correspond to a settings.py file that contains a SITE_ID of that value. This gives each site their own Django
instance and settings. The similarities between them would be the database settings and the code base.
Ultimately, allowing each settings.py that you have for each vhost can have its own DEFAULT_FROM_EMAIL.The patch as is, I will not accept. However, it would be reasonable to allow the from e-mail to be passed into
send and matched in send_now and queue. This will give you the ability to override the from e-mail as you
see fit.I am adjusting the title to reflect this.
Summary: Allow overriding of from e-mail address
Status: Accepted
Comment 2 by lfrodrigues, Dec 23, 2008
Ok,
Patch attached to allow overriding of from e-mail address.
patch.diff
2.6 KB DownloadComment 3 by lfrodrigues, Jan 03, 2009
Hello,
Any comments on my patch?
Comment 4 by ian.c.murray, Mar 12, 2009
bump
Any chance of this patch being added to trunk?Comment 5 by lfrodrigues, Apr 06, 2009
any comment about adding this?
Currently the notices() view does not retrieve notice types together with notices for current user. If the template processes each notice like below:
{% for notice in notices %}
{{ notice.notice_type.display }}
{% endfor %}
each notice_type is fetched separately from the database. When the user is displayed a lot of notifications, query count will quickly increase. I propose a patch to optimize away most of these queries by using select_related() in the view function.
Notifications currently tend to be sent using the language of the user which is doing the action, in case the get_notification_language function is not able to identify the language of the target (receiver) user.
For a international audience this is not very nice, having in mind that, if I'm a user that speaks Brazilian Portuguese, I might be sending localized (pt_BR) notifications to people who do not speak it.
The following patch makes the notification system to use the default language set in the Django settings, in case no language is found for the target user.
I would like to use HTML in my email templates for notifications I'm sending out, is this an easy patch?
http://code.google.com/p/django-notification/issues/detail?id=28
Reported by michael.martinides, Mar 31, 2009
What steps will reproduce the problem?
I need to pass an extra context to render my notice message. I think I'm not the only one.These resolves the issue
notification/models.py (revision 159) notification/models.py (working copy) @@ -381,9 +381,11 @@ verbose_name = _('observed item') verbose_name_plural = _('observed items') - def send_notice(self): + def send_notice(self, **kwargs): + extra_context = {'observed':self.observed_object} + extra_context.update(**kwargs) send([self.user], self.notice_type.label, - {'observed': self.observed_object}) + extra_context) def observe(observed, observer, notice_type_label, signal='post_save'):
http://code.google.com/p/django-notification/issues/detail?id=10
Reported by froland, Aug 10, 2008
django.po file
Users expect to get e-mails in their native languages.
So the notification should somehow know and use user's language.
Does django-notification have this feature?
http://code.google.com/p/django-notification/issues/detail?id=4
Reported by jjconti, May 20, 2008
This is a template example. It can be use with the include tag from any
other-app-template.This is an example from my code:
{% include "../../notifications/templates/notices.html" %}
NOTE: in other-app-view you should use the notice_for function:
d = {'notices': notices_for(request.user)}
and get it result rendered.
Details
It's in spanish.
- Internationalization should be done.
- url tag should be used to get the url for a certain view (for example
archive or delete).CSS
CSS example for the classes used in the template:
.notice { border: solid #CCC; border-width :0 1px 1px 0; background-color: #EDF3FE; margin: 10px 0px 10px 0px; padding: 10px; width: 250px; } .first-notice { font-weight: bold; }
In views.py
return render_to_response("notification/notice.html", { "notices": notices, "notice_types": notice_types, "notice_settings": notice_settings, }, context_instance=RequestContext(request))
but the name of the template is notice.html
Or am I missing something?
http://code.google.com/p/django-notification/issues/detail?id=6
Reported by jjconti, May 22, 2008
I suggest a new attribute for NoticeType: name.
If label is "Información" name should be "informacion"
If label is "Birthday Greet" name should be "birthday_greet"Django cames with a function to perform this stuff but I am not sure if the
name should be forced or defined by the user. In any case, I'll really
appreciate that attribute because it'll allow me to do this at Notice:def __getattr__(self, attrname): if(attrname.startswith('is_')): label = attrname[len('is_'):] try: notice_type = NoticeType.objects.get(label=label) return (lambda: True) except NoticeType: return (lambda: False) else: super(Notice, self).__getattr__(attrname)
Playing in the shell:
>>> from notifications.models import * >>> n = Notice.objects.get(id=1) >>> n.is_foo() False >>> n.notice_type <NoticeType: informacion> >>> n.is_informacion() True
These methods without arguments will be very useful at templates, where you
can ask if a Notice is_sometype and then render "class=sometype" for css stuff.
http://code.google.com/p/django-notification/issues/detail?id=11
Reported by mandric, Aug 11, 2008
Just looking at this method notification.views.notice():
http://code.google.com/p/django-notification/source/browse/trunk/notification/views.py#20
Is this a bug or a feature? Just wondering if I should hack something up
for it or just live without it for now. Most of my templates use {{
messages }} and render those at the top of the page. Ideally this view
method would add to messages and return a redirect.Comments appreciated.
Fails when threading
is not imported.
It would be very useful to have all those templates already created.
It would make it quicker to start using "notification".
i created a app where peoples can like/unlike posts they can follow/unfollow to each other and my question is:
any idea
It would be nice to be able to send a notification email only, and not store any data in the database.
This needs to be added to the example in docs/usage.txt for creating notification events on syncdb:
Add:
from django.db.models.signals import post_syncdb
And then change on line 12:
signals.post_syncdb.connect(create_notice_types, sender=notification)
To:
post_syncdb.connect(create_notice_types, sender=notification)
There is no Notice model and Observer code in development branch. Is it supposed to be continued and maintained?
The traceback: http://paste2.org/p/387304
Which I think leads back to 0f2d6f3
http://code.google.com/p/django-notification/issues/detail?id=26
Reported by carl.j.meyer, Jan 10, 2009
ObservedItemManager.get_for() (and stop_observing(), which calls it) accept
only observed, observer, and signal as arguments, and get_for() uses
self.get(...). This means it is not possible to differentiate based on
notice_type, and if there are multiple observations with the same observed
object, the same observer, and the same signal, get_for() (and thus also
stop_observing()) will raise an error because multiple objects are returned.I have a use case where the same user may observe the same object in
several different ways, differentiated based only on notice_type. It seems
to me that get_for() should have an optional notice_type argument, and in
any case should use self.filter() and return a queryset rather than using
self.get().Comment 1 by askfor, Mar 28, 2009
i got this problem too.
get_for_patch.patch
2.6 KB Download
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.