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

pull/1/head
Raymond Yee 2012-03-08 10:35:47 -08:00
commit eed1c39a5b
18 changed files with 227 additions and 110 deletions

View File

@ -13,8 +13,8 @@
}
</style>
<script type="text/javascript" src={{ jquery_home }} ></script>
<script type="text/javascript" src={{ jquery_ui_home }}></script>
<script type="text/javascript" src="{{ jquery_home }}" ></script>
<script type="text/javascript" src="{{ jquery_ui_home }}"></script>
<!-- toggle to panelview state instead of listview default -->
<script type="application/x-javascript">

View File

@ -17,7 +17,7 @@
<link REL="SHORTCUT ICON" HREF="/static/images/favicon.ico">
{% block extra_css %}{% endblock %}
{% block base_js %}
<script type="text/javascript" src={{ jquery_home }}></script>
<script type="text/javascript" src="{{ jquery_home }}"></script>
{% endblock %}
{% block extra_js %}
{% endblock %}
@ -80,46 +80,48 @@ Welcome to the alpha version of Unglue.It. This site is a preview of our full f
<div id="footer">
<div class="js-main">
<div class="column">
<span>About unglue.it</span>
<ul>
<li><a href="{{ abouturl }}">About</a></li>
<li><a href="http://www.gluejar.com/Blog">Blog</a></li>
<li><a href="{{ pressurl }}">Press</a></li>
<li><a href="http://eepurl.com/fKLfI">Newsletter</a></li>
</ul>
<span>About unglue.it</span>
<ul>
<li><a href="{{ abouturl }}">About</a></li>
<li><a href="http://www.gluejar.com/Blog">Blog</a></li>
<li><a href="{{ pressurl }}">Press</a></li>
<li><a href="http://eepurl.com/fKLfI">Newsletter</a></li>
</ul>
</div>
<div class="column">
<span>Your account</span>
<ul>
{% if user.is_authenticated %}
<li><a href="{{editurl}}">Account Settings</a></li>
{% endif %}
<li><a href="{{rhtoolsurl}}">Rights Holder Tools</a></li>
<li><a href="{{privacyurl}}">Privacy</a></li>
<li><a href="{{termsurl}}">Terms and Conditions</a></li>
{% if user.is_staff %}
<li><a href="{{adminurl}}">Unglue.it Administration</a></li>
{% endif %}
</ul>
<span>Your account</span>
<ul>
{% if user.is_authenticated %}
<li><a href="{{editurl}}">Account Settings</a></li>
{% endif %}
<li><a href="{{rhtoolsurl}}">Rights Holder Tools</a></li>
<li><a href="{{privacyurl}}">Privacy</a></li>
<li><a href="{{termsurl}}">Terms and Conditions</a></li>
{% if user.is_staff %}
<li><a href="{{adminurl}}">Unglue.it Administration</a></li>
{% endif %}
</ul>
</div>
<div class="column">
<span>Help</span>
<ul>
<li><a href="{{faqurl}}">General FAQ</a></li>
<li><a href="/faq/rightsholders/">Rights Holder FAQ</a></li>
<li><a href="{% url api_help %}">API</a></li>
<li><a href="mailto:support@gluejar.com">support@gluejar.com</a>
</ul>
<span>Help</span>
<ul>
<li><a href="{{faqurl}}">General FAQ</a></li>
<li><a href="/faq/rightsholders/">Rights Holder FAQ</a></li>
<li><a href="{% url api_help %}">API</a></li>
<li><a href="mailto:support@gluejar.com">support@gluejar.com</a>
</ul>
</div>
<div class="column">
<span>Contact</span>
<ul>
<li>General inquiries</li>
<li><a href="mailto:faq@gluejar.com">faq@gluejar.com</a></li>
<li>Rights Holders</li>
<li><a href="mailto:rights@gluejar.com">rights@gluejar.com</a></li>
</ul>
<span>Contact</span>
<ul>
<li>General inquiries</li>
<li><a href="mailto:faq@gluejar.com">faq@gluejar.com</a></li>
<li>Rights Holders</li>
<li><a href="mailto:rights@gluejar.com">rights@gluejar.com</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
{% block counter %}

View File

@ -3,7 +3,7 @@
{% block extra_extra_head %}
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/themes/ui-lightness/jquery-ui.css" type="text/css" media="screen">
{{ form.media.css }}
<script type="text/javascript" src={{ jquery_ui_home }}></script>
<script type="text/javascript" src="{{ jquery_ui_home }}"></script>
{{ form.media.js }}
{% endblock %}

