Approved rights holders get a claim form on work pages; still need to make a view that does the actual claiming

pull/1/head
eric 2011-11-15 18:20:29 -05:00
parent f83f046c7a
commit 354b46085f
7 changed files with 62 additions and 14 deletions

View File

@ -50,6 +50,8 @@ class RightsHolder(models.Model):
email = models.CharField(max_length=100, blank=True)
rights_holder_name = models.CharField(max_length=100, blank=True)
owner = models.ForeignKey(User, related_name="rights_holder", null=False )
def __unicode__(self):
return self.rights_holder_name
class Premium(models.Model):
PREMIUM_TYPES = ((u'00', u'Default'),(u'CU', u'Custom'))

View File

@ -1,9 +1,14 @@
from django import forms
from django.db import models
from regluit.core.models import UserProfile, RightsHolder
from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _
from decimal import Decimal as D
from regluit.core.models import UserProfile, RightsHolder, Claim
class ClaimForm(forms.ModelForm):
class Meta:
model = Claim
widgets = { 'user': forms.HiddenInput, 'work': forms.HiddenInput }
class RightsHolderForm(forms.ModelForm):
class Meta:

View File

@ -0,0 +1,16 @@
{% extends "basedocumentation.html" %}
{% block doccontent %}
<h1>Rights Holder Claim Form </h1>
<form method="POST" action="#">
{% csrf_token %}
<h2> Rightsholder making claim </h2>
<h2> Work being claimed </h2>
<h2> Terms and Conditions </h2>
{{ form.as_p }}
<input type="submit" name="submit" value="Confirm Claim" id="submit">
</form>
{% endblock %}

View File

@ -10,7 +10,7 @@
{{ form.as_p }}
<input type="submit" name="submit" value="Create" id="submit">
</form>
</form>
<h2> Accepted Rights Holders </h2>
{% for rights_holder in rights_holders %}
<h3>{{ rights_holder.rights_holder_name }}</h3>

View File

@ -110,7 +110,24 @@
</div>
<div id="tabs-4" class="tabs">
<div class="tabs-content">
Want to Unglue infomation xxx
<h3 class="tabcontent-title">Details for {{ work.title }}</h3>
{% if work.claim.count %}
<h4> Rights Information </h4>
<p> This work has been claimed by:</p>
<ul>
{% for claim in work.claim.all %}
<li>{{ claim.rights_holder.rights_holder_name }} </li>
{% endfor %}
</ul>
{% endif %}
{% if request.user.rights_holder %}
<h4> Claim this work:</h4>
<form method="GET" action="{% url claim %}">
{% csrf_token %}
{{ claimform.as_p }}
<input type="submit" name="submit" value="Claim" id="submit">
</form>
{% endif %}
</div>
</div>
</div>

View File

@ -17,6 +17,8 @@ urlpatterns = patterns(
name="privacy"),
url(r"^rightsholders/$", TemplateView.as_view(template_name="rhtools.html"),
name="rightsholders"),
url(r"^rightsholders/claim/$", TemplateView.as_view(template_name="claim.html"),
name="claim"),
url(r"^rh_admin/$", "rh_admin", name="rh_admin"),
url(r"^faq/$", TemplateView.as_view(template_name="faq.html"),
name="faq"),

View File

@ -26,7 +26,7 @@ from regluit.core import models, bookloader
from regluit.core import userlists
from regluit.core.search import gluejar_search
from regluit.core.goodreads import GoodreadsClient
from regluit.frontend.forms import UserData, ProfileForm, CampaignPledgeForm, GoodreadsShelfLoadingForm, RightsHolderForm
from regluit.frontend.forms import UserData, ProfileForm, CampaignPledgeForm, GoodreadsShelfLoadingForm, RightsHolderForm, ClaimForm
from regluit.payment.manager import PaymentManager
from regluit.payment.parameters import TARGET_TYPE_CAMPAIGN
@ -53,6 +53,7 @@ def stub(request):
def work(request, work_id, action='display'):
work = get_object_or_404(models.Work, id=work_id)
campaign = work.last_campaign()
claimform = ClaimForm(data={'work':work_id, 'user':request.user.id })
if campaign:
q = Q(campaign=campaign) | Q(campaign__isnull=True)
premiums = models.Premium.objects.filter(q)
@ -61,15 +62,20 @@ def work(request, work_id, action='display'):
if action == 'setup_campaign':
return render(request, 'setup_campaign.html', {'work': work})
else:
return render(request, 'work.html', {'work': work, 'premiums': premiums, 'ungluers': userlists.supporting_users(work, 5)})
return render(request, 'work.html', {
'work': work,
'premiums': premiums,
'ungluers': userlists.supporting_users(work, 5),
'claimform': claimform,
})
def workstub(request, title, imagebase, image, author, googlebooks_id, action='display'):
premiums = None
title = urllib.unquote_plus(title)
imagebase = urllib.unquote_plus(imagebase)
image = urllib.unquote_plus(image)
author = urllib.unquote_plus(author)
return render(request, 'workstub.html', {'title': title, 'image': image, 'imagebase': imagebase, 'author': author, 'googlebooks_id': googlebooks_id, 'premiums': premiums, 'ungluers': userlists.other_users(supporter, 5)})
premiums = None
title = urllib.unquote_plus(title)
imagebase = urllib.unquote_plus(imagebase)
image = urllib.unquote_plus(image)
author = urllib.unquote_plus(author)
return render(request, 'workstub.html', {'title': title, 'image': image, 'imagebase': imagebase, 'author': author, 'googlebooks_id': googlebooks_id, 'premiums': premiums, 'ungluers': userlists.other_users(supporter, 5)})
def subjects(request):
order = request.GET.get('order')
@ -225,9 +231,9 @@ def search(request):
# also urlencode some parameters we'll need to pass to workstub in the title links
# needs to be done outside the if condition
for result in results:
result['urlimage'] = urllib.quote_plus(sub('^https?:\/\/','', result['image']).encode("utf-8"), safe='')
result['urlauthor'] = urllib.quote_plus(result['author'].encode("utf-8"), safe='')
result['urltitle'] = urllib.quote_plus(result['title'].encode("utf-8"), safe='')
result['urlimage'] = urllib.quote_plus(sub('^https?:\/\/','', result['image']).encode("utf-8"), safe='')
result['urlauthor'] = urllib.quote_plus(result['author'].encode("utf-8"), safe='')
result['urltitle'] = urllib.quote_plus(result['title'].encode("utf-8"), safe='')
context = {
"q": q,