pull/1/head
Andromeda Yelton 2012-04-04 08:52:50 -04:00
commit 903356cbd6
8 changed files with 49 additions and 25 deletions

View File

@ -186,8 +186,6 @@ class Campaign(models.Model):
active_claim = self.work.claim.filter(status="active")[0]
ungluers = self.work.wished_by()
notification.queue(ungluers, "active_campaign", {'campaign':self, 'active_claim':active_claim}, True)
#import regluit.core.tasks as tasks
#tasks.emit_notifications().delay()
return self

View File

@ -1,3 +1,4 @@
import re
import json
import requests
import regluit.core.isbn
@ -32,7 +33,9 @@ def gluejar_search(q, user_ip='69.243.24.29', page=1):
# cover image
if v.has_key('imageLinks'):
r['cover_image_thumbnail'] = v['imageLinks'].get('thumbnail', "")
url = v['imageLinks'].get('thumbnail', "")
url = re.sub(r'http://bks[0-9]+\.books\.google\.com', 'https://encrypted.google.com', url)
r['cover_image_thumbnail'] = url
else:
r['cover_image_thumbnail'] = "/static/images/generic_cover_larger.png"

View File

@ -83,7 +83,5 @@ def notify_comment(comment, request, **kwargs):
other_wishers = comment.content_object.wished_by().exclude(id=comment.user.id).exclude(id__in=other_commenters)
notification.queue(other_commenters, "coment_on_commented", {'comment':comment}, True)
notification.queue(other_wishers, "wishlist_comment", {'comment':comment}, True)
# import regluit.core.tasks as tasks
# tasks.emit_notifications().delay()
comment_was_posted.connect(notify_comment)

View File

@ -302,6 +302,7 @@ class SearchTests(TestCase):
self.assertTrue(r.has_key('author'))
self.assertTrue(r.has_key('description'))
self.assertTrue(r.has_key('cover_image_thumbnail'))
self.assertTrue(r['cover_image_thumbnail'].startswith('https'))
self.assertTrue(r.has_key('publisher'))
self.assertTrue(r.has_key('isbn_13'))
self.assertTrue(r.has_key('googlebooks_id'))

View File

@ -131,6 +131,18 @@ class OpenCampaignForm(forms.ModelForm):
fields = 'name', 'work', 'managers'
widgets = { 'work': forms.HiddenInput }
class EditManagersForm(forms.ModelForm):
managers = AutoCompleteSelectMultipleField(
OwnerLookup,
label='Campaign Managers',
widget=AutoCompleteSelectMultipleWidget(OwnerLookup),
required=True,
)
class Meta:
model = Campaign
fields = ('id', 'managers')
widgets = { 'id': forms.HiddenInput }
class CustomPremiumForm(forms.ModelForm):
class Meta:
@ -179,7 +191,7 @@ class ManageCampaignForm(forms.ModelForm):
return new_deadline
def clean_license(self):
new_license = self.cleaned_data['license']
new_license = self.cleaned_data['license']
if self.instance:
if self.instance.status == 'ACTIVE':
raise forms.ValidationError(_('The license for an ACTIVE campaign cannot be changed.'))
@ -222,8 +234,8 @@ class CampaignPledgeForm(forms.Form):
try:
premium= Premium.objects.get(id=premium_id)
if premium.limit>0:
if premium.limit<=premium.premium_count:
raise forms.ValidationError(_("Sorry, that premium is fully subscribed."))
if premium.limit<=premium.premium_count:
raise forms.ValidationError(_("Sorry, that premium is fully subscribed."))
except Premium.DoesNotExist:
raise forms.ValidationError(_("Sorry, that premium is not valid."))

View File

