diff --git a/core/migrations/0016_auto__add_field_userprofile_pic_url__add_field_userprofile_facebook_id.py b/core/migrations/0016_auto__add_field_userprofile_pic_url__add_field_userprofile_facebook_id.py new file mode 100644 index 00000000..4f26e98f --- /dev/null +++ b/core/migrations/0016_auto__add_field_userprofile_pic_url__add_field_userprofile_facebook_id.py @@ -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'] diff --git a/core/models.py b/core/models.py index 4c133ef4..fd18a70a 100755 --- a/core/models.py +++ b/core/models.py @@ -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 diff --git a/frontend/forms.py b/frontend/forms.py index 03dc94fc..8b339b64 100644 --- a/frontend/forms.py +++ b/frontend/forms.py @@ -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): diff --git a/frontend/templates/base.html b/frontend/templates/base.html index d300269c..149480c4 100644 --- a/frontend/templates/base.html +++ b/frontend/templates/base.html @@ -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 %}
@@ -76,6 +77,9 @@Author: {{claim.work.author }}
On Behalf of: {{ claim.rights_holder.rights_holder_name }}
PSA #: {{ claim.rights_holder.id }}
- +Date of Claim : {{ claim.created }}
+Status: {{ claim.status }}
{% endfor %} {% endif %} -Author: {{claim.work.author }}
+By: {{ claim.user.username }} +
On Behalf of: {{ claim.rights_holder.rights_holder_name }}
+PSA #: {{ claim.rights_holder.id }}
+Date of Claim : {{ claim.created }}
+Status: {{ claim.status }}
+{% endfor %} + {% endblock %} \ No newline at end of file diff --git a/frontend/views.py b/frontend/views.py index 6dcbe9e4..de519d8c 100755 --- a/frontend/views.py +++ b/frontend/views.py @@ -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)