Пример #1
0
    def _generate_user(self, group='', actionname='reg_user'):
        '''
        Add new user
        '''
        save_url = self.request.resource_url(self.context, actionname)
        if 'form.submitted' in self.request.params:
            username = self.request.params['username']
            nickname = self.request.params['nickname']
            cintraid = str(int(self.request.params['cintraid']))
            email = self.request.params['email']
            balance = self.request.params['balance']
            points = self.request.params['points']
            experience = self.request.params['experience']
            group = self.request.params['group']
            logging.debug('Creating user: %s, cintraid: %s' %
                          (username, cintraid))
            user = User(username=username,
                        nickname=nickname,
                        cintraid=cintraid,
                        email=email,
                        balance=balance,
                        points=points,
                        experience=experience,
                        group=[group])
            pwd = self.request.params['pwd']
            pwd2 = self.request.params['pwd2']
            user.__name__ = cintraid
            user.__parent__ = self.context
            warnings = {}
            if pwd <> pwd2:
                warnings['pwd'] = 'password not matching'
                return dict(user=user, save_url=save_url, warnings=warnings)

            user.pwd = saltPeper(pwd)
            self.context[cintraid] = user
            approot = self.context.__parent__
            bk = Book(user=user)
            approot['books'][cintraid] = [bk]
            user.books = [bk]
            return HTTPFound(
                location=self.request.resource_url(self.context, cintraid))

        user = User()
        user.__name__ = ''
        user.__parent__ = self.context
        cintraids = sorted([int(cintraid) for cintraid in self.context])
        user.cintraid = str(int(cintraids[-1]) + 1)
        user.group = group or ''
        return dict(user=user, save_url=save_url, message={})
Пример #2
0
    def add_user(self):
        '''
        Add new user
        '''
        save_url = self.request.resource_url(self.context, 'add_user')
        if 'form.submitted' in self.request.params:
            username = self.request.params['username']
            nickname = self.request.params['nickname']
            cintraid = str(int(self.request.params['cintraid']))
            email = self.request.params['email']
            balance = self.request.params['balance']
            points = self.request.params['points']
            experience = self.request.params['experience']
            logging.debug( 'Creating user: %s, cintraid: %s'%(username, cintraid) )
            user = User( username=username, nickname=nickname,
                         cintraid=cintraid, email=email,
                         balance=balance, points=points,
                         experience=experience )
            pwd = self.request.params['pwd']
            pwd2 = self.request.params['pwd2']
            user.__name__ = cintraid
            user.__parent__ = self.context
            warnings = {}
            if pwd <> pwd2:
                warnings['pwd']='password not matching'
                return dict(user=user, save_url=save_url, warnings=warnings)

            self.context.__parent__['security']['userslogininfo'][user.cintraid]=pwd
            self.context[cintraid] = user
            approot = self.context.__parent__
            bk = Book(user=user)
            approot['books'][cintraid] = bk
            user.book = bk 
            return HTTPFound( location = self.request.resource_url(self.context, cintraid) )

        user = User()
        user.__name__ = ''
        user.__parent__ = self.context
        return dict(user=user, save_url=save_url, message={})
Пример #3
0
def appmaker(zodb_root):
    if not 'cintra_root' in zodb_root:
        cintra_root = CintraModel()

        instFolder = InstrumentFolder()
        cintra_root['instruments'] = instFolder
        instFolder.__name__='instruments'
        instFolder.__parent__ = cintra_root

        orderbookFolder = OrderbookFolder()
        cintra_root['orderbooks'] = orderbookFolder
        orderbookFolder.__name__='orderbooks'
        orderbookFolder.__parent__ = cintra_root

        bookFolder = BookFolder()
        cintra_root['books'] = bookFolder
        bookFolder.__name__='books'
        bookFolder.__parent__ = cintra_root

        userFolder = UserFolder()
        cintra_root['users'] = userFolder
        userFolder.__name__ = 'users'
        userFolder.__parent__ = cintra_root

        admincintraid = u'0'
        admin = User( username='******', nickname='beyondcloud',
                      cintraid = admincintraid, email='*****@*****.**',
                      pwd = saltPeper('zerutufz@cintra'),
                      group = ['group:admin'])
        userFolder[admincintraid] = admin
        admin.__name__ = admincintraid
        admin.__parent__ = userFolder

#        securityFolder = SecurityFolder()
#        cintra_root['security'] = securityFolder
#        securityFolder.__name__ = 'security'
#        securityFolder.__parent__ = cintra_root

#        userslogininfo = UsersLoginInfo()
#        cintra_root['security']['userslogininfo'] = userslogininfo
#        userslogininfo.__name__ = 'userslogininfo'
#        userslogininfo.__parent__ = cintra_root['security']

#        groupsinfo = GroupsInfo()
#        cintra_root['security']['groupsinfo'] = groupsinfo
#        groupsinfo.__name__ = 'groupsinfo'
#        groupsinfo.__parent__ = cintra_root['security']

        tradeFolder = TradeFolder()
        cintra_root['trades'] = tradeFolder
        tradeFolder.__name__ = 'trades'
        tradeFolder.__parent__ = cintra_root

        quoteofthedays = QuoteOfTheDayFolder()
        cintra_root['quoteofthedays'] = quoteofthedays
        quoteofthedays.__name__ = 'quoteofthedays'
        quoteofthedays.__parent__ = cintra_root

        zodb_root['cintra_root'] = cintra_root
        import transaction
        transaction.commit()
    return zodb_root['cintra_root']