From 3e5317355ff6acd3e858d4bbc21c393b5a4cb64b Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Tue, 23 Mar 2010 21:04:07 +0000 Subject: [PATCH] Moved username cleanup to new serviceaccount creation, stopping random error on saving --- sso/models.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sso/models.py b/sso/models.py index d7481bf..55c079a 100644 --- a/sso/models.py +++ b/sso/models.py @@ -110,19 +110,19 @@ class ServiceAccount(models.Model): def save(self): """ Override default save to setup accounts as needed """ - # Force username to be the same as their selected character - # Fix unicode first of all - name = unicodedata.normalize('NFKD', self.character.name).encode('ASCII', 'ignore') - - # Remove spaces and non-acceptable characters - self.username = re.sub('[^a-zA-Z0-9_-]+', '', name) - # Grab the API class api = self.service.api_class if not self.service_uid: # Create a account if we've not got a UID if self.active: + # Force username to be the same as their selected character + # Fix unicode first of all + name = unicodedata.normalize('NFKD', self.character.name).encode('ASCII', 'ignore') + + # Remove spaces and non-acceptable characters + self.username = re.sub('[^a-zA-Z0-9_-]+', '', name) + if not api.check_user(self.username): eveapi = None for eacc in EVEAccount.objects.filter(user=self.user):