View File

@ -13,7 +13,7 @@ location.hash = "#2";
</script>
<script type="text/javascript" src="/static/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/static/js/wishlist.js"></script>
<script type="text/javascript" src={{ jquery_ui_home }}></script>
<script type="text/javascript" src="{{ jquery_ui_home }}"></script>
<script type="text/javascript" src="/static/js/greenpanel.js"></script>
<script type="text/javascript" src="/static/js/toggle.js"></script>
{% endblock %}

View File

@ -11,7 +11,7 @@ comments rss?
{% endblock %}
{% block extra_head %}
<script type="text/javascript" src="/static/js/wishlist.js"></script>
<script type="text/javascript" src={{ jquery_ui_home }}></script>
<script type="text/javascript" src="{{ jquery_ui_home }}"></script>
<script type="text/javascript" src="/static/js/greenpanel.js"></script>
<script type="text/javascript" src="/static/js/toggle.js"></script>
<script type="text/javascript" src="/static/js/tabs.js"></script>

View File

@ -2,7 +2,7 @@
{% load truncatechars %}
{% block extra_js %}
<script type="text/javascript" src={{ jquery_ui_home }}></script>
<script type="text/javascript" src="{{ jquery_ui_home }}"></script>
{% endblock %}
{% block extra_css %}

View File

@ -19,7 +19,7 @@
<div class="user-block2">
<div class="block-inner">
<label class="title">Spread the Word</label>
<a href="https://www.facebook.com/sharer/sharer.php?src=bm&u={{request.build_absolute_uri}}"><img src="/static/images/supporter_icons/facebook_square.png" class="spread_the_word" alt="Facebook" title="Facebook" /></a>
<a href="https://www.facebook.com/sharer/sharer.php?src=bm&amp;u={{request.build_absolute_uri|urlencode }}"><img src="/static/images/supporter_icons/facebook_square.png" class="spread_the_word" alt="Facebook" title="Facebook" /></a>
<a href="https://twitter.com/share"><img src="/static/images/supporter_icons/twitter_square.png" alt="tweeter" title="Twitter" class="spread_the_word" /></a>
</div>
</div>
@ -29,7 +29,7 @@
<div class="movingrightalong"></div>
<div class="quicktour"><span class="highlight">Unglue.it offers a win-win solution: Crowdfunding.</span> We run pledge campaigns for books; you chip in. When, together, we've reached the goal, we'll reward the book's creators and issue an unglued ebook.</div>
<div class="movingrightalong"></div>
<div class="quicktour last"><a href="https://creativecommons.org/">Creative Commons</a> licensing means everyone, everywhere can read and share the unglued book freely and legally. <span class="highlight">You've given your favorite book to the world.</span>
<div class="quicktour last"><a href="https://creativecommons.org/">Creative Commons</a> licensing means everyone, everywhere can read and share the unglued book - freely and legally. <span class="highlight">You've given your favorite book to the world.</span>
{% if suppress_search_box %}
<div class="signup" id="highlighter">Sign up below. <img src="/static/images/landingpage/signmeup-arrow.png"></div>
{% else %}

View File

