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

pull/1/head
Andromeda Yelton 2011-11-16 15:25:06 -05:00
commit f748bb220e
8 changed files with 257 additions and 10 deletions

View File

@ -0,0 +1,205 @@
# encoding: utf-8
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding field 'UserProfile.pic_url'
db.add_column('core_userprofile', 'pic_url', self.gf('django.db.models.fields.URLField')(default='', max_length=200, blank=True), keep_default=False)
# Adding field 'UserProfile.facebook_id'
db.add_column('core_userprofile', 'facebook_id', self.gf('django.db.models.fields.PositiveIntegerField')(null=True), keep_default=False)
# Adding field 'UserProfile.librarything_id'
db.add_column('core_userprofile', 'librarything_id', self.gf('django.db.models.fields.CharField')(default='', max_length=31, blank=True), keep_default=False)
# Changing field 'CeleryTask.function_args'
db.alter_column('core_celerytask', 'function_args', self.gf('django.db.models.fields.IntegerField')(null=True))
# Adding field 'Claim.status'
db.add_column('core_claim', 'status', self.gf('django.db.models.fields.CharField')(default='pending', max_length=7), keep_default=False)
def backwards(self, orm):
# Deleting field 'UserProfile.pic_url'
db.delete_column('core_userprofile', 'pic_url')
# Deleting field 'UserProfile.facebook_id'
db.delete_column('core_userprofile', 'facebook_id')
# Deleting field 'UserProfile.librarything_id'
db.delete_column('core_userprofile', 'librarything_id')
# Changing field 'CeleryTask.function_args'
db.alter_column('core_celerytask', 'function_args', self.gf('django.db.models.fields.IntegerField')(default=0))
# Deleting field 'Claim.status'
db.delete_column('core_claim', 'status')
models = {
'auth.group': {
'Meta': {'object_name': 'Group'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
},
'auth.permission': {
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
'auth.user': {
'Meta': {'object_name': 'User'},
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
},
'contenttypes.contenttype': {
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
'core.author': {
'Meta': {'object_name': 'Author'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'editions': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'authors'", 'symmetrical': 'False', 'to': "orm['core.Edition']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '500'})
},
'core.campaign': {
'Meta': {'object_name': 'Campaign'},
'activated': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
'amazon_receiver': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'deadline': ('django.db.models.fields.DateTimeField', [], {}),
'description': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '500', 'null': 'True'}),
'paypal_receiver': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
'suspended': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
'suspended_reason': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'target': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '14', 'decimal_places': '2'}),
'withdrawn': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
'withdrawn_reason': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'work': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'campaigns'", 'to': "orm['core.Work']"})
},
'core.celerytask': {
'Meta': {'object_name': 'CeleryTask'},
'active': ('django.db.models.fields.NullBooleanField', [], {'default': 'True', 'null': 'True', 'blank': 'True'}),
'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2011, 11, 16, 13, 17, 38, 822204)', 'auto_now_add': 'True', 'blank': 'True'}),
'description': ('django.db.models.fields.CharField', [], {'max_length': '2048', 'null': 'True'}),
'function_args': ('django.db.models.fields.IntegerField', [], {'null': 'True'}),
'function_name': ('django.db.models.fields.CharField', [], {'max_length': '1024'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'task_id': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'tasks'", 'null': 'True', 'to': "orm['auth.User']"})
},
'core.claim': {
'Meta': {'object_name': 'Claim'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'rights_holder': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'claim'", 'to': "orm['core.RightsHolder']"}),
'status': ('django.db.models.fields.CharField', [], {'default': "'pending'", 'max_length': '7'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'claim'", 'to': "orm['auth.User']"}),
'work': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'claim'", 'to': "orm['core.Work']"})
},
'core.ebook': {
'Meta': {'object_name': 'Ebook'},
'edition': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'ebooks'", 'to': "orm['core.Edition']"}),
'format': ('django.db.models.fields.CharField', [], {'max_length': '25'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'provider': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'rights': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}),
'url': ('django.db.models.fields.CharField', [], {'max_length': '1024'})
},
'core.edition': {
'Meta': {'object_name': 'Edition'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'description': ('django.db.models.fields.TextField', [], {'default': "''", 'null': 'True'}),
'googlebooks_id': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'isbn_10': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True'}),
'isbn_13': ('django.db.models.fields.CharField', [], {'max_length': '13', 'null': 'True'}),
'language': ('django.db.models.fields.CharField', [], {'max_length': '2', 'null': 'True'}),
'oclc': ('django.db.models.fields.CharField', [], {'max_length': '25', 'null': 'True'}),
'public_domain': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': 'True'}),
'publication_date': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
'publisher': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '1000'}),
'work': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'editions'", 'null': 'True', 'to': "orm['core.Work']"})
},
'core.premium': {
'Meta': {'object_name': 'Premium'},
'amount': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '0'}),
'campaign': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'premiums'", 'null': 'True', 'to': "orm['core.Campaign']"}),
'description': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'type': ('django.db.models.fields.CharField', [], {'max_length': '2'})
},
'core.rightsholder': {
'Meta': {'object_name': 'RightsHolder'},
'email': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'rights_holder'", 'to': "orm['auth.User']"}),
'rights_holder_name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'})
},
'core.subject': {
'Meta': {'object_name': 'Subject'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'editions': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'subjects'", 'symmetrical': 'False', 'to': "orm['core.Edition']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '500'})
},
'core.userprofile': {
'Meta': {'object_name': 'UserProfile'},
'facebook_id': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True'}),
'goodreads_auth_secret': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'goodreads_auth_token': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'goodreads_user_id': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}),
'goodreads_user_link': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
'goodreads_user_name': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
'home_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'librarything_id': ('django.db.models.fields.CharField', [], {'max_length': '31', 'blank': 'True'}),
'pic_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}),
'tagline': ('django.db.models.fields.CharField', [], {'max_length': '140', 'blank': 'True'}),
'twitter_id': ('django.db.models.fields.CharField', [], {'max_length': '15', 'blank': 'True'}),
'user': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'profile'", 'unique': 'True', 'to': "orm['auth.User']"})
},
'core.wishlist': {
'Meta': {'object_name': 'Wishlist'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'user': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'wishlist'", 'unique': 'True', 'to': "orm['auth.User']"}),
'works': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'wishlists'", 'symmetrical': 'False', 'to': "orm['core.Work']"})
},
'core.work': {
'Meta': {'object_name': 'Work'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'openlibrary_id': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '1000'})
}
}
complete_apps = ['core']

