Advertisement
Guest User

Untitled

a guest
May 31st, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.79 KB | None | 0 0
  1. class FaxLine(StormContainer):
  2. """FaxLine object
  3.  
  4. Verify if the class implements the interfaces:
  5.  
  6. >>> from zope.interface.verify import verifyClass
  7. >>> verifyClass(IFaxLine, FaxLine)
  8. True
  9.  
  10. Create a testing database:
  11.  
  12. >>> import transaction
  13. >>> from voipeople.zsqlobject import create_testingdb
  14. >>> zstorm, store = create_testingdb('voipeople')
  15.  
  16. Verify that the object implements the interfaces:
  17.  
  18. >>> from voipeople.content import Account, Address, Department, FaxLine, List
  19. >>> account = Account(legal_name=u'Kynetix S.r.l.', vat_rate = 20, billing_type_id =1)
  20. >>> dummy = store.add(account)
  21. >>> transaction.get().commit()
  22. >>> address = Address(line1=u'DUMMY', city=u'DUMMY', state=u'DUMMY',
  23. ... zip_code=u'00000', country=u'DUMMY', account=account)
  24. >>> dummy = store.add(address)
  25. >>> transaction.get().commit()
  26. >>> list = List(description=u'Voipeople Gold')
  27. >>> dummy = store.add(list)
  28. >>> transaction.get().commit()
  29. >>> department = Department(description=u'DUMMY',
  30. ... account=account, address=address)
  31. >>> dummy = store.add(department)
  32. >>> transaction.get().commit()
  33. >>> faxline = FaxLine(password=u'granata', security = 1,
  34. ... fax_number_id=2,department=department,
  35. ... salelist=list, account=account, delivery_email=u'mr@voipeople.it',username=u'marco')
  36. >>> dummy = store.add(faxline)
  37. >>> transaction.get().commit()
  38. >>> from zope.interface.verify import verifyObject
  39. >>> verifyObject(IFaxLine, faxline)
  40. True
  41.  
  42. Verify data and relations:
  43.  
  44. >>> faxline.username
  45. u'marco'
  46. >>> faxline.department.description
  47. u'DUMMY'
  48. >>> faxline.department.account.legal_name
  49. u'Kynetix S.r.l.'
  50.  
  51. Clean up the testing database:
  52.  
  53. >>> zstorm.remove(store)
  54.  
  55. """
  56.  
  57. implements(IFaxLine, IVoipeopleSecurity)
  58.  
  59. __storm_table__ = 'fax_lines'
  60. __storm_items__ = ('senderemails', 'faxdetailrecords')
  61.  
  62. def __get_name(self):
  63. return unicode(self.id)
  64. def __set_name(self, value):
  65. pass
  66. __name__ = property(__get_name, __set_name)
  67.  
  68. def __get_parent(self):
  69. app = getSite()
  70. if IVoipeopleApplication.providedBy(app):
  71. return app['faxlines']
  72. return None
  73. def __set_parent(self, value):
  74. pass
  75. __parent__ = property(__get_parent, __set_parent)
  76.  
  77. id = SQL.Int(primary=True)
  78.  
  79. username = SQL.Unicode()
  80.  
  81. password = SQL.Unicode()
  82.  
  83. delivery_email = SQL.Unicode()
  84.  
  85. delivery_name = SQL.Unicode()
  86.  
  87. sent_fax = SQL.Int()
  88.  
  89. security = SQL.Bool()
  90.  
  91. fax_number_id = SQL.Int()
  92. faxnumber = SQL.Reference(fax_number_id, 'FaxNumber.id')
  93.  
  94. status = SQL.Unicode(default=u'N')
  95.  
  96. faxdetailrecords = SQL.ReferenceSet(id, "FaxDetailRecord.fax_line_id")
  97.  
  98. senderemails = SQL.ReferenceSet(id, "SenderEmail.fax_line_id")
  99.  
  100. #serviceslines = SQL.ReferenceSet(id, "ServiceLine.fax_line_id")
  101.  
  102. #flatratestatus = SQL.ReferenceSet(id, "SenderEmail.fax_line_id")
  103.  
  104. department_id = SQL.Int()
  105. department = SQL.Reference(department_id, 'Department.id')
  106.  
  107. sale_list_id = SQL.Int()
  108. salelist = SQL.Reference(sale_list_id, 'List.id')
  109.  
  110. account_id = SQL.Int()
  111. account = SQL.Reference(account_id, 'Account.id')
  112.  
  113. @staticmethod
  114. def get_info():
  115. info = {
  116. 'search_field': FaxLine.username,
  117. 'interface': IFaxLine,
  118. 'fields': ('username', 'password', 'faxnumber', 'status','delivery_email', 'delivery_name', 'department', 'salelist')
  119. }
  120. return info
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement