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

pull/1/head
Raymond Yee 2011-11-18 06:15:06 -08:00
commit 3fcc1b9947
9 changed files with 276 additions and 222 deletions

View File

@ -162,6 +162,10 @@ class Work(models.Model):
title = models.CharField(max_length=1000)
openlibrary_id = models.CharField(max_length=50, null=True)
def __init__(self, *args, **kwargs):
self._last_campaign = None
super(Work, self).__init__(*args, **kwargs)
def cover_image_small(self):
return self.editions.all()[0].cover_image_small()
@ -169,21 +173,22 @@ class Work(models.Model):
return self.editions.all()[0].cover_image_thumbnail()
def author(self):
authorlist = self.editions.all()[0].authors.all()
if authorlist.count() == 1:
myauthor = authorlist[0].name
elif authorlist.count() > 1:
myauthor = authorlist[0].name + ' et al.'
else:
myauthor = ''
return myauthor
authors = list(Author.objects.filter(editions__work=self).all())
if len(authors) == 1:
return authors[0].name
elif len(authors) > 1:
return authors[0].name + ' et al.'
return ''
def last_campaign(self):
# stash away the last campaign to prevent repeated lookups
if hasattr(self, '_last_campaign'):
return self._last_campaign
try:
last = self.campaigns.order_by('-created')[0]
except:
last = None
return last
self._last_campaign = self.campaigns.order_by('-created')[0]
except IndexError:
pass
return self._last_campaign
def last_campaign_status(self):
campaign = self.last_campaign()
@ -236,9 +241,8 @@ class Work(models.Model):
return self.first_ebook('epub')
def first_ebook(self, ebook_format=None):
for edition in self.editions.all():
for ebook in edition.ebooks.all():
if ebook_format == None or ebook.format == ebook_format:
for ebook in Ebook.objects.filter(edition__work=self,
format=ebook_format):
return ebook
return None

View File

@ -9,6 +9,7 @@
cd /opt/regluit
sudo -u ubuntu /usr/bin/git pull
source ENV/bin/activate
pip install -r requirements.pip
django-admin.py syncdb --migrate --settings regluit.settings.prod
sudo /etc/init.d/apache2 restart
sudo /etc/init.d/celeryd restart

View File

@ -1,4 +1,5 @@
{% extends "base.html" %}
{% load endless %}
{% block title %} — {{ supporter.username }}{% endblock %}
@ -231,7 +232,8 @@ how do I integrate the your wishlist thing with the tabs thing?
Nudge, nudge, say no more.
{% endifequal %}
{% else %}
{% for work in wishlist.works.all %}
{% paginate 20 works %}
{% for work in works %}
<!-- classify which tab depending on work.last_campaign_status -->
{% if work.last_campaign_status == 'SUCCESSFUL' %}
<div class="listview tabs tabs-1">
@ -350,6 +352,11 @@ how do I integrate the your wishlist thing with the tabs thing?
</div>
</div>
{% endfor %}
<br>
<hr>
<div class="pagination content-block-heading">
{% show_pages %}
</div>
{% endifequal %}
</div>
</div>

View File

@ -160,6 +160,7 @@ def rh_admin(request):
def supporter(request, supporter_username, template_name):
supporter = get_object_or_404(User, username=supporter_username)
wishlist = supporter.wishlist
works = wishlist.works.all()
backed = 0
backing = 0
transet = Transaction.objects.all().filter(user = supporter)
@ -238,6 +239,7 @@ def supporter(request, supporter_username, template_name):
context = {
"supporter": supporter,
"wishlist": wishlist,
"works": works,
"backed": backed,
"backing": backing,
"wished": wished,

View File

@ -16,3 +16,4 @@ oauth2
mechanize
pyzotero
freebase
django-endless-pagination

View File

@ -108,6 +108,7 @@ INSTALLED_APPS = (
'social_auth',
'tastypie',
'djcelery',
'endless_pagination',
)
# A sample logging configuration. The only tangible logging

View File

@ -296,3 +296,21 @@ div.content-block-content .cols3 .column {
#footer .column li a {
color: #6994a3;
}
.pagination {
width: 100%;
text-align: center;
margin-top: 20px;
}
.pagination .endless_page_link {
font-size: 16pt;
border: thin #eeeeee solid;
font-weight: normal;
margin: 5px;
}
.pagination .endless_page_current {
font-size: 16pt;
border: thin #eeeeee solid;
font-weight: normal;
margin: 5px;
background-color: #edf3f4;
}

View File

@ -3,12 +3,12 @@ which overrides display: none in the stylesheet. Sneaky! */
$(document).ready(function(){
$('#toggle-list').click(function(){
$('.panelview').addClass("listview").removeClass("panelview");
$j(this).css({opacity: 1});
$(this).css({opacity: 1});
$('#toggle-panel').css({opacity: .2});
});
$('#toggle-panel').click(function(){
$('.listview').addClass("panelview").removeClass("listview");
$j(this).css({opacity: 1});
$(this).css({opacity: 1});
$('#toggle-list').css({opacity: .2});
});
});

View File

@ -316,3 +316,23 @@ div.content-block-content {
}
}
}
.pagination {
width: 100%;
text-align: center;
margin-top: 20px;
.endless_page_link {
font-size: 16pt;
border: thin #eeeeee solid;
font-weight: normal;
margin: 5px;
}
.endless_page_current {
font-size: 16pt;
border: thin #eeeeee solid;
font-weight: normal;
margin: 5px;
background-color:@pale-blue;
}
}