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

Conflicts:
	frontend/templates/press.html
pull/1/head
Andromeda Yelton 2012-05-21 10:38:08 -04:00
commit 690bd76357
9 changed files with 105 additions and 44 deletions

View File

@ -23,7 +23,7 @@
<a href="/api/v1/campaign/?format=json&amp;api_key={{api_key}}&amp;username={{user.username}}">{{base_url}}/api/v1/campaign/?format=json&amp;api_key={api_key}&amp;username={username}</a>
<h3>Identifier Resolution</h3>
<p>JSON to get work/edition data for an isbn</p>
<a href="/api/v1/identifier/?format=json&amp;api_key={{api_key}}&amp;type=isbn&amp;value=9780441012039">{{base_url}}/api/v1/identifier/?format=json&amp;api_key={api_key}&amp;ype=isbn&amp;value=9780441012039</a>
<a href="/api/v1/identifier/?format=json&amp;api_key={{api_key}}&amp;username={{user.username}}&amp;type=isbn&amp;value=9780441012039">{{base_url}}/api/v1/identifier/?format=json&amp;api_key={api_key}&amp;username={username}&amp;ype=isbn&amp;value=9780441012039</a>
<p> In addition to isbn, you can use 'goog' if you have a google books id, and 'oclc' for oclc numbers.</p>
{% endif %}

View File

@ -70,6 +70,16 @@ class ApiTests(TestCase):
self.assertEqual(j['meta']['logged_in_username'], None)
self.assertEqual(j['objects'][0]['in_wishlist'], False)
def test_identifier_lookup(self):
r = self.client.get('/api/v1/identifier/', data={
'format': 'json',
'value': regluit.core.isbn.convert_10_to_13('0441012035'),
'type': 'isbn',
'username': self.user.username,
'api_key': self.user.api_key.key
})
self.assertEqual(r.status_code, 200)
def test_logged_in_user_info(self):
# login and see if adding a work to the users wishlist causes
# it to show up as in_wishlist in the campaign info

View File

