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

pull/1/head
Andromeda Yelton 2012-03-13 16:27:39 -04:00
commit ffcea5c3d6
7 changed files with 67 additions and 14 deletions

View File

@ -13,6 +13,9 @@
{% endfor %}</ul>{% endif %}
<br />{{ wishlists.today.count }} of them have 1 or more items on a wishlist.
</li>
<li>{{ users.yesterday.count }} registered yesterday.
<br />{{ wishlists.yesterday.count }} of them have 1 or more items on a wishlist.
</li>
<li>{{ users.days7.count }} have registered in the past 7 days.
<br />{{ wishlists.days7.count }} of them have 1 or more items on a wishlist.
</li>
@ -23,6 +26,12 @@
<br />{{ wishlists.all.count }} of them have 1 or more items on a wishlist.
</li>
</ul>
<ul>
<li> {{ users.gr.count }} ungluers are connected to GoodReads.</li>
<li> {{ users.lt.count }} ungluers are connected to LibraryThing.</li>
<li> {{ users.fb.count }} ungluers are connected to FaceBook.</li>
<li> {{ users.tw.count }} ungluers are connected to Twitter.</li>
</ul>
</dd>
</dl>
<h2>Works</h2>
@ -35,6 +44,8 @@
<li><a href="{% url work work.id %}">{{work.title}}</a></li>
{% endfor %}</ul>{% endif %}
</li>
<li>{{ works.yesterday.count }} were added yesterday.
</li>
<li>{{ works.days7.count }} have been added in the past 7 days.
</li>
<li>{{ works.month.count }} have been added in this month.
@ -69,6 +80,8 @@
<li><a href="{% url work ebook.edition.work.id %}">{{ebook.edition.work.title}}</a></li>
{% endfor %}</ul>{% endif %}
</li>
<li>{{ ebooks.yesterday.count }} were added yesterday.
</li>
<li>{{ ebooks.days7.count }} have been added in the past 7 days.
</li>
<li>{{ ebooks.month.count }} have been added in this month.

View File

@ -12,7 +12,7 @@
</div>
<br />
<div class="welcomealternatives">
Or you can <a href="{% url auth_password_reset %}">view your profile</a> &#151; <a href="{% url work_list 'popular' %}">see the most wishlisted books</a> &#151; <a href="/feedback/">send us feedback</a>
Or you can <a href="{{editurl}}">change your username</a> &#151; <a href="{% url work_list 'popular' %}">see the most wishlisted books</a> &#151; <a href="/feedback/">send us feedback</a>
</div>
{% endblock %}

View File

@ -259,7 +259,7 @@ there's no tab for seeing ALL my books, only the filters! huh.
<li class="tabs3"><a href="#">Wishlisted</a></li>
</ul>
<span id="rss"><a href="feed" title="RSS feed of {{ supporter }}'s latest wishbooks" alt="RSS feed of {{ supporter }}'s latest wishbooks"><img src="/static/images/feedicons-standard/feed-icon-14x14.png"><span>Subscribe</span></a></span>
<span id="rss"><a href="feed" title="RSS feed of {{ supporter }}'s latest wishbooks" ><img src="/static/images/feedicons-standard/feed-icon-14x14.png" alt="RSS feed of {{ supporter }}'s latest wishbooks" /><span>Subscribe</span></a></span>
{% if not works %}
{% comment %}

View File

