Changeset 1223
- Timestamp:
- 12/18/06 09:40:49 (6 years ago)
- File:
-
- 1 edited
-
ccsd/trunk/crcnetd/modules/ccs_billing.py (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ccsd/trunk/crcnetd/modules/ccs_billing.py
r1195 r1223 22 22 Plan stuff 23 23 """ 24 def addPlan(details): 24 @exportViaXMLRPC(SESSION_RW, AUTH_ADMINISTRATOR, True) 25 def addPlan(self,details): 25 26 """ 26 27 Adds a plan into the database. … … 30 31 Returns true on success 31 32 """ 32 props = ["plan_name", "description", "price", "raduis_plan", \ 33 34 session = getSessionE(self._session_id) 35 props = ["plan_name", "description", "price", "radius_plan", \ 33 36 "included_mb", "cap_period", "cap_action", "cap_param", \ 34 37 "cap_price"] … … 38 41 39 42 session.execute(sql,(values)) 40 41 42 def updatePlan(plan_id, newDetails): 43 return True 44 45 @exportViaXMLRPC(SESSION_RW, AUTH_ADMINISTRATOR, True) 46 def editPlan(self, newDetails): 43 47 """ 44 48 Updates the plan with the id of plan_id with the details in … … 48 52 returns true on success. 49 53 """ 50 54 session = getSessionE(self._session_id) 51 55 props = ["plan_name","description","price","radius_plan", \ 52 56 "included_mb", "cap_period", "cap_action", "cap_param", \ 53 57 "cap_price"] 54 58 (sql, values) = buildUpdateFromDict("billing_plan", props, 55 newDetails, "plan_id", plan_id)59 newDetails, "plan_id", newDetails["plan_id"]) 56 60 57 61 if values == None: … … 59 63 60 64 session.execute(sql, values) 61 62 65 return True 66 63 67 @exportViaXMLRPC(SESSION_RW, AUTH_ADMINISTRATOR, True) 64 68 def removePlan(self, plan_id): … … 78 82 @exportViaXMLRPC(SESSION_RO, AUTH_ADMINISTRATOR, True) 79 83 def listPlans(self): 84 """ 85 Returns a list of all plans. 86 """ 80 87 session = getSessionE(self._session_id) 81 88 … … 84 91 return session.query(sql,()) 85 92 86 87 88 93 89 94 @exportViaXMLRPC(SESSION_RO, AUTH_ADMINISTRATOR, True) … … 100 105 return res[0] 101 106 107 @exportViaXMLRPC(SESSION_RO, AUTH_ADMINISTRATOR, True) 108 def getRadiusPlans(self): 109 """ 110 Gets a list of all radius plans and returns it. 111 """ 112 session = getSessionE(self._session_id) 113 114 sql = "SELECT * FROM radius_plan" 115 116 return session.query(sql, ()) 117 102 118 """ 103 119 Customer stuff, includes user name and password. 104 120 """ 105 def updateCustomer(contact_id, newDetails):106 """107 Updates a customer. newDetails is a dictionary containing only the108 fields that need updating109 """110 111 def removeCustomer(contact_id):112 """113 Removes a customer from the database with the id of contact_id.114 """115 116 121 @exportViaXMLRPC(SESSION_RO, AUTH_ADMINISTRATOR, True) 117 122 def getCustomerList(self): … … 126 131 def editCustomer(session_id, details): 127 132 session = getSessionE(session_id) 128 133 tim 129 134 editContact(session_id, details) 130 135 if not details.has_key("plan_id"): … … 141 146 details["billing_address"], details["contact_id"])) 142 147 148 sql = "SELECT included_mb, radius_plan FROM plans WHERE plan_id=%s" 149 150 res = session.query(sql, (details["plan_id"])) 151 152 sql = "UPDATE customer_state SET plan_start=CURRENT_TIMESTAMP, " \ 153 "radius_plan=%s, plan_id=%s, cap_at_mb=%s" 154 155 session.execute(sql, (res[0]["radius_plan"], details["plan_id"], res[0]["included_mb"])) 143 156 return details["contact_id"] 144 157 … … 173 186 res = session.query(sql, (details["plan_id"])) 174 187 188 #Set up the customer state table. 175 189 sql = "INSERT INTO customer_state VALUES(%s,%s,CURRENT_TIMESTAMP, "\ 176 190 "%s,%s,CURRENT_TIMESTAMP,%s)"
Note: See TracChangeset
for help on using the changeset viewer.
