first pass with 2to3

This commit is contained in:
Thomas Steen Rasmussen 2017-01-30 12:16:07 +01:00
parent 0ff37bbca5
commit 3a7b952090
107 changed files with 184 additions and 184 deletions

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import uuid

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.1 on 2016-01-17 17:18
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-04-22 20:19
from __future__ import unicode_literals
from django.db import migrations

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.5 on 2016-05-06 20:16
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-05-10 20:11
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-08-04 17:05
from __future__ import unicode_literals
from django.db import migrations

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2016-12-12 18:03
from __future__ import unicode_literals
import datetime
from django.conf import settings

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2016-12-12 18:09
from __future__ import unicode_literals
from django.db import migrations

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2016-12-20 16:45
from __future__ import unicode_literals
import datetime
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2016-12-20 17:14
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2016-12-28 17:50
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2016-12-28 23:12
from __future__ import unicode_literals
from django.db import migrations

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2016-12-29 22:01
from __future__ import unicode_literals
import django.contrib.postgres.fields.ranges
from django.db import migrations

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2016-12-29 22:02
from __future__ import unicode_literals
import django.contrib.postgres.fields.ranges
from django.db import migrations

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2017-01-16 16:34
from __future__ import unicode_literals
from django.db import migrations

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2017-01-16 16:37
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2017-01-16 21:59
from __future__ import unicode_literals
from django.db import migrations

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-01-28 17:41
from __future__ import unicode_literals
import django.contrib.postgres.fields.ranges
from django.db import migrations

View file

@ -91,7 +91,7 @@ class Camp(CreatedUpdatedModel, UUIDModel):
field = getattr(self, camppart)
if not hasattr(field, '__class__') or not hasattr(field.__class__, '__name__') or not field.__class__.__name__ == 'DateTimeTZRange':
print("this attribute is not a datetimetzrange field: %s" % field)
print(("this attribute is not a datetimetzrange field: %s" % field))
return False
daycount = (field.upper - field.lower).days

View file

@ -1,4 +1,4 @@
from __future__ import unicode_literals
from django.apps import AppConfig

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2016-12-24 22:11
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2016-12-28 23:12
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,4 +1,4 @@
from __future__ import unicode_literals
from django.contrib import messages
from django.db import models
from utils.models import CreatedUpdatedModel

View file

@ -1,4 +1,4 @@
from __future__ import unicode_literals
from django.apps import AppConfig

View file

@ -24,19 +24,19 @@ class Plugin(object):
def server_ready(self, **kwargs):
"""triggered after the server sent the MOTD (require core plugin)"""
if settings.DEBUG:
print("inside server_ready(), kwargs: %s" % kwargs)
print(("inside server_ready(), kwargs: %s" % kwargs))
def connection_lost(self, **kwargs):
"""triggered when connection is lost"""
if settings.DEBUG:
print("inside connection_lost(), kwargs: %s" % kwargs)
print(("inside connection_lost(), kwargs: %s" % kwargs))
def connection_made(self, **kwargs):
"""triggered when connection is up"""
if settings.DEBUG:
print("inside connection_made(), kwargs: %s" % kwargs)
print(("inside connection_made(), kwargs: %s" % kwargs))
###############################################################################################
@ -46,7 +46,7 @@ class Plugin(object):
def on_join_part_quit(self, **kwargs):
"""triggered when there is a join part or quit on a channel the bot is in"""
if settings.DEBUG:
print("inside on_join_part_quit(), kwargs: %s" % kwargs)
print(("inside on_join_part_quit(), kwargs: %s" % kwargs))
if self.bot.nick == kwargs['mask'].split("!")[0] and kwargs['channel'] == "#tirsdagsfilm":
self.bot.loop.call_later(1, self.bot.get_outgoing_messages)
@ -55,13 +55,13 @@ class Plugin(object):
def on_privmsg(self, **kwargs):
"""triggered when a privmsg is sent to the bot or to a channel the bot is in"""
if settings.DEBUG:
print("inside on_privmsg(), kwargs: %s" % kwargs)
print(("inside on_privmsg(), kwargs: %s" % kwargs))
@irc3.event(irc3.rfc.KICK)
def on_kick(self, **kwargs):
if settings.DEBUG:
print("inside on_kick(), kwargs: %s" % kwargs)
print(("inside on_kick(), kwargs: %s" % kwargs))
###############################################################################################
@ -78,12 +78,12 @@ class Plugin(object):
print("inside get_outgoing_messages()")
for msg in OutgoingIrcMessage.objects.filter(processed=False).order_by('created_date'):
if msg.target[0] == "#" and msg.target in self.bot.channels:
print("sending privmsg to %s: %s" % (msg.target, msg.message))
print(("sending privmsg to %s: %s" % (msg.target, msg.message)))
self.bot.privmsg(msg.target, msg.message)
msg.processed=True
msg.save()
else:
print("skipping message to channel %s because the bot is not in the channel" % msg.target)
print(("skipping message to channel %s because the bot is not in the channel" % msg.target))
# call this function again in 60 seconds
self.bot.loop.call_later(60, self.bot.get_outgoing_messages)

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-01-29 20:29
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,4 +1,4 @@
from __future__ import unicode_literals
from utils.models import UUIDModel, CreatedUpdatedModel
from django.db import models