@ -111,9 +111,10 @@ class CampaignAction(models.Model):
type = models.CharField(max_length=15)
comment = models.TextField(null=True, blank=True)
campaign = models.ForeignKey("Campaign", related_name="actions", null=False)
class Campaign(models.Model):
LICENSE_CHOICES = (('CC BY-NC-ND','CC BY-NC-ND'),
class CCLicense():
CCCHOICES = (
('CC BY-NC-ND','CC BY-NC-ND'),
('CC BY-ND','CC BY-ND'),
('CC BY','CC BY'),
('CC BY-NC','CC BY-NC'),
@ -121,6 +122,53 @@ class Campaign(models.Model):
( 'CC BY-SA','CC BY-SA'),
( 'CC0','CC0'),
)
CHOICES = CCCHOICES+(('PD-US', 'Public Domain, US'),)
@classmethod
def url(klass, license):
if license == 'PD-US':
return 'http://creativecommons.org/publicdomain/mark/1.0/'
elif license == 'CC0':
return 'http://creativecommons.org/publicdomain/zero/1.0/'
elif license == 'CC BY':
return 'http://creativecommons.org/licenses/by/3.0/'
elif license == 'CC BY-NC-ND':
return 'http://creativecommons.org/licenses/by-nc-nd/3.0/'
elif license == 'CC BY-NC-SA':
return 'http://creativecommons.org/licenses/by-nc-sa/3.0/'
elif license == 'CC BY-NC':
return 'http://creativecommons.org/licenses/by-nc/3.0/'
elif license == 'CC BY-SA':
return 'http://creativecommons.org/licenses/by-sa/3.0/'
elif license == 'CC BY-ND':
return 'http://creativecommons.org/licenses/by-nd/3.0/'
else:
return ''
@classmethod
def badge(klass,license):
if license == 'PD-US':
return 'https://i.creativecommons.org/p/mark/1.0/88x31.png'
elif license == 'CC0':
return 'https://i.creativecommons.org/p/zero/1.0/88x31.png'
elif license == 'CC BY':
return 'https://i.creativecommons.org/l/by/3.0/88x31.png'
elif license == 'CC BY-NC-ND':
return 'https://i.creativecommons.org/l/by-nc-nd/3.0/88x31.png'
elif license == 'CC BY-NC-SA':
return 'https://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png'
elif license == 'CC BY-NC':
return 'https://i.creativecommons.org/l/by-nc/3.0/88x31.png'
elif license == 'CC BY-SA':
return 'https://i.creativecommons.org/l/by-sa/3.0/88x31.png'
elif license == 'CC BY-ND':
return 'https://i.creativecommons.org/l/by-nd/3.0/88x31.png'
else:
return ''
class Campaign(models.Model):
LICENSE_CHOICES = CCLicense.CCCHOICES
created = models.DateTimeField(auto_now_add=True)
name = models.CharField(max_length=500, null=True, blank=False)
description = models.TextField(null=True, blank=False)
@ -269,13 +317,22 @@ class Campaign(models.Model):
def rightsholder(self):
"""returns the name of the rights holder for an active or initialized campaign"""
try:
if self.status=='ACTIVE' or self.status=='INITIALIZED':
q = Q(status='ACTIVE') | Q(status='INITIALIZED')
rh = self.work.claim.filter(q)[0].rights_holder.rights_holder_name
return rh
if self.status=='ACTIVE' or self.status=='INITIALIZED':
q = Q(status='ACTIVE') | Q(status='INITIALIZED')
rh = self.work.claim.filter(q)[0].rights_holder.rights_holder_name
return rh
except:
pass
return ''
@property
def license_url(self):
return CCLicense.url(self.license)
@property
def license_badge(self):
return CCLicense.badge(self.license)
class Identifier(models.Model):
# olib, ltwk, goog, gdrd, thng, isbn, oclc, olwk, olib, gute, glue
@ -610,15 +667,7 @@ class WasWork(models.Model):
class Ebook(models.Model):
FORMAT_CHOICES = (('pdf','PDF'),( 'epub','EPUB'), ('html','HTML'), ('text','TEXT'), ('mobi','MOBI'))
RIGHTS_CHOICES = (('PD-US', 'Public Domain, US'),
('CC BY-NC-ND','CC BY-NC-ND'),
('CC BY-ND','CC BY-ND'),
('CC BY','CC BY'),
('CC BY-NC','CC BY-NC'),
( 'CC BY-NC-SA','CC BY-NC-SA'),
( 'CC BY-SA','CC BY-SA'),
( 'CC0','CC0'),
)
RIGHTS_CHOICES = CCLicense.CHOICES
url = models.URLField(max_length=1024)
created = models.DateTimeField(auto_now_add=True)
format = models.CharField(max_length=25, choices = FORMAT_CHOICES)
@ -635,27 +684,9 @@ class Ebook(models.Model):
@property
def rights_badge(self):
my_rights=self.rights
if not my_rights:
return 'https://i.creativecommons.org/p/mark/1.0/88x31.png'
if my_rights == 'PD-US':
return 'https://i.creativecommons.org/p/mark/1.0/88x31.png'
elif my_rights == 'CC0':
return 'https://i.creativecommons.org/p/zero/1.0/88x31.png'
elif my_rights == 'CC BY':
return 'https://i.creativecommons.org/l/by/3.0/88x31.png'
elif my_rights == 'CC BY-NC-ND':
return 'https://i.creativecommons.org/l/by-nc-nd/3.0/88x31.png'
elif my_rights == 'CC BY-NC-SA':
return 'https://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png'
elif my_rights == 'CC BY-NC':
return 'https://i.creativecommons.org/l/by-nc/3.0/88x31.png'
elif my_rights == 'CC BY-SA':
return 'https://i.creativecommons.org/l/by-sa/3.0/88x31.png'
elif my_rights == 'CC BY-ND':
return 'https://i.creativecommons.org/l/by-nd/3.0/88x31.png'
else:
return ''
if self.rights is None :
return CCLicense.badge('PD-US')
return CCLicense.badge(self.rights)
@classmethod
def infer_provider(klass, url):

View File

@ -350,7 +350,11 @@ class CampaignTests(TestCase):
w = Work()
w.save()
c = Campaign(target=D('1000.00'), deadline=datetime(2013, 1, 1), work=w)
c.license = 'CC BY-NC'
c.save()
self.assertEqual(c.license_url, 'http://creativecommons.org/licenses/by-nc/3.0/')
self.assertEqual(c.license_badge, 'https://i.creativecommons.org/l/by-nc/3.0/88x31.png')
def test_campaign_status(self):

View File

@ -241,7 +241,21 @@ def getManageCampaignForm ( instance, data=None, *args, **kwargs ):
new_license = self.cleaned_data['license']
if self.instance:
if self.instance.status == 'ACTIVE' and self.instance.license != new_license:
raise forms.ValidationError(_('The license for an ACTIVE campaign cannot be changed.'))
# should only allow change to a less restrictive license
if self.instance.license == 'CC BY-ND' and new_license in ['CC BY-NC-ND','CC BY-NC-SA','CC BY-NC']:
raise forms.ValidationError(_('The proposed license for an ACTIVE campaign may not add restrictions.'))
elif self.instance.license == 'CC BY' and new_license != 'CC0':
raise forms.ValidationError(_('The proposed license for an ACTIVE campaign may not add restrictions.'))
elif self.instance.license == 'CC BY-NC' and new_license in ['CC BY-NC-ND','CC BY-NC-SA','CC BY-SA','CC BY-ND']:
raise forms.ValidationError(_('The proposed license for an ACTIVE campaign may not add restrictions.'))
elif self.instance.license == 'CC BY-ND' and new_license in ['CC BY-NC-ND','CC BY-NC-SA','CC BY-SA','CC BY-NC']:
raise forms.ValidationError(_('The proposed license for an ACTIVE campaign may not add restrictions.'))
elif self.instance.license == 'CC BY-SA' and new_license in ['CC BY-NC-ND','CC BY-NC-SA','CC BY-ND','CC BY-NC']:
raise forms.ValidationError(_('The proposed license for an ACTIVE campaign may not add restrictions.'))
elif self.instance.license == 'CC BY-NC-SA' and new_license in ['CC BY-NC-ND','CC BY-ND']:
raise forms.ValidationError(_('The proposed license for an ACTIVE campaign may not add restrictions.'))
elif self.instance.license == 'CC0' :
raise forms.ValidationError(_('The proposed license for an ACTIVE campaign may not add restrictions.'))
return new_license
return ManageCampaignForm(instance = instance, data=data)

View File

@ -169,8 +169,9 @@ Please fix the following before launching your campaign:
${{ form.target.errors }}{{ form.target }}
<h3>License being offered</h3>
<p>If your campaign succeeds, you will be offering your ebook under a <b>{{ campaign.license }}</b> license.</p>
{{ form.license.errors }}<span style="display: none">{{ form.license }}</span>
<p>If your campaign succeeds, you will be offering your ebook under a <b><a href="{{campaign.license_url }}">{{ campaign.license }}</a></b> license.</p>
<p>During a campaign, you may only change the license to remove restrictions. For more info on the licenses you can use, see <a href="http://creativecommons.org/licenses">Creative Commons: About the Licenses</a>.</p></p>
{{ form.license.errors }}<span>{{ form.license }}</span>
<h3>Ending date</h3>
<p>The ending date of your campaign is <b>{{ campaign.deadline }}</b>. Your campaign will conclude on this date or when you meet your target price, whichever is earlier. You may not change the ending date of an active campaign.</p>
{{ form.deadline.errors }}<span style="display: none">{{ form.deadline }}</span>

View File

@ -47,7 +47,7 @@
<dl>
<dt>What?</dt>
<dd>Unglue.it offers a win-win solution to readers, who want to read and share their favorite books conveniently, and rights holders, who want to be rewarded for their work.<br /><br />
We will run <a href="http://en.wikipedia.org/wiki/Crowdfunding">crowdfunding</a> campaigns to raise money for specific, already-published books. When we reach goals set by the rights holders, we'll pay them to unglue their work. They'll issue an electronic edition with a <a href="http://creativecommons.org">Creative Commons</a> license. Our default license, <a href="http://creativecommons.org/licenses/by-nc-nd/3.0/">BY-NC-ND</a>, will make the edition free and legal for everyone to read, copy, and share, noncommercially, worldwide. However, rights holders are welcome to choose any Creative Commons license; some are even less restrictive.<br /><br />
We will run <a href="http://en.wikipedia.org/wiki/Crowdfunding">crowdfunding</a> campaigns to raise money for specific, already-published books. When we reach goals set by the rights holders, we'll pay them to unglue their work. They'll issue an electronic edition with a <a href="http://creativecommons.org">Creative Commons</a> license as specified during the campaign. These licenses will make the edition free and legal for everyone to read, copy, and share, worldwide.<br /><br />
At present, in our alpha phase, we're not running live campaigns (though you may see some fake campaign data for testing purposes). However, most of the other features of the site -- such as searching for books, adding them to your wishlist, and personalizing your user profile -- work. We invite you to try them out and give us feedback.<br /><br />
Once we've fully tested our payment processes and user experience, we'll have a beta launch. At this point we'll announce our founding rights holders, run live campaigns, and invite everyone to join the site.</dd>
<dt>Why?</dt>

View File

@ -21,7 +21,8 @@ $j(document).ready(function() {
next = next.replace(/[\x22\x27\x3c\x3e]/g,'');
$j.cookie('next', next, {path: '/'});
} else if(saved_next!=null){
$j('#link-to-next').html("<a href='"+saved_next+"'> Click to continue after logging in...</a>");
var do_next = $j('#link-to-next');
if (do_next.length) window.location.replace(saved_next);
}
});
</script>

View File

@ -278,7 +278,7 @@ $j(document).ready(function(){
{{ claim.rights_holder.rights_holder_name }}
{% endif %}
{% endfor %}
, has agreed to release <i>{{work.title}}</i> to the world as a Creative Commons licensed ebook ({{ work.last_campaign.license }}) if ungluers can join together to raise ${{ work.last_campaign.target|intcomma }} by {{ work.last_campaign.deadline }}.
, has agreed to release <i>{{work.title}}</i> to the world as a Creative Commons licensed ebook (<a href="{{ work.last_campaign.license_url }}">{{ work.last_campaign.license }}</a>) if ungluers can join together to raise ${{ work.last_campaign.target|intcomma }} by {{ work.last_campaign.deadline }}.
You can help!</p>
<h4>Campaign details: the fine print</h4>