예제 #1
0
파일: items.py 프로젝트: exhuma/tinvent
    def index(self, categories=None, status=None ):
        identity = request.environ.get( 'repoze.who.identity' )
        user = identity['user']

        me_contact = Contact.find_by_user( user )

        if not me_contact:
           raise ValueError( "Unable to retrieve user-to-contact mapping. For some reason the contact mapping the current user to a contact_id has vanished." )

        return dict( page='index', user=user,
              me_contact = me_contact,
              categories=DBSession.query(Category) )
예제 #2
0
파일: contacts.py 프로젝트: exhuma/tinvent
    def view(self, contact_id):
        identity = request.environ.get( 'repoze.who.identity' )
        user = identity['user']
        me_contact = Contact.find_by_user(user)

        contact_query = DBSession.query( Contact )
        contact_query = contact_query.filter_by( user_id=user.user_id )
        contact_query = contact_query.filter_by( contact_id=contact_id )
        contact = contact_query.first()

        your_items_query = DBSession.query( Item )
        your_items_query = your_items_query.filter_by( holder_id=contact.contact_id )
        your_items_query = your_items_query.filter_by( owner_id=me_contact.contact_id )

        his_items_query = DBSession.query( Item )
        his_items_query = his_items_query.filter_by( holder_id=me_contact.contact_id )
        his_items_query = his_items_query.filter_by( owner_id=contact.contact_id )

        return dict( page='index', user=user, contact=contact,
              his_items_query=his_items_query,
              your_items_query=your_items_query )
예제 #3
0
파일: items.py 프로젝트: exhuma/tinvent
    def view(self, item_id):
        identity = request.environ.get( 'repoze.who.identity' )
        user = identity['user']
        me_contact = Contact.find_by_user( user )
        item = DBSession.query(Item)\
              .filter_by( item_id=item_id )\
              .first()
        if not item:
           raise ValueError( "Item not found!" )
        if item.holder_id != me_contact.contact_id and item.owner_id != me_contact.contact_id:
           raise ValueError( "You neither own nor hold this item! Access Denied!" )

        return dict( item=item )
예제 #4
0
파일: all.py 프로젝트: exhuma/tinvent
 def find_by_user(self, user):
    the_contact = DBSession.query( self )\
            .filter_by( user_id=user.user_id )\
            .filter_by( other_user_id=user.user_id)\
            .first()
    return the_contact
예제 #5
0
파일: __init__.py 프로젝트: exhuma/tinvent
 def test_query_obj(self):
     obj = DBSession.query(self.klass).one()
     for key, value in self.attrs.iteritems():
         assert_equals(getattr(obj, key), value)
예제 #6
0
파일: auth.py 프로젝트: exhuma/tinvent
 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()
예제 #7
0
파일: auth.py 프로젝트: exhuma/tinvent
 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()