@ -0,0 +1,83 @@
{% extends "basedocumentation.html" %}
{% block title %} Metrics {% endblock %}
{% block doccontent %}
<h2>Users</h2>
<dl>
<dt> How many ungluers have registered?</dt>
<dd>
<ul>
<li>{{ users.today.count }} have registered today. They are
<ul>{% for user in users.today %}
<li><a href="{% url supporter user.username %}">{{user.username}}</a></li>
{% endfor %}</ul>
<br />{{ wishlists.today.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>
<li>{{ users.month.count }} have registered in this month.
<br />{{ wishlists.month.count }} of them have 1 or more items on a wishlist.
</li>
<li>{{ users.all.count }} have registered in total.
<br />{{ wishlists.all.count }} of them have 1 or more items on a wishlist.
</li>
</ul>
</dd>
</dl>
<h2>Works</h2>
<dl>
<dt> How many works have been added to Unglue.it?</dt>
<dd>
<ul>
<li>{{ works.today.count }} have been added today. They are
<ul>{% for work in users_today %}
<li><a href="{% url work work.id %}">{{work.title}}</a></li>
{% endfor %}</ul>
</li>
<li>{{ works.days7.count }} have been added in the past 7 days.
</li>
<li>{{ works.month.count }} have been added in this month.
</li>
<li>{{ works.all.count }} have been added in total.
</li>
</ul>
</dd>
<dt> How often have the works been wished?</dt>
<dd>
<ul>
<li>{{ works.wishedby50.count }} have been wished by more than 50 ungluers.
</li>
<li>{{ works.wishedby20.count }} have been wished by more than 20 ungluers.
</li>
<li>{{ works.wishedby10.count }} have been wished by more than 10 ungluers.
</li>
<li>{{ works.wishedby5.count }} have been wished by more than 5 ungluers.
</li>
<li>{{ works.wishedby2.count }} have been wished by more than 2 ungluers.
</li>
</ul>
</dd>
</dl>
<h2>Ebooks</h2>
<dl>
<dt> How many ebooks have been added to Unglue.it?</dt>
<dd>
<ul>
<li>{{ ebooks.today.count }} have been added today. They are
<ul>{% for work in users_today %}
<li><a href="{% url work ebook.edition.work.id %}">{{ebook.edition.work.title}}</a></li>
{% endfor %}</ul>
</li>
<li>{{ ebooks.days7.count }} have been added in the past 7 days.
</li>
<li>{{ ebooks.month.count }} have been added in this month.
</li>
<li>{{ ebooks.all.count }} have been added in total.
</li>
</ul>
</dd>
</dl>
{% endblock %}

View File

@ -165,6 +165,11 @@ For more background, read our president Eric Hellman's thoughts on <a href="http
<a name="video"></a><h2>Video</h2>
<div class="pressvideos">
<div>
<iframe width="480" height="274" src="http://www.youtube-nocookie.com/embed/36o0o9aGbKc?rel=0" frameborder="0" allowfullscreen></iframe><br />
<I>February 2012</I><br />
Eric Hellman on the <a href="http://oreilly.com/toc/">Tools of Change</a> podcast.
</div>
<div>
<iframe width="480" height="274" src="http://www.youtube-nocookie.com/embed/YNGPCR-iM24?rel=0" frameborder="0" allowfullscreen></iframe><br />
<I>November 2011</I><br />

View File

@ -3,7 +3,7 @@
{% block extra_extra_head %}
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/themes/ui-lightness/jquery-ui.css" type="text/css" media="screen">
<link href="/static/css/dj.selectable.css" type="text/css" media="all" rel="stylesheet" />
<script type="text/javascript" src={{ jquery_ui_home }}></script>
<script type="text/javascript" src="{{ jquery_ui_home }}"></script>
<script type="text/javascript" src="/static/js/jquery.dj.selectable.js"></script>
{% endblock %}

View File

@ -3,7 +3,7 @@
{% block extra_extra_head %}
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/themes/ui-lightness/jquery-ui.css" type="text/css" media="screen">
{{ form.media.css }}
<script type="text/javascript" src={{ jquery_ui_home }} ></script>
<script type="text/javascript" src="{{ jquery_ui_home }}" ></script>
{{ form.media.js }}
{% endblock %}

View File

@ -9,11 +9,10 @@
<link type="text/css" rel="stylesheet" href="/static/css/book_list.css" />
<link type="text/css" rel="stylesheet" href="/static/css/book_panel.css" />
{% endblock %}
{% block extra_head %}
{% block extra_js %}
<script type="text/javascript" src="/static/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/static/js/wishlist.js"></script>
<script type="text/javascript" src={{ jquery_ui_home }}></script>
<script type="text/javascript" src="{{ jquery_ui_home }}"></script>
<script type="text/javascript" src="/static/js/greenpanel.js"></script>
<script type="text/javascript" src="/static/js/import_books.js"></script>
<script type="text/javascript" src="/static/js/counter.js"></script>
@ -49,20 +48,16 @@
<script type="text/javascript" src="/static/js/toggle.js"></script>
<script type="text/javascript" src="/static/js/tabs.js"></script>
{% endif %}
{% endblock %}
{% block extra_js %}
<script>
<!-- highlight LT/GR add functions when people click on import divs -->
<script type="text/javascript">
var $j = jQuery.noConflict();
$j(document).ready(function(){
var highlighter = $j('#loadlt');
var target = $j('#connectlt');
highlighter.click(function(){
target.css({"background": "#8dc63f"}).animate(
{backgroundColor: "white"}, 1500
);
});
});
function highlightTarget(targetdiv) {
var target = $j(targetdiv);
target.css({"background": "#8dc63f"}).animate(
{backgroundColor: "white"}, 1500
);
};
</script>
{% endblock %}
@ -226,7 +221,7 @@ there's no tab for seeing ALL my books, only the filters! huh.
</div>
</form>
{% else %}
<div id="loadgr"><div>Connect your GoodReads account to import from GoodReads.</div></div>
<div id="loadgr" onclick="highlightTarget('#connectgr'); return false;"><div>Connect your GoodReads account to import from GoodReads.</div></div>
{% endif %}
{% if librarything_id %}
<form id="librarything_load" method="post" action="#">
@ -234,7 +229,7 @@ there's no tab for seeing ALL my books, only the filters! huh.
<div id="loadlt"><input type="submit" id="librarything_input" value="Add your LibraryThing library" /></div>
</form>
{% else %}
<div id="loadlt"><div>Add your LibraryThing ID to import from LibraryThing.</div></div>
<div id="loadlt" onclick="highlightTarget('#connectlt'); return false;"><div>Add your LibraryThing ID to import from LibraryThing.</div></div>
{% endif %}
</div>
</div>

View File

@ -10,7 +10,7 @@
{% block extra_head %}
<script type="text/javascript" src="/static/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/static/js/wishlist.js"></script>
<script type="text/javascript" src={{ jquery_ui_home }}></script>
<script type="text/javascript" src="{{ jquery_ui_home }}"></script>
<script type="text/javascript" src="/static/js/greenpanel.js"></script>
<script type="text/javascript" src="/static/js/toggle.js"></script>
<script type="text/javascript" src="/static/js/tabs.js"></script>

View File

@ -7,8 +7,8 @@
{% endblock %}
{% block base_js %}
<script type="text/javascript" src={{ jquery_home }}></script>
<script type="text/javascript" src={{ jquery_ui_home }}></script>
<script type="text/javascript" src="{{ jquery_home }}"></script>
<script type="text/javascript" src="{{ jquery_ui_home }}"></script>
<script type="text/javascript" src="/static/js/wishlist.js"></script>
<script type="text/javascript" src="/static/js/tabs4.js"></script>
<script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>

View File

@ -9,9 +9,9 @@
{% endblock %}
{% block extra_head %}
<script type="text/javascript" src="/static/js/wishlist.js"></script>
<script type="text/javascript" src={{ jquery_home }}></script>
<script type="text/javascript" src="{{ jquery_home }}"></script>
<script type="text/javascript" src="/static/js/jquery.cookie.js"></script>
<script type="text/javascript" src={{ jquery_ui_home }}></script>
<script type="text/javascript" src="{{ jquery_ui_home }}"></script>
<script type="text/javascript" src="/static/js/greenpanel.js"></script>
<script type="text/javascript" src="/static/js/toggle.js"></script>
<script type="text/javascript" src="/static/js/tabs.js"></script>

View File

@ -64,6 +64,8 @@ class PageTests(TestCase):
self.assertEqual(r.status_code, 200)
r = anon_client.get("/search/?q=sverige")
self.assertEqual(r.status_code, 200)
r = anon_client.get("/info/metrics.html")
self.assertEqual(r.status_code, 200)
class GoogleBooksTest(TestCase):

View File

@ -7,7 +7,7 @@ from django.conf import settings
from regluit.core.models import Campaign
from regluit.frontend.views import CampaignFormView, GoodreadsDisplayView, LibraryThingView, PledgeView, PledgeCompleteView, PledgeCancelView, FAQView
from regluit.frontend.views import CampaignListView, DonateView, WorkListView, UngluedListView
from regluit.frontend.views import CampaignListView, DonateView, WorkListView, UngluedListView, InfoPageView
urlpatterns = patterns(
"regluit.frontend.views",
@ -61,6 +61,7 @@ urlpatterns = patterns(
url(r"^about/$", TemplateView.as_view(template_name="about.html"),
name="about"),
url(r"^comments/$", "comment", name="comment"),
url(r"^info/(?P<template_name>[\w\.]*)$", InfoPageView.as_view()),
)
if not settings.IS_PREVIEW:

View File

@ -53,34 +53,36 @@ from regluit.payment.models import Transaction
logger = logging.getLogger(__name__)
def slideshow(max):
ending = models.Campaign.objects.filter(status='ACTIVE').order_by('deadline')
count = ending.count()
is_preview = settings.IS_PREVIEW
i = 0
j = 0
if is_preview:
# on the preview site there are no active campaigns, so we should show most-wished books instead
worklist = models.Work.objects.order_by('-num_wishes')[:count]
else:
worklist = []
while i<max and count>0:
worklist.append(ending[j].work)
i += 1
j += 1
if j == count:
j = 0
return worklist
def home(request):
if request.user.is_authenticated():
return HttpResponseRedirect(reverse('supporter',
args=[request.user.username]))
ending = models.Campaign.objects.filter(status='ACTIVE').order_by('deadline')
j=0
i=0
works=[]
works2=[]
count=ending.count()
# on the preview site there are no active campaigns, so we should show most-wished books instead
is_preview = settings.IS_PREVIEW
if is_preview:
worklist = models.Work.objects.order_by('-num_wishes')
works = worklist[:6]
works2 = worklist[6:12]
else:
while i<12 and count>0:
if i<6:
works.append(ending[j].work)
else:
works2.append(ending[j].work)
i += 1
j += 1
if j == count:
j = 0
worklist = slideshow(12)
works = worklist[:6]
works2 = worklist[6:12]
events = models.Wishes.objects.order_by('-created')[0:2]
return render(request, 'home.html', {'suppress_search_box': True, 'works': works, 'works2': works2, 'events': events})
@ -769,30 +771,14 @@ def supporter(request, supporter_username, template_name):
backing = works_active.count()
wished = works_wished.count()
else:
ending = models.Campaign.objects.filter(status='ACTIVE').order_by('deadline')
count = ending.count()
i = 0
j = 0
if is_preview:
worklist = models.Work.objects.order_by('-num_wishes')
works = worklist[:4]
works2 = worklist[4:8]
else:
while i<8 and count>0:
if i<4:
works.append(ending[j].work)
else:
works2.append(ending[j].work)
i += 1
j += 1
if j == count:
j = 0
else:
backed = 0
backing = 0
wished = 0
worklist = slideshow(8)
works = worklist[:4]
works2 = worklist[4:8]
date = supporter.date_joined.strftime("%B %d, %Y")
@ -1002,6 +988,49 @@ class CampaignFormView(FormView):
logger.info("CampaignFormView paypal: Error " + str(t.reference))
return HttpResponse(response)
class InfoPageView(TemplateView):
def get_template_names(self, **kwargs):
if self.kwargs['template_name']:
return (self.kwargs['template_name'])
else:
return ('metrics.html')
def get_context_data(self, **kwargs):
users = User.objects
users.today = users.filter(date_joined__range = (datetime.date.today(), datetime.datetime.now()))
users.days7 = users.filter(date_joined__range = (datetime.date.today()-datetime.timedelta(days=7), datetime.datetime.now()))
users.year = users.filter(date_joined__year = datetime.date.today().year)
users.month = users.year.filter(date_joined__month = datetime.date.today().month)
works = models.Work.objects
works.today = works.filter(created__range = (datetime.date.today(), datetime.datetime.now()))
works.days7 = works.filter(created__range = (datetime.date.today()-datetime.timedelta(days=7), datetime.datetime.now()))
works.year = works.filter(created__year = datetime.date.today().year)
works.month = works.year.filter(created__month = datetime.date.today().month)
works.wishedby2 = works.filter(num_wishes__gte = 2)
works.wishedby20 = works.filter(num_wishes__gte = 20)
works.wishedby5 = works.filter(num_wishes__gte = 5)
works.wishedby50 = works.filter(num_wishes__gte = 50)
works.wishedby10 = works.filter(num_wishes__gte = 10)
works.wishedby100 = works.filter(num_wishes__gte = 100)
ebooks = models.Ebook.objects
ebooks.today = ebooks.filter(created__range = (datetime.date.today(), datetime.datetime.now()))
ebooks.days7 = ebooks.filter(created__range = (datetime.date.today()-datetime.timedelta(days=7), datetime.datetime.now()))
ebooks.year = ebooks.filter(created__year = datetime.date.today().year)
ebooks.month = ebooks.year.filter(created__month = datetime.date.today().month)
wishlists= models.Wishlist.objects.exclude(wishes__isnull=True)
wishlists.today = wishlists.filter(created__range = (datetime.date.today(), datetime.datetime.now()))
wishlists.days7 = wishlists.filter(created__range = (datetime.date.today()-datetime.timedelta(days=7), datetime.datetime.now()))
wishlists.year = wishlists.filter(created__year = datetime.date.today().year)
wishlists.month = wishlists.year.filter(created__month = datetime.date.today().month)
return {
'users': users,
'works': works,
'ebooks': ebooks,
'wishlists': wishlists,
}
class FAQView(TemplateView):
template_name = "faq.html"
def get_context_data(self, **kwargs):