diff --git a/core/feeds.py b/core/feeds.py index 64abeb7b..002ba72b 100644 --- a/core/feeds.py +++ b/core/feeds.py @@ -15,7 +15,7 @@ class SupporterWishlistFeed(Feed): return "Latest wishbooks for %s on unglue.it" % obj.username def link(self, obj): - return "/%s/feed/" % obj.username + return "/supporter/%s/feed/" % obj.username def item_title(self, item): return "%s" % item.title @@ -24,4 +24,4 @@ class SupporterWishlistFeed(Feed): return "/work/%s" % item.id def items(self, obj): - return obj.wishlist.works.all().order_by('-id')[:5] \ No newline at end of file + return obj.wishlist.works.all().order_by('-id')[:100] \ No newline at end of file diff --git a/core/models.py b/core/models.py index 92809ae8..9f6c210b 100755 --- a/core/models.py +++ b/core/models.py @@ -18,9 +18,11 @@ from django.db import models from django.db.models import Q, get_model from django.contrib.auth.models import User from django.contrib.sites.models import Site +from django.core.urlresolvers import reverse from django.conf import settings from django.utils.translation import ugettext_lazy as _ + import regluit import regluit.core.isbn from regluit.core.signals import successful_campaign, unsuccessful_campaign, wishlist_added @@ -534,9 +536,28 @@ class Campaign(models.Model): @property def success_date(self): if self.status == 'SUCCESSFUL': - return self.actions.filter(type='succeeded')[0].timestamp + try: + return self.actions.filter(type='succeeded')[0].timestamp + except: + return '' return '' + + @property + def countdown(self): + from math import ceil + time_remaining = self.deadline - now() + countdown = "" + if time_remaining.days: + countdown = "%s days" % str(time_remaining.days + 1) + elif time_remaining.seconds > 3600: + countdown = "%s hours" % str(time_remaining.seconds/3600 + 1) + elif time_remaining.seconds > 60: + countdown = "%s minutes" % str(time_remaining.seconds/60 + 1) + else: + countdown = "Seconds" + + return countdown class Identifier(models.Model): # olib, ltwk, goog, gdrd, thng, isbn, oclc, olwk, olib, gute, glue @@ -821,6 +842,9 @@ class Work(models.Model): except: return False + def get_absolute_url(self): + return reverse('work', args=[str(self.id)]) + class Author(models.Model): created = models.DateTimeField(auto_now_add=True) name = models.CharField(max_length=500) diff --git a/core/signals.py b/core/signals.py index 8200b724..ea28b99d 100644 --- a/core/signals.py +++ b/core/signals.py @@ -249,7 +249,7 @@ def handle_wishlist_added(supporter, work, **kwargs): notification.send([claim[0].user], "new_wisher", { 'supporter': supporter, 'work': work, - 'base_url': settings.BASE_URL, + 'base_url': settings.BASE_URL_SECURE, }, True) from regluit.core.tasks import emit_notifications @@ -269,13 +269,13 @@ def handle_wishlist_near_deadline(campaign, **kwargs): notification.send(pledgers, "wishlist_near_deadline", { 'campaign': campaign, - 'domain': settings.BASE_URL, + 'domain': settings.BASE_URL_SECURE, 'pledged': True, }, True) notification.send(nonpledgers, "wishlist_near_deadline", { 'campaign': campaign, - 'domain': settings.BASE_URL, + 'domain': settings.BASE_URL_SECURE, 'pledged': False, }, True) diff --git a/core/sitemaps.py b/core/sitemaps.py new file mode 100644 index 00000000..b676d79d --- /dev/null +++ b/core/sitemaps.py @@ -0,0 +1,37 @@ +from django.contrib.sitemaps import Sitemap +from django.core.urlresolvers import reverse +from regluit.core.models import Work, Edition + +class WorkSitemap(Sitemap): + protocol = 'https' + limit = 10000 + + def items(self): + return Work.objects.all() + + def priority(self,work): + if work.last_campaign(): + return '1.0' + if work.num_wishes>1000: + return '0.8' + if work.num_wishes>100: + return '0.6' + if work.num_wishes>10: + return '0.4' + if work.num_wishes>1: + return '0.3' + if work.num_wishes==1: + return '0.2' + if work.num_wishes==0: + return '0.1' + return '0.1' + +class PublisherSitemap(Sitemap): + priority = 0.2 + protocol = 'https' + + def items(self): + return Edition.objects.exclude(publisher__isnull=True).exclude(publisher="").order_by('publisher').values('publisher').distinct() + + def location(self, pub): + return reverse("bypub_list",args=[pub['publisher']]) diff --git a/frontend/templates/about.html b/frontend/templates/about.html index 155e2e23..84bdcd85 100644 --- a/frontend/templates/about.html +++ b/frontend/templates/about.html @@ -2,7 +2,7 @@ {% block title %} Everything You Always Wanted to Know {% endblock %} {% block doccontent %}

About

-

Unglue.it is a service provided by Gluejar, Inc. It's a place for individuals and institutions to join together to liberate specific ebooks and other types of digital content by paying rights holders to relicense their works under Creative Commons licenses.

+

Unglue.it is a service provided by Gluejar, Inc. It's a place for individuals and institutions to join together to liberate specific ebooks and other types of digital content by paying rights holders to relicense their works under Creative Commons licenses.

What does this mean?