Merge branch 'master' of github.com:Gluejar/regluit into ry

Conflicts:
	core/tasks.py
pull/1/head
Raymond Yee 2012-03-29 14:05:55 -07:00
commit 3dd1713fa5
9 changed files with 148 additions and 112 deletions

View File

@ -1,3 +1,11 @@
def is_preview(request):
from django.conf import settings
return {'is_preview': settings.IS_PREVIEW, 'jquery_home': settings.JQUERY_HOME, 'jquery_ui_home': settings.JQUERY_UI_HOME}
def count_unseen(request):
from notification.models import Notice, NoticeManager
if request.user.is_anonymous():
count = 0
else:
count = Notice.objects.unseen_count_for(request.user)
return {'unseen_count': count}

View File

@ -7,6 +7,8 @@ from social_auth.signals import pre_update
from social_auth.backends.facebook import FacebookBackend
from tastypie.models import create_api_key
#from regluit.core import tasks
import registration.signals
import logging
@ -60,6 +62,12 @@ from django.utils.translation import ugettext_noop as _
from django.db.models import signals
from notification import models as notification
from notification.engine import send_all
from celery.decorators import task
@task
def emit_notifications():
send_all()
# create notification types (using django-notification) -- tie to syncdb
@ -75,9 +83,8 @@ from django.contrib.comments.signals import comment_was_posted
def notify_comment(comment, request, **kwargs):
other_commenters = User.objects.filter(comment_comments__content_type=comment.content_type, comment_comments__object_pk=comment.object_pk).distinct().exclude(id=comment.user.id)
other_wishers = comment.content_object.wished_by().exclude(id=comment.user.id).exclude(id__in=other_commenters)
notification.send(other_commenters, "coment_on_commented", {'comment':comment}, True)
notification.send(other_wishers, "wishlist_comment", {'comment':comment}, True)
notification.queue(other_commenters, "coment_on_commented", {'comment':comment}, True)
notification.queue(other_wishers, "wishlist_comment", {'comment':comment}, True)
emit_notifications.delay()
comment_was_posted.connect(notify_comment)

View File

@ -29,14 +29,9 @@ def load_librarything_into_wishlist(user_id, lt_username, max_books=None):
user=User.objects.get(id=user_id)
return librarything.load_librarything_into_wishlist(user, lt_username, max_books)
@task
def add(x,y):
"""trivial task to add two numbers: don't delete this for now -- used in tests for learning about celery"""
return x+y
@task
def fac(n, sleep_interval=None):
"""a task used in core.tests.CeleryTaskTest to show example of how to report progress in tasks"""
# used to test celery task execution
if not(isinstance(n,int) and n >= 0):
raise Exception("You can't calculate a factorial of %s " % (str(n)))
if n <= 1:
@ -49,3 +44,4 @@ def fac(n, sleep_interval=None):
if sleep_interval is not None:
sleep(sleep_interval)
return res

View File

@ -18,25 +18,26 @@
</div>
</a>
{% if notices %}
{% if unseen_count > 0 %}
<div class="notices_menu">
<a href="{% url notification_mark_all_seen %}">{% trans "Mark all unseen notices seen" %}</a>
<a href="{% url notification_mark_all_seen %}">{% trans "Mark all notices seen" %}</a>
</div>
{% endif %}
<div class="comments"></div>
<br />
{% for notice in notices %}
{% if notice.is_unseen %}
<div class="unseen_notice">
{% else %}
{% if unseen_count > 0 %}
{% for notice in notices %}
{% if notice.unseen %}
{% comment %}
Note: do not call is_unseen because it will mark the notification as seen,
and we're leaving that up to the user.
{% endcomment %}
<div class="notice">
{% endif %}
{{ notice.message|safe }}
</div>
<br />
{% endif %}
{% endfor %}
{% else %}
<p>{% trans "No notices." %}</p>
{% endif %}

View File

