From 52198031cd6b8652a80e9333cd603843d2344275 Mon Sep 17 00:00:00 2001 From: oysteini Date: Wed, 24 Nov 2010 16:24:52 +0000 Subject: [PATCH] =?UTF-8?q?Fikset=20noe=20problemer=20med=20store/sm=C3=A5?= =?UTF-8?q?=20bokstaver.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Det ble egentlig gjort for lenge siden, men ble ikke commitet da. --- db.py | 2 +- helpers.py | 1 + text_based.py | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/db.py b/db.py index b3728b7..bfb382c 100644 --- a/db.py +++ b/db.py @@ -15,7 +15,7 @@ class User(Base): credit = Column(Integer) 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): self.name = name diff --git a/helpers.py b/helpers.py index cf14a3f..156d5d9 100644 --- a/helpers.py +++ b/helpers.py @@ -6,6 +6,7 @@ import os import signal def search_user(string, session): + string = string.lower() exact_match = session.query(User).filter(or_(User.name==string, User.card==string)).first() if exact_match: return exact_match diff --git a/text_based.py b/text_based.py index f78758b..bad0030 100755 --- a/text_based.py +++ b/text_based.py @@ -546,6 +546,7 @@ class AddUserMenu(Menu): self.print_header() 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 = cardnum.lower() user = User(username, cardnum) self.session.add(user) 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_re, (0,10), empty_string_is_none=True) + user.card = user.card.lower() try: self.session.commit() print 'User %s stored' % user.name