View file

@ -1,4 +1,4 @@
from __future__ import unicode_literals
from django.apps import AppConfig

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-05-30 19:12
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-05-30 22:23
from __future__ import unicode_literals
from django.db import migrations

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-06-05 21:26
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-06-10 17:43
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-06-18 19:02
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2016-12-20 11:27
from __future__ import unicode_literals
from django.db import migrations

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2016-12-20 11:36
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2016-12-20 13:03
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,4 +1,4 @@
from __future__ import unicode_literals
from django.db import models
from django.utils import encoding

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from django.conf import settings

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-07-13 19:38
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-08-04 17:05
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-08-04 17:11
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-08-04 17:12
from __future__ import unicode_literals
from django.db import migrations

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-08-07 13:12
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-08-07 13:20
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-08-07 13:33
from __future__ import unicode_literals
from django.db import migrations

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-08-08 17:47
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-08-27 07:52
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2016-12-12 18:09
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2016-12-29 21:49
from __future__ import unicode_literals
import django.contrib.postgres.fields.ranges
from django.db import migrations

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2016-12-29 21:50
from __future__ import unicode_literals
import django.contrib.postgres.fields.ranges
from django.db import migrations

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-01-21 12:12
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-01-22 13:39
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-01-28 17:41
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,4 +1,4 @@
from __future__ import unicode_literals
from django.contrib.postgres.fields import DateTimeRangeField
from django.db import models
from django.utils.text import slugify

View file

