Esempio n. 1
0
 def test_tg2app_model(self):
     """ Test creating a new user with the apps model """
     from tg2app.model import User, DBSession
     me = User()
     me.user_name = u'jim'
     me.email_address = u'*****@*****.**'
     DBSession.add(me)
     DBSession.flush()
     assert DBSession.query(User).count() == 1
Esempio n. 2
0
 def test_tg2app_model(self):
     """ Test creating a new user with the apps model """
     from tg2app.model import User, DBSession
     me = User()
     me.user_name = u'jim'
     me.email_address = u'*****@*****.**'
     DBSession.add(me)
     DBSession.flush()
     assert DBSession.query(User).count() == 1
Esempio n. 3
0
    def add_user(self, username):
        my_user = model.User(
                user_name=username,
                email_address=username + '@linkybook.com',
                display_name='No Display Name',
            )
        DBSession.add(my_user)

        redirect('/get_users')
Esempio n. 4
0
 def add_user(self, username):
     if len(username) < 7:
         flash('Too short!')
         redirect('/get_users')
         
     my_user = model.User(
         user_name=username,
         email_address=username + '@abc.com',
         display_name='no display name',
     )
     DBSession.add(my_user)
     
     redirect('/get_users')
Esempio n. 5
0
    def add_user(self, username):
        # http://typhon.csh.rit.edu:9000/add_user?username=foo

        if len(username) != 7:
            redirect('/')

        my_user = model.User(
            user_name=username,
            email_address=username + "@typhon.com",
            display_name='no display name',
        )
        DBSession.add(my_user)

        # Last thing.. redirect to another URL
        redirect('/get_users')
Esempio n. 6
0
 def get_users(self):
     users = DBSession.query(model.User).all()
     return {
         'users': [
             user.to_json() for user in users
         ],
     }
Esempio n. 7
0
 def setup(self):
     try:
         new_attrs = {}
         new_attrs.update(self.attrs)
         new_attrs.update(self.do_get_dependencies())
         self.obj = self.klass(**new_attrs)
         DBSession.add(self.obj)
         DBSession.flush()
         return self.obj
     except:
         DBSession.rollback()
         raise
Esempio n. 8
0
 def setup(self):
     try:
         new_attrs = {}
         new_attrs.update(self.attrs)
         new_attrs.update(self.do_get_dependencies())
         self.obj = self.klass(**new_attrs)
         DBSession.add(self.obj)
         DBSession.flush()
         return self.obj
     except:
         DBSession.rollback()
         raise
Esempio n. 9
0
 def setUp(self):
     """Prepare model test fixture."""
     try:
         new_attrs = {}
         new_attrs.update(self.attrs)
         new_attrs.update(self.do_get_dependencies())
         self.obj = self.klass(**new_attrs)
         DBSession.add(self.obj)
         DBSession.flush()
         return self.obj
     except:
         DBSession.rollback()
         raise
Esempio n. 10
0
 def setUp(self):
     """Prepare model test fixture."""
     try:
         new_attrs = {}
         new_attrs.update(self.attrs)
         new_attrs.update(self.do_get_dependencies())
         self.obj = self.klass(**new_attrs)
         DBSession.add(self.obj)
         DBSession.flush()
         return self.obj
     except:
         DBSession.rollback()
         raise
Esempio n. 11
0
 def test_query_obj(self):
     obj = DBSession.query(self.klass).one()
     for key, value in self.attrs.iteritems():
         assert_equals(getattr(obj, key), value)
Esempio n. 12
0
 def tearDown(self):
     DBSession.rollback()
Esempio n. 13
0
 def tearDown(self):
     """Finish model test fixture."""
     DBSession.rollback()
Esempio n. 14
0
 def test_query_obj(self):
     """Model objects can be queried"""
     obj = DBSession.query(self.klass).one()
     for key, value in self.attrs.iteritems():
         assert_equals(getattr(obj, key), value)
Esempio n. 15
0
 def tearDown(self):
     """Finish model test fixture."""
     DBSession.rollback()
Esempio n. 16
0
 def test_query_obj(self):
     """Model objects can be queried"""
     obj = DBSession.query(self.klass).one()
     for key, value in self.attrs.iteritems():
         assert_equals(getattr(obj, key), value)
Esempio n. 17
0
 def by_email_address(cls, email):
     """Return the user object whose email address is ``email``."""
     return DBSession.query(cls).filter_by(email_address=email).first()
Esempio n. 18
0
 def by_user_name(cls, username):
     """Return the user object whose user name is ``username``."""
     return DBSession.query(cls).filter(cls.user_name == username).first()
Esempio n. 19
0
 def by_email_address(cls, email):
     """Return the user object whose email address is ``email``."""
     return DBSession.query(cls).filter(cls.email_address == email).first()
Esempio n. 20
0
 def tearDown(self):
     DBSession.rollback()
Esempio n. 21
0
 def test_query_obj(self):
     obj = DBSession.query(self.klass).one()
     for key, value in self.attrs.iteritems():
         assert_equals(getattr(obj, key), value)
Esempio n. 22
0
 def by_user_name(cls, username):
     """Return the user object whose user name is ``username``."""
     return DBSession.query(cls).filter_by(user_name=username).first()
Esempio n. 23
0
    def _default(self, *args, **kw):
        """ Serves up the RadialGraph widget """

        assert(len(args) == 1) # how else could it be?
        name = args[0]

        base = DBSession.query(m.FBUser).filter_by(name=name)

        if base.count() == 0 :
            raise LookupError("No such user '%s'" % name)

        if base.count() > 1:
            raise LookupError, "More than one user matches '%s'" % name

        user = base.one()

        # Some color constants for the radial graph
        bg = '#F8F7ED'
        green = '#84CA24'
        blue = '#006295'

        class Tg2AppSQLARadialGraph(SQLARadialGraph):
            id = 'sqlaRadialGraph'
            base_url = '/jit/data/'
            entities = [m.FBUser]
            rootObject = user
            depth = 1

            # Have it occupy the full page
            width = '980'
            height = '980'

            # Have it conform with the site style
            backgroundcolor = bg
            background = { 'CanvasStyles': { 'strokeStyle' : bg } }
            Node = { 'color' : green }
            Edge = { 'color' : blue, 'lineWidth':1.5, }

            # Space things out a little
            levelDistance = 150

            # Override the label style
            onPlaceLabel = JSSymbol(src="""
                (function(domElement, node){
                    domElement.style.display = "none";
                    domElement.innerHTML = node.name;
                    domElement.style.display = "";
                    var left = parseInt(domElement.style.left);
                    domElement.style.width = '120px';
                    domElement.style.height = '';
                    var w = domElement.offsetWidth;
                    domElement.style.left = (left - w /2) + 'px';

                    // This should all be moved to a css file
                    domElement.style.cursor = 'pointer';
                    if ( node._depth <= 1 )
                        domElement.style.color = 'black';
                    else
                        domElement.style.color = 'grey';
                })""")

        return {'widget': Tg2AppSQLARadialGraph}