def register(email,nick,password): email = email.strip() nick = nick.strip() session = database.get_session() exist = session.query(UserProfile).filter(UserProfile.Email == email).count() > 0 userid = -1 if not exist : user = UserProfile() user.Email = email user.Nick = nick user.Password = password user.EmailVerify = False user.Status = UserStatus.Enabled user.IsAdmin = False user.RegDate = datetime.now() session.add(user) session.commit() userid = user.UserId session.close() return (exist,userid)
import sys from nuteam.models import database, UserProfile,UserStatus, IssueCategory, IssueCategoryStatus from datetime import datetime if '-dropcreate' in sys.argv: database.drop_database() print(u'delete database done!') database.create_database() print(u'create database done!') session = database.get_session() admin = UserProfile() admin.Email = '*****@*****.**' admin.Nick = u'bigdurian' admin.Password = '******' admin.Status = UserStatus.Enabled admin.IsAdmin = True admin.RegDate = datetime.now() session.add(admin) bug = IssueCategory() bug.CategoryName = u'Bug' bug.Status = IssueCategoryStatus.Enabled issue = IssueCategory() issue.CategoryName = u'Issue' issue.Status = IssueCategoryStatus.Enabled session.add(bug) session.add(issue)