@ -18,7 +18,7 @@ def send_email(emailtype, recipient, formatdict, subject, sender='BornHack <info
elif emailtype == 'testmail':
text_template = 'emails/testmail.txt'
else:
print 'Unknown email type: %s' % emailtype
print('Unknown email type: %s' % emailtype)
return False
try:
@ -34,7 +34,7 @@ def send_email(emailtype, recipient, formatdict, subject, sender='BornHack <info
msg.attach(attachment_filename, attachment, 'application/pdf')
except Exception as E:
print 'exception while rendering email: %s' % E
print('exception while rendering email: %s' % E)
return False
### send the email

View file

@ -21,7 +21,7 @@ def calculate_epay_hash(order, request):
def validate_epay_callback(query):
hashstring = ''
for key, value in query.iteritems():
for key, value in query.items():
if key != 'hash':
hashstring += value
hash = hashlib.md5(hashstring + settings.EPAY_MD5_SECRET).hexdigest()

View file

@ -15,27 +15,27 @@ def api_epay_callback(request):
try:
order = EpayOrder.objects.get(id=request.GET['orderid'][1:])
except EpayOrder.DoesNotExist:
print "epay callback - epayorder %s not found" % request.GET['orderid']
print("epay callback - epayorder %s not found" % request.GET['orderid'])
return HttpResponse("Not OK")
### check hash here
if 'hash' not in request.GET:
print "epay callback - missing epay hash"
print("epay callback - missing epay hash")
return HttpResponse("Not OK")
### this does not work sometimes, ordering is off maybe?
hashstring = ''
qs = request.META['QUERY_STRING']
print "querystring is %s" % qs
print("querystring is %s" % qs)
for kv in qs.split("&"):
print "hashstring is now %s" % hashstring
print("hashstring is now %s" % hashstring)
if kv.split("=")[0] != "hash":
hashstring += kv.split("=")[1]
print "hashstring is now %s" % hashstring
print("hashstring is now %s" % hashstring)
hashstring += settings.EPAY_MD5_SECRET
epayhash = hashlib.md5(hashstring).hexdigest()
if epayhash != request.GET['hash']:
print "epay callback - wrong epay hash"
print("epay callback - wrong epay hash")
return HttpResponse("Not OK")
### save callback in epayorder
@ -61,7 +61,7 @@ def api_epay_callback(request):
### save
order.save()
else:
print "epay callback - order %s not recognized" % request.GET['orderid']
print("epay callback - order %s not recognized" % request.GET['orderid'])
return HttpResponse("Not OK")
return HttpResponse("OK")
@ -103,7 +103,7 @@ def epay_order(request):
### save epay order with commit=False
epayorder = form.save(commit=False)
except Exception as E:
print "unable to save epay order with commit=false"
print("unable to save epay order with commit=false")
return render(request, 'epay_order_fail.html', {
'message': _('Unable to save epay order. Please try again, and please contact us if the problem persists.')
})

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-05-10 20:00
from __future__ import unicode_literals
from django.conf import settings
import django.contrib.postgres.fields.jsonb

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-05-10 20:02
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-05-13 06:46
from __future__ import unicode_literals
import django.contrib.postgres.fields.ranges
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-05-15 16:04
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-05-15 16:14
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-05-15 16:15
from __future__ import unicode_literals
from django.db import migrations

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-05-15 21:57
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-05-16 09:54
from __future__ import unicode_literals
import datetime
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-05-17 06:00
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-05-17 13:13
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-05-17 19:02
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-05-23 15:08
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-05-25 16:58
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-05-25 17:02
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-05-29 10:47
from __future__ import unicode_literals
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-05-29 11:22
from __future__ import unicode_literals
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-05-29 16:26
from __future__ import unicode_literals
from django.db import migrations

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-05-29 17:36
from __future__ import unicode_literals
from django.db import migrations

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-05-30 15:29
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-05-30 18:24
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-05-30 22:23
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-05-30 23:01
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-06-01 08:53
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-06-05 21:26
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-06-18 19:02
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-06-18 22:15
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-07-12 20:36
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-07-12 21:19
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-07-12 21:33
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-08-27 07:52
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.3 on 2016-11-09 10:00
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.3 on 2016-11-09 11:46
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2016-12-12 17:56
from __future__ import unicode_literals
from django.db import migrations

View file

@ -1,50 +1,50 @@
from wkhtmltopdf.views import PDFTemplateResponse
from PyPDF2 import PdfFileWriter, PdfFileReader
from django.test.client import RequestFactory
from django.conf import settings
import StringIO
def generate_pdf_letter(filename, template, formatdict):
### produce text-only PDF from template
pdfgenerator = PDFTemplateResponse(
request=RequestFactory().get('/'),
template=template,
context=formatdict,
cmd_options={
'margin-top': 50,
'margin-bottom': 50,
},
)
textonlypdf = StringIO.StringIO()
textonlypdf.write(pdfgenerator.rendered_content)
### create a blank pdf to work with
finalpdf = PdfFileWriter()
### open the text-only pdf
pdfreader = PdfFileReader(textonlypdf)
### get watermark from watermark file
watermark = PdfFileReader(open(settings.LETTERHEAD_PDF_PATH, 'rb'))
### add the watermark to all pages
for pagenum in xrange(pdfreader.getNumPages()):
page = watermark.getPage(0)
try:
page.mergePage(pdfreader.getPage(pagenum))
except ValueError:
### watermark pdf might be broken?
return False
### add page to output
finalpdf.addPage(page)
### save the generated pdf to the archive
with open(settings.PDF_ARCHIVE_PATH+filename, 'wb') as fh:
finalpdf.write(fh)
print('Saved pdf to archive: %s' % settings.PDF_ARCHIVE_PATH+filename)
### return a file object with the data
returnfile = StringIO.StringIO()
finalpdf.write(returnfile)
return returnfile
from wkhtmltopdf.views import PDFTemplateResponse
from PyPDF2 import PdfFileWriter, PdfFileReader
from django.test.client import RequestFactory
from django.conf import settings
import io
def generate_pdf_letter(filename, template, formatdict):
### produce text-only PDF from template
pdfgenerator = PDFTemplateResponse(
request=RequestFactory().get('/'),
template=template,
context=formatdict,
cmd_options={
'margin-top': 50,
'margin-bottom': 50,
},
)
textonlypdf = io.StringIO()
textonlypdf.write(pdfgenerator.rendered_content)
### create a blank pdf to work with
finalpdf = PdfFileWriter()
### open the text-only pdf
pdfreader = PdfFileReader(textonlypdf)
### get watermark from watermark file
watermark = PdfFileReader(open(settings.LETTERHEAD_PDF_PATH, 'rb'))
### add the watermark to all pages
for pagenum in range(pdfreader.getNumPages()):
page = watermark.getPage(0)
try:
page.mergePage(pdfreader.getPage(pagenum))
except ValueError:
### watermark pdf might be broken?
return False
### add page to output
finalpdf.addPage(page)
### save the generated pdf to the archive
with open(settings.PDF_ARCHIVE_PATH+filename, 'wb') as fh:
finalpdf.write(fh)
print(('Saved pdf to archive: %s' % settings.PDF_ARCHIVE_PATH+filename))
### return a file object with the data
returnfile = io.StringIO()
finalpdf.write(returnfile)
return returnfile

View file

@ -538,7 +538,7 @@ class CoinifyRedirectView(LoginRequiredMixin, EnsureUserOwnsOrderMixin, EnsureUn
# check if it expired
if parse_datetime(order.coinifyapiinvoice.invoicejson['expire_time']) < timezone.now():
# this coinifyinvoice expired, delete it
print("deleting expired coinifyinvoice id %s" % order.coinifyapiinvoice.invoicejson['id'])
print(("deleting expired coinifyinvoice id %s" % order.coinifyapiinvoice.invoicejson['id']))
order.coinifyapiinvoice.delete()
order = self.get_object()
@ -565,10 +565,10 @@ class CoinifyRedirectView(LoginRequiredMixin, EnsureUserOwnsOrderMixin, EnsureUn
# Parse response
if not response['success']:
api_error = response['error']
print("API error: %s (%s)" % (
print(("API error: %s (%s)" % (
api_error['message'],
api_error['code']
))
)))
messages.error(request, "There was a problem with the payment provider. Please try again later")
return HttpResponseRedirect(reverse_lazy('shop:order_detail', kwargs={'pk': self.get_object().pk}))
else:
@ -577,7 +577,7 @@ class CoinifyRedirectView(LoginRequiredMixin, EnsureUserOwnsOrderMixin, EnsureUn
invoicejson = response['data'],
order = order,
)
print("created new coinifyinvoice id %s" % coinifyinvoice.invoicejson['id'])
print(("created new coinifyinvoice id %s" % coinifyinvoice.invoicejson['id']))
return super(CoinifyRedirectView, self).dispatch(
request, *args, **kwargs
)
@ -600,7 +600,7 @@ class CoinifyCallbackView(SingleObjectMixin, View):
# make a dict with all HTTP_ headers
headerdict = {}
for key, value in request.META.items():
for key, value in list(request.META.items()):
if key[:5] == 'HTTP_':
headerdict[key[5:]] = value
@ -622,7 +622,7 @@ class CoinifyCallbackView(SingleObjectMixin, View):
try:
coinifyinvoice = CoinifyAPIInvoice.objects.get(invoicejson__id=callbackjson['data']['id'])
except CoinifyAPIInvoice.DoesNotExist:
print("unable to find CoinifyAPIInvoice with id %s" % callbackjson['data']['id'])
print(("unable to find CoinifyAPIInvoice with id %s" % callbackjson['data']['id']))
return HttpResponseBadRequest('bad coinifyinvoice id')
# save new coinifyinvoice payload

View file

@ -1,4 +1,4 @@
from __future__ import unicode_literals
from django.apps import AppConfig

View file

@ -1,4 +1,4 @@
from __future__ import unicode_literals
from django.apps import AppConfig

View file

@ -29,11 +29,11 @@ class Command(BaseCommand):
),
camp=(
timezone.datetime(2016, 8, 27, 12, 0, tzinfo=timezone.utc),
timezone.datetime(2016, 9, 04, 11, 59, tzinfo=timezone.utc),
timezone.datetime(2016, 9, 0o4, 11, 59, tzinfo=timezone.utc),
),
teardown=(
timezone.datetime(2016, 9, 04, 12, 0, tzinfo=timezone.utc),
timezone.datetime(2016, 9, 06, 12, 0, tzinfo=timezone.utc),
timezone.datetime(2016, 9, 0o4, 12, 0, tzinfo=timezone.utc),
timezone.datetime(2016, 9, 0o6, 12, 0, tzinfo=timezone.utc),
),
)
@ -47,11 +47,11 @@ class Command(BaseCommand):
),
camp=(
timezone.datetime(2017, 8, 27, 12, 0, tzinfo=timezone.utc),
timezone.datetime(2017, 9, 04, 11, 59, tzinfo=timezone.utc),
timezone.datetime(2017, 9, 0o4, 11, 59, tzinfo=timezone.utc),
),
teardown=(
timezone.datetime(2017, 9, 04, 12, 0, tzinfo=timezone.utc),
timezone.datetime(2017, 9, 06, 12, 0, tzinfo=timezone.utc),
timezone.datetime(2017, 9, 0o4, 12, 0, tzinfo=timezone.utc),
timezone.datetime(2017, 9, 0o6, 12, 0, tzinfo=timezone.utc),
),
)
@ -65,11 +65,11 @@ class Command(BaseCommand):
),
camp=(
timezone.datetime(2018, 8, 27, 12, 0, tzinfo=timezone.utc),
timezone.datetime(2018, 9, 04, 11, 59, tzinfo=timezone.utc),
timezone.datetime(2018, 9, 0o4, 11, 59, tzinfo=timezone.utc),
),
teardown=(
timezone.datetime(2018, 9, 04, 12, 0, tzinfo=timezone.utc),
timezone.datetime(2018, 9, 06, 12, 0, tzinfo=timezone.utc),
timezone.datetime(2018, 9, 0o4, 12, 0, tzinfo=timezone.utc),
timezone.datetime(2018, 9, 0o6, 12, 0, tzinfo=timezone.utc),
),
)

View file

@ -1,4 +1,4 @@
from __future__ import unicode_literals
from django.apps import AppConfig

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-07-05 21:38
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-07-05 21:54
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-07-05 21:59
from __future__ import unicode_literals
from django.db import migrations, models

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-07-10 16:58
from __future__ import unicode_literals
from django.db import migrations, models

Some files were not shown because too many files have changed in this diff Show more