--- a/iro/controller/viewinterface.py Sat Jan 28 04:03:15 2012 +0100
+++ b/iro/controller/viewinterface.py Sat Jan 28 04:03:46 2012 +0100
@@ -141,8 +141,8 @@
'''
- user = session.query(User).filter_by(name=user.name).first()
- return [u.offer_name for u in user.rights if u.isDefault == True]
+ offers = session.query(Userright.offer_name).join(Offer,User).filter(and_(User.name==user.name,Offer.typ==typ,Userright.isDefault==True))
+ return [u[0] for u in offers]
@vUser
def statistic(self, user):
--- a/tests/xmlrpc.py Sat Jan 28 04:03:15 2012 +0100
+++ b/tests/xmlrpc.py Sat Jan 28 04:03:46 2012 +0100
@@ -142,6 +142,19 @@
self.failUnlessEqual(self.__rpc2().routes('abcdef123456789','sms'),['sipgate_basic','sipgate_plus'])
self.failUnlessEqual(self.__rpc2().routes('abcdef123456789','fax'),['faxde'])
+ def testDefaultRoutes(self):
+ '''test the defaultRoute function'''
+ with WithSession(md.engine, autocommit=True) as session:
+ u=User(name='test',apikey='abcdef123456789')
+ o=Offer(name="sipgate_basic", provider="sipgate", route="basic", typ="sms")
+ u.rights.append(Userright(o,True))
+ o=Offer(name="sipgate_plus", provider="sipgate", route="plus", typ="sms")
+ u.rights.append(Userright(o))
+ session.add(u)
+ self.failUnlessEqual(self.__rpc2().defaultRoute('abcdef123456789','sms'),['sipgate_basic'])
+
+
+
def startReactor(engine):
"""starts the Rector with a special debug Clild, so that the reactor can be stopped remotly. """
from twisted.internet import reactor