diff -r 7b8167c4aa6f -r f69ff46d3240 src/cm/views/notifications.py --- a/src/cm/views/notifications.py Thu Nov 26 12:03:53 2009 +0100 +++ b/src/cm/views/notifications.py Mon Nov 30 13:46:17 2009 +0100 @@ -19,8 +19,9 @@ @login_required def notifications(request): - notify_check = Notification.objects.filter(text=None,type=None,user=request.user, active=True).count() - own_check = Notification.objects.filter(text=None,type='own',user=request.user, active=True).count() + workspace_notify_check = Notification.objects.filter(text=None,type='workspace',user=request.user, active=True).count() + own_notify_check = Notification.objects.filter(text=None,type='own',user=request.user, active=True).count() + if request.method == 'POST': if 'activate' in request.POST: Configuration.objects.set_key('private_feed_key', generate_key()) @@ -28,22 +29,15 @@ if 'reset' in request.POST: Configuration.objects.set_key('private_feed_key', generate_key()) display_message(request, _(u"Private feed reseted.")) - if request.POST.get('notify_check',None) == u'true': - if not notify_check: - notification = Notification.objects.create_notification(text=None, type=None, email_or_user=request.user) - # ajax display_message(request, _(u"Notifications activated.")) - elif request.POST.get('notify_check',None) == u'false': - Notification.objects.filter(text=None,type=None,user=request.user).delete() - notify_check = False - - if request.POST.get('own_check',None) == u'true': - Notification.objects.set_notification_to_own_discussions(text=None,email_or_user=request.user, active=True) - elif request.POST.get('own_check',None) == u'false': - Notification.objects.set_notification_to_own_discussions(text=None,email_or_user=request.user, active=False) - own_check = False + if request.POST.get('notif_id',None): + notif_id = request.POST.get('notif_id') + notif_type = 'own' if notif_id == 'own_notify_check' else 'workspace' + notif_val = request.POST.get(notif_id,None) + if notif_val != None : + Notification.objects.set_notification(text=None, type=notif_type, active=(notif_val == 'true'), email_or_user=request.user) - return render_to_response('site/notifications.html', {'notify_check':notify_check, - 'own_check' :own_check, + return render_to_response('site/notifications.html', {'workspace_notify_check':workspace_notify_check, + 'own_notify_check' :own_notify_check, }, context_instance=RequestContext(request)) @@ -73,9 +67,8 @@ from cm.security import user_has_perm # import here! anonymous_can_view_text = user_has_perm(None, 'can_view_text', text=text) - own_check = Notification.objects.filter(text=text,type='own',user=user).count() - all_check = Notification.objects.filter(text=text,type=None,user=user).count() - + text_notify_check = Notification.objects.filter(text=text,type='text',user=user, active=True).count() + workspace_notify_check = Notification.objects.filter(text=None,type='workspace',user=user, active=True).count() embed_code = '