@ -228,7 +228,7 @@ class WorkListView(ListView):
if (facet == 'popular'):
return models.Work.objects.order_by('-num_wishes', 'id')
elif (facet == 'recommended'):
return models.Work.objects.filter(wishlists__user=recommended_user)
return models.Work.objects.filter(wishlists__user=recommended_user).order_by('-num_wishes')
elif (facet == 'new'):
return models.Work.objects.filter(num_wishes__gt=0).order_by('-created', '-num_wishes' ,'id')
else:
@ -240,8 +240,8 @@ class WorkListView(ListView):
context['ungluers'] = userlists.work_list_users(qs,5)
context['facet'] =self.kwargs['facet']
context['works_unglued'] = qs.filter(editions__ebooks__isnull=False).distinct()
context['works_active'] = qs.exclude(editions__ebooks__isnull=False).filter(Q(campaigns__status='ACTIVE') | Q(campaigns__status='SUCCESSFUL')).distinct().order_by('-campaigns__status', 'campaigns__deadline')
context['works_wished'] = qs.exclude(editions__ebooks__isnull=False).exclude(campaigns__status='ACTIVE').exclude(campaigns__status='SUCCESSFUL').distinct().order_by('-num_wishes')
context['works_active'] = qs.exclude(editions__ebooks__isnull=False).filter(Q(campaigns__status='ACTIVE') | Q(campaigns__status='SUCCESSFUL')).distinct()
context['works_wished'] = qs.exclude(editions__ebooks__isnull=False).exclude(campaigns__status='ACTIVE').exclude(campaigns__status='SUCCESSFUL').distinct()
context['activetab'] = "#3"
@ -1017,11 +1017,23 @@ class InfoPageView(TemplateView):
users.days7 = users.filter(date_joined__range = (date_today()-timedelta(days=7), now()))
users.year = users.filter(date_joined__year = date_today().year)
users.month = users.year.filter(date_joined__month = date_today().month)
if date_today().day==1:
users.yesterday = users.filter(date_joined__range = (date_today()-timedelta(days=1), date_today()))
else:
users.yesterday = users.month.filter(date_joined__day = date_today().day-1)
users.gr = users.filter(profile__goodreads_user_id__isnull = False)
users.lt = users.exclude(profile__librarything_id = '')
users.fb = users.filter(profile__facebook_id__isnull = False)
users.tw = users.exclude(profile__twitter_id = '')
works = models.Work.objects
works.today = works.filter(created__range = (date_today(), now()))
works.days7 = works.filter(created__range = (date_today()-timedelta(days=7), now()))
works.year = works.filter(created__year = date_today().year)
works.month = works.year.filter(created__month = date_today().month)
if date_today().day==1:
works.yesterday = works.filter(created__range = (date_today()-timedelta(days=1), date_today()))
else:
works.yesterday = works.month.filter(created__day = date_today().day-1)
works.wishedby2 = works.filter(num_wishes__gte = 2)
works.wishedby20 = works.filter(num_wishes__gte = 20)
works.wishedby5 = works.filter(num_wishes__gte = 5)
@ -1033,11 +1045,19 @@ class InfoPageView(TemplateView):
ebooks.days7 = ebooks.filter(created__range = (date_today()-timedelta(days=7), now()))
ebooks.year = ebooks.filter(created__year = date_today().year)
ebooks.month = ebooks.year.filter(created__month = date_today().month)
if date_today().day==1:
ebooks.yesterday = ebooks.filter(created__range = (date_today()-timedelta(days=1), date_today()))
else:
ebooks.yesterday = ebooks.month.filter(created__day = date_today().day-1)
wishlists= models.Wishlist.objects.exclude(wishes__isnull=True)
wishlists.today = wishlists.filter(created__range = (date_today(), now()))
wishlists.days7 = wishlists.filter(created__range = (date_today()-timedelta(days=7), now()))
wishlists.year = wishlists.filter(created__year = date_today().year)
wishlists.month = wishlists.year.filter(created__month = date_today().month)
if date_today().day==1:
wishlists.yesterday = wishlists.filter(created__range = (date_today()-timedelta(days=1), date_today()))
else:
wishlists.yesterday = wishlists.month.filter(created__day = date_today().day-1)
return {
'users': users,
'works': works,

View File

@ -10,7 +10,10 @@ from django.db.models.query_utils import Q
from django.shortcuts import render_to_response
from django.template import RequestContext
import datetime
from datetime import timedelta
from regluit.utils.localdatetime import now, isoformat
import dateutil
import dateutil.parser
import hashlib
import httplib
@ -601,16 +604,16 @@ class Preapproval( PaypalEnvelopeRequest ):
cancel_url = settings.BASE_URL + CANCEL_URL
# set the expiration date for the preapproval if not passed in
now = datetime.datetime.utcnow()
now_val = now()
if expiry is None:
expiry = now + datetime.timedelta( days=settings.PREAPPROVAL_PERIOD )
transaction.date_authorized = now
expiry = now_val + timedelta( days=settings.PREAPPROVAL_PERIOD )
transaction.date_authorized = now_val
transaction.date_expired = expiry
transaction.save()
data = {
'endingDate': expiry.isoformat(),
'startingDate': now.isoformat(),
'endingDate': isoformat(expiry),
'startingDate': isoformat(now_val),
'maxTotalAmountOfAllPayments': '%.2f' % transaction.amount,
'maxNumberOfPayments':1,
'maxAmountPerPayment': '%.2f' % transaction.amount,
@ -704,8 +707,15 @@ class PreapprovalDetails(PaypalEnvelopeRequest):
else:
self.approved = None
self.expiration = self.response.get("endingDate", None)
self.date = self.response.get("startingDate", None)
try:
self.expiration = dateutil.parser.parse(self.response.get("endingDate"))
except:
self.expiration = None
try:
self.date = dateutil.parser.parse(self.response.get("startingDate", None))
except:
self.date = None
except:
self.errorMessage = "Error: ServerError"

View File

@ -23,6 +23,7 @@ import logging
import os
from decimal import Decimal as D
from regluit.utils.localdatetime import now
from datetime import timedelta
def setup_selenium():
# Set the display window for our xvfb
@ -278,7 +279,7 @@ class TransactionTest(TestCase):
w = Work()
w.save()
c = Campaign(target=D('1000.00'),deadline=now() + datetime.timedelta(days=180),work=w)
c = Campaign(target=D('1000.00'),deadline=now() + timedelta(days=180),work=w)
c.save()
t = Transaction()

View File

@ -110,6 +110,15 @@ def make_naive(value, timezone):
value = timezone.normalize(value)
return value.replace(tzinfo=None)
def isoformat(value):
"""
if value is naive, assume it's in the default_timezone
"""
if is_naive(value):
return make_aware(value, get_default_timezone()).isoformat()
else:
return value.isoformat()
def as_utc_naive(value):
"""
if value is naive, assume it's in the default time zone, then convert to UTC but make naive