Added configuration options for some secret lengths

This commit is contained in:
Raphael Michel
2016-08-03 00:17:11 +02:00
parent d976d8d26d
commit 221ce9f0ae
9 changed files with 36 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ import string
from datetime import datetime
from decimal import Decimal
from django.conf import settings
from django.db import models
from django.utils.timezone import now
from django.utils.translation import ugettext_lazy as _
@@ -21,7 +22,7 @@ def generate_secret():
def generate_position_secret():
# Exclude o,0,1,i,l to avoid confusion with bad fonts/printers
return ''.join(random.choice('abcdefghjkmnpqrstuvwxyz23456789') for _ in range(32))
return ''.join(random.choice('abcdefghjkmnpqrstuvwxyz23456789') for _ in range(settings.ENTROPY['ticket_secret']))
class Order(LoggedModel):
@@ -193,7 +194,7 @@ class Order(LoggedModel):
def assign_code(self):
charset = list('ABCDEFGHKLMNPQRSTUVWXYZ23456789')
while True:
code = "".join([random.choice(charset) for i in range(5)])
code = "".join([random.choice(charset) for i in range(settings.ENTROPY['order_code'])])
if not Order.objects.filter(event=self.event, code=code).exists():
self.code = code
return