mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 14:13:21 +00:00
Migrate and fix etickets
This commit is contained in:
parent
cd23fdf3ef
commit
deeb2b5b6f
@ -999,7 +999,7 @@ class EticketPDFView(CanViewMixin, DetailView):
|
|||||||
self.object = self.get_object()
|
self.object = self.get_object()
|
||||||
eticket = self.object.product.eticket
|
eticket = self.object.product.eticket
|
||||||
user = self.object.customer.user
|
user = self.object.customer.user
|
||||||
code = "%s %s %s" % (self.object.customer.user.id, self.object.quantity, self.object.product.id)
|
code = "%s %s %s" % (self.object.customer.user.id, self.object.product.id, self.object.quantity)
|
||||||
code += " " + eticket.get_hash(code)[:8].upper()
|
code += " " + eticket.get_hash(code)[:8].upper()
|
||||||
response = HttpResponse(content_type='application/pdf')
|
response = HttpResponse(content_type='application/pdf')
|
||||||
response['Content-Disposition'] = 'filename="eticket.pdf"'
|
response['Content-Disposition'] = 'filename="eticket.pdf"'
|
||||||
@ -1030,7 +1030,7 @@ class EticketPDFView(CanViewMixin, DetailView):
|
|||||||
p.drawCentredString(10.5 * cm, 23.6 * cm, eticket.event_title)
|
p.drawCentredString(10.5 * cm, 23.6 * cm, eticket.event_title)
|
||||||
if eticket.event_date:
|
if eticket.event_date:
|
||||||
p.setFont("Helvetica-Bold", 16)
|
p.setFont("Helvetica-Bold", 16)
|
||||||
p.drawCentredString(10.5 * cm, 22.6 * cm, eticket.event_date.strftime("%d %b %Y"))
|
p.drawCentredString(10.5 * cm, 22.6 * cm, eticket.event_date.strftime("%d %b %Y")) # FIXME with a locale
|
||||||
p.setFont("Helvetica-Bold", 14)
|
p.setFont("Helvetica-Bold", 14)
|
||||||
p.drawCentredString(10.5 * cm, 15 * cm, user.get_display_name())
|
p.drawCentredString(10.5 * cm, 15 * cm, user.get_display_name())
|
||||||
p.setFont("Courier-Bold", 14)
|
p.setFont("Courier-Bold", 14)
|
||||||
|
35
migrate.py
35
migrate.py
@ -21,7 +21,7 @@ from django.core.files import File
|
|||||||
|
|
||||||
from core.models import User, SithFile
|
from core.models import User, SithFile
|
||||||
from club.models import Club, Membership
|
from club.models import Club, Membership
|
||||||
from counter.models import Customer, Counter, Selling, Refilling, Product, ProductType, Permanency
|
from counter.models import Customer, Counter, Selling, Refilling, Product, ProductType, Permanency, Eticket
|
||||||
from subscription.models import Subscription, Subscriber
|
from subscription.models import Subscription, Subscriber
|
||||||
from eboutic.models import Invoice, InvoiceItem
|
from eboutic.models import Invoice, InvoiceItem
|
||||||
from accounting.models import BankAccount, ClubAccount, GeneralJournal, Operation, AccountingType, Company, SimplifiedAccountingType
|
from accounting.models import BankAccount, ClubAccount, GeneralJournal, Operation, AccountingType, Company, SimplifiedAccountingType
|
||||||
@ -962,6 +962,36 @@ def migrate_godfathers():
|
|||||||
print("Godfathers migrated at %s" % datetime.datetime.now())
|
print("Godfathers migrated at %s" % datetime.datetime.now())
|
||||||
print("Running time: %s" % (datetime.datetime.now()-start))
|
print("Running time: %s" % (datetime.datetime.now()-start))
|
||||||
|
|
||||||
|
def migrate_etickets():
|
||||||
|
FILE_ROOT = "/data/files/"
|
||||||
|
cur = db.cursor(MySQLdb.cursors.SSDictCursor)
|
||||||
|
cur.execute("""
|
||||||
|
SELECT *
|
||||||
|
FROM cpt_etickets
|
||||||
|
""")
|
||||||
|
Eticket.objects.all().delete()
|
||||||
|
for r in cur:
|
||||||
|
try:
|
||||||
|
p = Product.objects.filter(id=r['id_produit']).first()
|
||||||
|
try:
|
||||||
|
f = File(open(FILE_ROOT + '/' + str(r['banner']) + ".1", 'rb'))
|
||||||
|
except:
|
||||||
|
f = None
|
||||||
|
e = Eticket(
|
||||||
|
product=p,
|
||||||
|
secret=to_unicode(r['secret']),
|
||||||
|
banner=f,
|
||||||
|
event_title=p.name,
|
||||||
|
)
|
||||||
|
e.save()
|
||||||
|
e.secret=to_unicode(r['secret'])
|
||||||
|
e.save()
|
||||||
|
except Exception as e:
|
||||||
|
print("FAIL to migrate eticket: %s" % (repr(e)))
|
||||||
|
cur.close()
|
||||||
|
print("Etickets migrated at %s" % datetime.datetime.now())
|
||||||
|
print("Running time: %s" % (datetime.datetime.now()-start))
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print("Start at %s" % start)
|
print("Start at %s" % start)
|
||||||
# Core
|
# Core
|
||||||
@ -975,7 +1005,8 @@ def main():
|
|||||||
# check_accounts()
|
# check_accounts()
|
||||||
# Accounting
|
# Accounting
|
||||||
# migrate_accounting()
|
# migrate_accounting()
|
||||||
migrate_godfathers()
|
# migrate_godfathers()
|
||||||
|
migrate_etickets()
|
||||||
# reset_index('core', 'club', 'subscription', 'accounting', 'eboutic', 'launderette', 'counter')
|
# reset_index('core', 'club', 'subscription', 'accounting', 'eboutic', 'launderette', 'counter')
|
||||||
end = datetime.datetime.now()
|
end = datetime.datetime.now()
|
||||||
print("End at %s" % end)
|
print("End at %s" % end)
|
||||||
|
Loading…
Reference in New Issue
Block a user