@ -73,6 +73,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.request',
'regluit.context_processors.is_preview',
'regluit.context_processors.count_unseen',
)
MIDDLEWARE_CLASSES = (

View File

@ -118,6 +118,3 @@ LOGGING = {
STATIC_ROOT = '/var/www/static'
IS_PREVIEW = False
# a django-notification setting for whether to queue notifications or send_now (False)
NOTIFICATION_QUEUE_ALL = True

View File

@ -118,5 +118,3 @@ LOGGING = {
STATIC_ROOT = '/var/www/static'
# a django-notification setting for whether to queue notifications or send_now (False)
NOTIFICATION_QUEUE_ALL = True

View File

@ -278,42 +278,6 @@ ul.menu {
clear: both;
visibility: hidden;
}
/* Learn More menu */
#block-intro-text {
padding-right: 10px;
}
#block-intro-text span.def {
font-style: italic;
}
a#readon {
background: url("/static/images/learnmore-downarrow.png") right center no-repeat;
color: #fff;
text-transform: capitalize;
display: block;
float: right;
font-size: 13px;
font-weight: bold;
}
a#readon.down {
background: url("/static/images/learnmore-uparrow.png") right center no-repeat;
}
a#readon span {
-moz-border-radius: 32px 0 0 32px;
-webkit-border-radius: 32px 0 0 32px;
border-radius: 32px 0 0 32px;
background-color: #8ac3d7;
margin-right: 34px;
padding: 0 5px 0 20px;
height: 36px;
line-height: 36px;
display: block;
}
.spread_the_word {
height: 24px;
width: 24px;
position: top;
margin-left: 5px;
}
/* Header section */
#js-header {
height: 90px;
@ -332,6 +296,7 @@ a#readon span {
.js-topmenu ul li {
float: left;
padding: 0 10px;
position: relative;
}
.js-topmenu ul li a {
color: #3d4e53;
@ -355,6 +320,19 @@ a#readon span {
overflow: auto;
max-width: 240px;
}
.js-topmenu ul li #notification_count {
position: absolute;
right: 10px;
top: -14px;
color: #e35351;
background-color: white;
border: solid 2px #e35351;
-moz-border-radius: 16px;
-webkit-border-radius: 16px;
border-radius: 16px;
padding: 3px;
line-height: 16px;
}
.js-topmenu ul li.last a {
background: url("/static/images/bg.png") right top no-repeat;
}
@ -415,6 +393,42 @@ a#readon span {
display: none;
}
/* Learn More menu */
#block-intro-text {
padding-right: 10px;
}
#block-intro-text span.def {
font-style: italic;
}
a#readon {
background: url("/static/images/learnmore-downarrow.png") right center no-repeat;
color: #fff;
text-transform: capitalize;
display: block;
float: right;
font-size: 13px;
font-weight: bold;
}
a#readon.down {
background: url("/static/images/learnmore-uparrow.png") right center no-repeat;
}
a#readon span {
-moz-border-radius: 32px 0 0 32px;
-webkit-border-radius: 32px 0 0 32px;
border-radius: 32px 0 0 32px;
background-color: #8ac3d7;
margin-right: 34px;
padding: 0 5px 0 20px;
height: 36px;
line-height: 36px;
display: block;
}
.spread_the_word {
height: 24px;
width: 24px;
position: top;
margin-left: 5px;
}
/* Explore column */
#js-leftcol {
float: left;

View File

@ -193,44 +193,6 @@ ul.menu{
visibility: hidden;
}
/* Learn More menu */
#block-intro-text {
padding-right: 10px;
span.def {
font-style: italic;
}
}
a#readon {
background:url("@{image-base}learnmore-downarrow.png") right center no-repeat;
color:#fff;
text-transform:capitalize;
display:block;
float:right;
font-size:13px;
font-weight:bold;
&.down {
background:url("@{image-base}learnmore-uparrow.png") right center no-repeat;
}
span {
.border-radius(32px, 0, 0, 32px);
background-color: @bright-blue;
margin-right:34px;
padding:0 5px 0 20px;
.height(36px);
display:block;
}
}
.spread_the_word {
height: 24px;
width: 24px;
position: top;
margin-left:5px;
}
/* Header section */
#js-header {
height:90px;
@ -253,6 +215,7 @@ a#readon {
li {
float:left;
padding:0 10px;
position: relative;
a {
color:@text-blue;
@ -267,6 +230,18 @@ a#readon {
max-width: 240px;
}
#notification_count {
position: absolute;
right: 10px;
top: -14px;
color: @alert;
background-color: white;
border: solid 2px @alert;
.one-border-radius(16px);
padding: 3px;
line-height: 16px;
}
&.last {
a {
background: url(@background-header) right top no-repeat;
@ -338,6 +313,45 @@ a#readon {
display: none;
}
/* Learn More menu */
#block-intro-text {
padding-right: 10px;
span.def {
font-style: italic;
}
}
a#readon {
background:url("@{image-base}learnmore-downarrow.png") right center no-repeat;
color:#fff;
text-transform:capitalize;
display:block;
float:right;
font-size:13px;
font-weight:bold;
&.down {
background:url("@{image-base}learnmore-uparrow.png") right center no-repeat;
}
span {
.border-radius(32px, 0, 0, 32px);
background-color: @bright-blue;
margin-right:34px;
padding:0 5px 0 20px;
.height(36px);
display:block;
}
}
.spread_the_word {
height: 24px;
width: 24px;
position: top;
margin-left:5px;
}
/* Explore column */
#js-leftcol {
float:left;