View File

@ -5,6 +5,7 @@ from decimal import Decimal
from django.db import models
from django.db.models import Q
from django.contrib.auth.models import User
from django.conf import settings
import regluit
@ -41,10 +42,16 @@ class CeleryTask(models.Model):
return f.AsyncResult(self.task_id).info
class Claim(models.Model):
STATUSES = ((
u'Active', u'Claim has been registered and approved.'),
(u'Pending', u'Claim is pending approval.'),
(u'Released', u'Claim has been released.'),
)
rights_holder = models.ForeignKey("RightsHolder", related_name="claim", null=False )
work = models.ForeignKey("Work", related_name="claim", null=False )
user = models.ForeignKey(User, related_name="claim", null=False )
created = models.DateTimeField(auto_now_add=True)
status = models.CharField(max_length=7, choices= STATUSES, default='pending')
class RightsHolder(models.Model):
email = models.CharField(max_length=100, blank=True)
@ -318,6 +325,14 @@ class UserProfile(models.Model):
goodreads_auth_secret = models.TextField(null=True, blank=True)
goodreads_user_link = models.CharField(max_length=200, null=True, blank=True)
def is_admin(self):
if self.user.is_anonymous():
return False
for name,email in settings.ADMINS :
if email == self.user.email :
return True
return False
from regluit.core import signals
from regluit.payment.manager import PaymentManager

View File

@ -9,6 +9,7 @@ class ClaimForm(forms.ModelForm):
i_agree=forms.BooleanField()
class Meta:
model = Claim
exclude = 'status'
widgets = { 'user': forms.HiddenInput, 'work': forms.HiddenInput }
class RightsHolderForm(forms.ModelForm):

View File