@ -38,7 +38,7 @@ Any questions not covered here? Please email us at <a href="mailto:rights@gluej
<h2>Works You Have Claimed</h2>
<dl>
{% for claim in claims %}
<dt>Title: <a href="{% url work work_id=claim.work.id %}">{{claim.work.title }}</a></dt>
<dt>Title: <a href="{% url work work_id=claim.work.id %}">{{claim.work.title }}</a>&nbsp;&nbsp;&nbsp;(work #{{ claim.work.id }})</dt>
<dd>Author: {{claim.work.author }}
<br />On Behalf of: {{ claim.rights_holder.rights_holder_name }}
<br />PSA #: {{ claim.rights_holder.id }}
@ -65,6 +65,10 @@ Any questions not covered here? Please email us at <a href="mailto:rights@gluej
Name: Your campaign, "{{ campaign.name }}", is {{ campaign.status }}<br />
Created: {{ campaign.created }}<br />
Manager(s): {% for user in campaign.managers.all %} <a href="{% url supporter user.username %}">{{ user.username }} </a> {% endfor %}
<form method="POST" action="#">{% csrf_token %}
Add/Remove Managers: {{ campaign.edit_managers_form.managers }}{{ campaign.edit_managers_form.managers.errors }}
<input type="submit" name="edit_managers_{{campaign.id}}" value="Save Managers" id="submit">
</form>
</div>
<div>
<a href="{% url manage_campaign campaign.id %}" class="manage">Manage This Campaign</a>
@ -81,7 +85,7 @@ Any questions not covered here? Please email us at <a href="mailto:rights@gluej
<h2>Rights Holders That You Administer</h2>
<dl>
{% for rights_holder in request.user.rights_holder.all %}
<dt>Name: {{ rights_holder.rights_holder_name }}</dt>
<dt>Name: {{ rights_holder.rights_holder_name }}&nbsp;&nbsp;&nbsp;(rights holder #{{ rights_holder.id }})</dt>
<dd>PSA #: {{ rights_holder.id }}
<br />contact email: {{ rights_holder.email }}</dd>
{% endfor %}

View File

@ -11,7 +11,7 @@
<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="http://platform.twitter.com/widgets.js"></script>
<script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
<script type="text/javascript" src="/static/js/counter.js"></script>
<script>
@ -180,7 +180,8 @@ $j(document).ready(function(){
<ul class="tabs">
<li class="tabs1 {% if activetab == '1' %}active{% endif %}"><a href="#">{% if status == 'ACTIVE' %}Campaign{% else %}Description{% endif %}</a></li>
<li class="tabs2 {% if activetab == '2' %}active{% endif %}"><a href="#">Comments {% if comment_count > 0 %}({{ comment_count }}){% endif %}</a></li>
<li class="tabs3 {% if activetab == '3' %}active{% endif %}" id="supporters"><a href="#">Supporters {% if wishers > 0 %}({{ wishers }}){% endif %}</a></li>
{# the number of supporters currently commented out because they are overflowing the tab space #}
<li class="tabs3 {% if activetab == '3' %}active{% endif %}" id="supporters"><a href="#">Supporters {# {% if wishers > 0 %}({{ wishers }}){% endif %} #}</a></li>
<li class="tabs4 {% if activetab == '4' %}active{% endif %}"><a href="#">Rights</a></li>
</ul>

View File

@ -44,8 +44,8 @@ from regluit.core.search import gluejar_search
from regluit.core.goodreads import GoodreadsClient
from regluit.frontend.forms import UserData, ProfileForm, CampaignPledgeForm, GoodreadsShelfLoadingForm
from regluit.frontend.forms import RightsHolderForm, UserClaimForm, LibraryThingForm, OpenCampaignForm
from regluit.frontend.forms import ManageCampaignForm, DonateForm, CampaignAdminForm, EmailShareForm, FeedbackForm
from regluit.frontend.forms import EbookForm, CustomPremiumForm
from regluit.frontend.forms import ManageCampaignForm, DonateForm, CampaignAdminForm, EmailShareForm, FeedbackForm
from regluit.frontend.forms import EbookForm, CustomPremiumForm, EditManagersForm
from regluit.payment.manager import PaymentManager
from regluit.payment.models import Transaction
from regluit.payment.parameters import TARGET_TYPE_CAMPAIGN, TARGET_TYPE_DONATION, PAYMENT_TYPE_AUTHORIZATION
@ -164,19 +164,19 @@ def work(request, work_id, action='display'):
active_claims = work.claim.all().filter(status='active')
if active_claims.count() == 1:
claimstatus = 'one_active'
rights_holder_name = active_claims[0].rights_holder.rights_holder_name
claimstatus = 'one_active'
rights_holder_name = active_claims[0].rights_holder.rights_holder_name
else:
rights_holder_name = None
pending_claims = work.claim.all().filter(status='pending')
pending_claims_count = pending_claims.count()
if pending_claims_count > 1:
claimstatus = 'disputed'
elif pending_claims_count == 1:
claimstatus = 'one_pending'
rights_holder_name = pending_claims[0].rights_holder.rights_holder_name
else:
claimstatus = 'open'
pending_claims = work.claim.all().filter(status='pending')
pending_claims_count = pending_claims.count()
if pending_claims_count > 1:
claimstatus = 'disputed'
elif pending_claims_count == 1:
claimstatus = 'one_pending'
rights_holder_name = pending_claims[0].rights_holder.rights_holder_name
else:
claimstatus = 'open'
return render(request, 'work.html', {
'work': work,
@ -809,6 +809,13 @@ def rh_tools(request):
for campaign in claim.campaigns:
if campaign.status in ['ACTIVE','INITIALIZED']:
claim.can_open_new=False
if campaign.status == 'ACTIVE':
if request.method == 'POST' and request.POST.has_key('edit_managers_%s'% campaign.id) :
campaign.edit_managers_form=EditManagersForm( instance=campaign, data=request.POST, prefix=campaign.id)
if campaign.edit_managers_form.is_valid():
campaign.edit_managers_form.save()
else:
campaign.edit_managers_form=EditManagersForm(instance=campaign, prefix=campaign.id)
if claim.status == 'active' and claim.can_open_new:
if request.method == 'POST' and int(request.POST['work']) == claim.work.id :
claim.campaign_form = OpenCampaignForm(request.POST)