Fikset noe problemer med store/små bokstaver.
Det ble egentlig gjort for lenge siden, men ble ikke commitet da.
This commit is contained in:
parent
666c301e14
commit
52198031cd
2
db.py
2
db.py
|
@ -15,7 +15,7 @@ class User(Base):
|
||||||
credit = Column(Integer)
|
credit = Column(Integer)
|
||||||
|
|
||||||
name_re = r"[a-z]+"
|
name_re = r"[a-z]+"
|
||||||
card_re = r"((ntnu)?[0-9]+)?"
|
card_re = r"(([Nn][Tt][Nn][Uu])?[0-9]+)?"
|
||||||
|
|
||||||
def __init__(self, name, card, credit=0):
|
def __init__(self, name, card, credit=0):
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
|
@ -6,6 +6,7 @@ import os
|
||||||
import signal
|
import signal
|
||||||
|
|
||||||
def search_user(string, session):
|
def search_user(string, session):
|
||||||
|
string = string.lower()
|
||||||
exact_match = session.query(User).filter(or_(User.name==string, User.card==string)).first()
|
exact_match = session.query(User).filter(or_(User.name==string, User.card==string)).first()
|
||||||
if exact_match:
|
if exact_match:
|
||||||
return exact_match
|
return exact_match
|
||||||
|
|
|
@ -546,6 +546,7 @@ class AddUserMenu(Menu):
|
||||||
self.print_header()
|
self.print_header()
|
||||||
username = self.input_str('Username (should be same as PVV username)> ', User.name_re, (1,10))
|
username = self.input_str('Username (should be same as PVV username)> ', User.name_re, (1,10))
|
||||||
cardnum = self.input_str('Card number (optional)> ', User.card_re, (0,10))
|
cardnum = self.input_str('Card number (optional)> ', User.card_re, (0,10))
|
||||||
|
cardnum = cardnum.lower()
|
||||||
user = User(username, cardnum)
|
user = User(username, cardnum)
|
||||||
self.session.add(user)
|
self.session.add(user)
|
||||||
try:
|
try:
|
||||||
|
@ -576,6 +577,7 @@ user (write an empty line to remove the card number).
|
||||||
user.card = self.input_str('Card number (currently %s)> ' % card_str,
|
user.card = self.input_str('Card number (currently %s)> ' % card_str,
|
||||||
User.card_re, (0,10),
|
User.card_re, (0,10),
|
||||||
empty_string_is_none=True)
|
empty_string_is_none=True)
|
||||||
|
user.card = user.card.lower()
|
||||||
try:
|
try:
|
||||||
self.session.commit()
|
self.session.commit()
|
||||||
print 'User %s stored' % user.name
|
print 'User %s stored' % user.name
|
||||||
|
|
Loading…
Reference in New Issue