def register_handler(self, username=None, password=None, confirm_password=None, y=None, x=None, Submit=None): DBSession = DBSessionmaker() if password == confirm_password and username is not None and password is not None and confirm_password is not None: if DBSession.query(User).filter( User.user_name == username).count() == 0: newuser = User(username, password, 0) normal = DBSession.query(Group).filter( Group.group_name == 'normal').first() newuser.groups = newuser.groups + [normal] DBSession.add(newuser) DBSession.commit() flash(_('Successfully Registered, %s!') % username) redirect('/') else: flash(_('Username %s already registered') % username) redirect('/register') elif password != confirm_password: flash(_('Passwords do not match')) redirect('/register') else: flash(_('Insufficient information')) redirect('/register') return
def guest(self): DBSession = DBSessionmaker() guests = DBSession.query(User).order_by(User.user_name).all() try: guests = DBSession.query(User).order_by(User.user_name).all() except: DBSession.close() redirect('/') last = -1 for guest in guests: if 'GUEST-' in guest.user_name: tmp = int(guest.user_name.split('GUEST-')[1]) if tmp > last: last = tmp username = '******' + str(last + 1) password = '******' confirm_password = '******' if password == confirm_password and username is not None and password is not None and confirm_password is not None: if DBSession.query(User).filter( User.user_name == username).count() == 0: newuser = User(username, password, 0) normal = DBSession.query(Group).filter( Group.group_name == 'normal').first() newuser.groups = newuser.groups + [normal] DBSession.add(newuser) DBSession.commit() DBSession.close() redirect('/auto_login?username='******'&password='******'Username %s already registered') % username) DBSession.close() redirect('/') elif password != confirm_password: flash(_('Passwords do not match')) DBSession.close() redirect('/') else: flash(_('Insufficient information')) DBSession.close() redirect('/')
def register_handler(self, username=None, password=None, confirm_password=None, y=None, x=None, Submit=None): DBSession = DBSessionmaker() if password == confirm_password and username is not None and password is not None and confirm_password is not None: if DBSession.query(User).filter(User.user_name==username).count() == 0: newuser = User(username, password, 0) normal = DBSession.query(Group).filter(Group.group_name=='normal').first() newuser.groups = newuser.groups + [normal] DBSession.add(newuser) DBSession.commit() flash(_('Successfully Registered, %s!') % username) redirect('/') else: flash(_('Username %s already registered') %username) redirect('/register') elif password != confirm_password: flash(_('Passwords do not match')) redirect('/register') else: flash(_('Insufficient information')) redirect('/register') return
def guest(self): DBSession = DBSessionmaker() guests = DBSession.query(User).order_by(User.user_name).all() try: guests = DBSession.query(User).order_by(User.user_name).all() except: DBSession.close() redirect('/') last = -1 for guest in guests: if 'GUEST-' in guest.user_name: tmp = int(guest.user_name.split('GUEST-')[1]) if tmp > last: last = tmp username = '******' + str(last + 1) password = '******' confirm_password = '******' if password == confirm_password and username is not None and password is not None and confirm_password is not None: if DBSession.query(User).filter(User.user_name==username).count() == 0: newuser = User(username, password, 0) normal = DBSession.query(Group).filter(Group.group_name=='normal').first() newuser.groups = newuser.groups + [normal] DBSession.add(newuser) DBSession.commit() DBSession.close() redirect('/auto_login?username='******'&password='******'Username %s already registered') %username) DBSession.close() redirect('/') elif password != confirm_password: flash(_('Passwords do not match')) DBSession.close() redirect('/') else: flash(_('Insufficient information')) DBSession.close() redirect('/')