@ -4,6 +4,7 @@
{% url regluit.frontend.views.edit_user as editurl %}
{% url rightsholders as rhtoolsurl %}
{% url faq as faqurl %}
{% url rh_admin as adminurl %}
<html>
<head>
@ -76,6 +77,9 @@
<li><a href="{{rhtoolsurl}}">Rights Holder Tools</a></li>
<li><a href="{{privacyurl}}">Privacy</a></li>
<li><a href="/stub/terms_and_conditions">Terms and Conditions</a></li>
{% if user.profile.is_admin %}
<li><a href="{{adminurl}}">Unglue.it Administration</a></li>
{% endif %}
</ul>
</div>
<div class="column">

View File

@ -1,5 +1,5 @@
{% extends "basedocumentation.html" %}
{% block title %}Claim Form{% endblock %}
{% block doccontent %}
<h1>Rights Holder Claim Form </h1>

View File

@ -19,11 +19,12 @@
<p>Author: {{claim.work.author }}</p>
<p>On Behalf of: {{ claim.rights_holder.rights_holder_name }}</p>
<p>PSA #: {{ claim.rights_holder.id }}</p>
<p></p>
<p>Date of Claim : {{ claim.created }}</p>
<p>Status: {{ claim.status }}</p>
{% endfor %}
{% endif %}
<h2>Rights Holder FAQ/How to launch a campaign</h2>
<h2>How to launch an Unglue.it campaign</h2>
<ol>
<li>
@ -35,7 +36,14 @@
The next step for a rights holder is to claim works from the Unglue.it database. Find the work by adding it to you wishlist.
On the "details" tab of the work's page, you will find a form that allows you to enter a claim.
When you enter a claim, you will be asked to agree to terms and conditions, in which you agree that you're making the claim in good faith, and that you can substantiate that you have legal control over rights to the work.
If you claim a work by mistake, please contact Unglue.it rights holder relations immediately: rights@gluejar.com
</li>
<li>
Once a claim is made, it will be reviewed by Unglue.it staff.
We'll make sure that the the claim is in order, and we may contact you at {{ request.user.email }} if we have any questions.
We may want to look over publishing contracts, etc., to make sure you have sufficient rights to unglue the book.
</li>
</ol>
<h2>Rightsholder social media tools</h2>
@ -54,4 +62,6 @@ Here are the standard rewards:
<li><em>$100</em> &#8212; Your name, link of your choice, & a brief message (140 characters max) under "bibliophiles"</li>
</ul>
<h2>More Questions</h2>
{% endblock %}

View File

@ -19,4 +19,15 @@
owner: <a href="{% url supporter supporter_username=rights_holder.owner %}">{{ rights_holder.owner }}</a><br/>
{% endfor %}
<h2> Pending Claims </h2>
{% for claim in pending %}
<h3>Title: <a href="{% url work work_id=claim.work.id %}">{{claim.work.title }}</a></h3>
<p>Author: {{claim.work.author }}</p>
<p>By: {{ claim.user.username }}
<p>On Behalf of: {{ claim.rights_holder.rights_holder_name }}</p>
<p>PSA #: {{ claim.rights_holder.id }}</p>
<p>Date of Claim : {{ claim.created }}</p>
<p>Status: {{ claim.status }}</p>
{% endfor %}
{% endblock %}

View File

@ -124,7 +124,7 @@ def claim(request):
return render(request, "claim.html", context)
def rh_admin(request):
if not is_admin(request.user):
if not request.user.profile.is_admin:
return render(request, "admins_only.html")
if request.method == 'POST':
form = RightsHolderForm(data=request.POST)
@ -133,14 +133,15 @@ def rh_admin(request):
else:
form = RightsHolderForm()
rights_holders = models.RightsHolder.objects.all()
context = { 'request': request, 'rights_holders': rights_holders, 'form': form }
pending = models.Claim.objects.filter(status = 'pending')
context = {
'request': request,
'rights_holders': rights_holders,
'form': form,
'pending': pending,
}
return render(request, "rights_holders.html", context)
def is_admin(user):
for name,email in settings.ADMINS :
if email == user.email :
return True
return False
def supporter(request, supporter_username, template_name):
supporter = get_object_or_404(User, username=supporter_username)