Merge branch 'master' of github.com:Gluejar/regluit
commit
2dee8c3895
|
@ -319,7 +319,6 @@ class CampaignAdminForm(forms.Form):
|
||||||
|
|
||||||
class EmailShareForm(forms.Form):
|
class EmailShareForm(forms.Form):
|
||||||
recipient = forms.EmailField(error_messages={'required': 'Please specify a recipient.'})
|
recipient = forms.EmailField(error_messages={'required': 'Please specify a recipient.'})
|
||||||
sender = forms.EmailField(widget=forms.HiddenInput())
|
|
||||||
subject = forms.CharField(max_length=100, error_messages={'required': 'Please specify a subject.'})
|
subject = forms.CharField(max_length=100, error_messages={'required': 'Please specify a subject.'})
|
||||||
message = forms.CharField(widget=forms.Textarea(), error_messages={'required': 'Please include a message.'})
|
message = forms.CharField(widget=forms.Textarea(), error_messages={'required': 'Please include a message.'})
|
||||||
# allows us to return user to original page by passing it as hidden form input
|
# allows us to return user to original page by passing it as hidden form input
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
I just pledged to unglue one of my favorite books, "{{ work.title }}", on Unglue.it:
|
||||||
|
https://{{site}}{% url work work.id %}.
|
||||||
|
|
||||||
|
If enough of us pledge to unglue this book, the creator will be paid and the ebook will become free to everyone on earth. Will you join me?
|
|
@ -0,0 +1,3 @@
|
||||||
|
I'm ungluing books on Unglue.it.
|
||||||
|
|
||||||
|
Together we're paying creators and making ebooks free to everyone on earth. Join me! https://unglue.it/
|
|
@ -0,0 +1,4 @@
|
||||||
|
Help me unglue one of my favorite books, "{{ work.title }}" on Unglue.it:
|
||||||
|
https://{{site}}{% url work work.id %}
|
||||||
|
|
||||||
|
If enough of us pledge to unglue this book, the creator will be paid and the ebook will become free to everyone on earth.
|
|
@ -0,0 +1,4 @@
|
||||||
|
Help me unglue one of my favorite books, "{{ work.title }}" on Unglue.it:
|
||||||
|
https://{{site}}{% url work work.id %}
|
||||||
|
|
||||||
|
If enough of us wishlist this book, Unglue.it may start a campaign to pay the creator and make the ebook free to everyone on earth.
|
|
@ -22,6 +22,7 @@ from django.core.exceptions import ObjectDoesNotExist
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.contrib.comments import Comment
|
from django.contrib.comments import Comment
|
||||||
|
from django.contrib.sites.models import Site
|
||||||
from django.db.models import Q, Count, Sum
|
from django.db.models import Q, Count, Sum
|
||||||
from django.forms import Select
|
from django.forms import Select
|
||||||
from django.forms.models import modelformset_factory
|
from django.forms.models import modelformset_factory
|
||||||
|
@ -1762,7 +1763,7 @@ def emailshare(request):
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
subject = form.cleaned_data['subject']
|
subject = form.cleaned_data['subject']
|
||||||
message = form.cleaned_data['message']
|
message = form.cleaned_data['message']
|
||||||
sender = form.cleaned_data['sender']
|
sender = sender = request.user.email
|
||||||
recipient = form.cleaned_data['recipient']
|
recipient = form.cleaned_data['recipient']
|
||||||
send_mail_task.delay(subject, message, sender, [recipient])
|
send_mail_task.delay(subject, message, sender, [recipient])
|
||||||
try:
|
try:
|
||||||
|
@ -1772,41 +1773,34 @@ def emailshare(request):
|
||||||
return HttpResponseRedirect(next)
|
return HttpResponseRedirect(next)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
sender = request.user.email
|
|
||||||
try:
|
try:
|
||||||
next = request.GET['next']
|
next = request.GET['next']
|
||||||
if "pledge" in request.path:
|
if "pledge" in request.path:
|
||||||
work_id = next.split('=')[1]
|
work_id = next.split('=')[1]
|
||||||
book = models.Work.objects.get(pk=int(work_id))
|
work = models.Work.objects.get(pk=int(work_id))
|
||||||
title = book.title
|
message = render_to_string('emails/i_just_pledged.txt',{'request':request,'work':work,'site': Site.objects.get_current()})
|
||||||
message = "I just pledged to unglue one of my favorite books, "+title+", on Unglue.it: http://unglue.it/work/"+work_id+". If enough of us pledge to unglue this book, the creator will be paid and the ebook will become free to everyone on earth. Will you join me?"
|
subject = "Help me unglue "+work.title
|
||||||
subject = "Help me unglue "+title
|
|
||||||
else:
|
else:
|
||||||
work_id = next.split('/')[-2]
|
work_id = next.split('/')[-2]
|
||||||
work_id = int(work_id)
|
work_id = int(work_id)
|
||||||
book = models.Work.objects.get(pk=work_id)
|
work = models.Work.objects.get(pk=work_id)
|
||||||
title = book.title
|
|
||||||
# if title requires unicode let's ignore it for now
|
|
||||||
try:
|
try:
|
||||||
title = ', '+str(title)+', '
|
status = work.last_campaign().status
|
||||||
except:
|
|
||||||
title = ' '
|
|
||||||
try:
|
|
||||||
status = book.last_campaign().status
|
|
||||||
except:
|
except:
|
||||||
status = None
|
status = None
|
||||||
|
|
||||||
# customize the call to action depending on campaign status
|
# customize the call to action depending on campaign status
|
||||||
if status == 'ACTIVE':
|
if status == 'ACTIVE':
|
||||||
message = 'Help me unglue one of my favorite books'+title+'on Unglue.it: http://unglue.it/'+next+'. If enough of us pledge to unglue this book, the creator will be paid and the ebook will become free to everyone on earth.'
|
message = render_to_string('emails/pledge_this.txt',{'request':request,'work':work,'site': Site.objects.get_current()})
|
||||||
else:
|
else:
|
||||||
message = 'Help me unglue one of my favorite books'+title+'on Unglue.it: http://unglue.it'+next+'. If enough of us wishlist this book, Unglue.it may start a campaign to pay the creator and make the ebook free to everyone on earth.'
|
message = render_to_string('emails/wish_this.txt',{'request':request,'work':work,'site': Site.objects.get_current()})
|
||||||
subject = 'Come see one of my favorite books on Unglue.it'
|
subject = 'Come see one of my favorite books on Unglue.it'
|
||||||
|
|
||||||
form = EmailShareForm(initial={'sender': sender, 'next':next, 'subject': subject, 'message': message})
|
form = EmailShareForm(initial={ 'next':next, 'subject': subject, 'message': message})
|
||||||
except:
|
except:
|
||||||
next = ''
|
next = ''
|
||||||
form = EmailShareForm(initial={'sender': sender, 'next':next, 'subject': 'Come join me on Unglue.it', 'message':"I'm ungluing books on Unglue.it. Together we're paying creators and making ebooks free to everyone on earth. Join me! http://unglue.it"})
|
form = EmailShareForm(initial={'next':next, 'subject': 'Come join me on Unglue.it', 'message':render_to_string('emails/join_me.txt',{'request':request,'site': Site.objects.get_current()})})
|
||||||
|
|
||||||
return render(request, "emailshare.html", {'form':form})
|
return render(request, "emailshare.html", {'form':form})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue