Changeset 1223


Ignore:
Timestamp:
12/18/06 09:40:49 (6 years ago)
Author:
ijm1
Message:

Added functionality for adding and editing plans. editCustoemr also updated so that it updates the customer_state table when a customers plan changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ccsd/trunk/crcnetd/modules/ccs_billing.py

    r1195 r1223  
    2222    Plan stuff 
    2323    """ 
    24     def addPlan(details): 
     24    @exportViaXMLRPC(SESSION_RW, AUTH_ADMINISTRATOR, True) 
     25    def addPlan(self,details): 
    2526        """ 
    2627        Adds a plan into the database. 
     
    3031        Returns true on success 
    3132        """ 
    32         props = ["plan_name", "description", "price", "raduis_plan", \ 
     33 
     34        session = getSessionE(self._session_id) 
     35        props = ["plan_name", "description", "price", "radius_plan", \ 
    3336                "included_mb", "cap_period", "cap_action", "cap_param", \ 
    3437                "cap_price"] 
     
    3841 
    3942        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): 
    4347        """ 
    4448        Updates the plan with the id of plan_id with the details in  
     
    4852        returns true on success. 
    4953        """ 
    50          
     54        session = getSessionE(self._session_id) 
    5155        props = ["plan_name","description","price","radius_plan", \ 
    5256                "included_mb", "cap_period", "cap_action", "cap_param", \ 
    5357                "cap_price"] 
    5458        (sql, values) = buildUpdateFromDict("billing_plan", props,  
    55                 newDetails, "plan_id", plan_id) 
     59                newDetails, "plan_id", newDetails["plan_id"]) 
    5660 
    5761        if values == None: 
     
    5963 
    6064        session.execute(sql, values) 
    61          
    62          
     65        return True 
     66 
    6367    @exportViaXMLRPC(SESSION_RW, AUTH_ADMINISTRATOR, True) 
    6468    def removePlan(self, plan_id): 
     
    7882    @exportViaXMLRPC(SESSION_RO, AUTH_ADMINISTRATOR, True) 
    7983    def listPlans(self): 
     84        """ 
     85        Returns a list of all plans. 
     86        """ 
    8087        session = getSessionE(self._session_id) 
    8188         
     
    8491        return session.query(sql,()) 
    8592 
    86          
    87      
    8893     
    8994    @exportViaXMLRPC(SESSION_RO, AUTH_ADMINISTRATOR, True) 
     
    100105        return res[0] 
    101106     
     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 
    102118    """ 
    103119    Customer stuff, includes user name and password. 
    104120    """ 
    105     def updateCustomer(contact_id, newDetails): 
    106         """ 
    107         Updates a customer. newDetails is a dictionary containing only the 
    108         fields that need updating 
    109         """ 
    110  
    111     def removeCustomer(contact_id): 
    112         """ 
    113         Removes a customer from the database with the id of contact_id. 
    114         """ 
    115      
    116121    @exportViaXMLRPC(SESSION_RO, AUTH_ADMINISTRATOR, True) 
    117122    def getCustomerList(self): 
     
    126131def editCustomer(session_id, details): 
    127132    session = getSessionE(session_id) 
    128      
     133    tim 
    129134    editContact(session_id, details) 
    130135    if not details.has_key("plan_id"): 
     
    141146        details["billing_address"], details["contact_id"])) 
    142147     
     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"])) 
    143156    return details["contact_id"] 
    144157     
     
    173186    res = session.query(sql, (details["plan_id"])) 
    174187     
     188    #Set up the customer state table. 
    175189    sql = "INSERT INTO customer_state VALUES(%s,%s,CURRENT_TIMESTAMP, "\ 
    176190        "%s,%s,CURRENT_TIMESTAMP,%s)" 
Note: See TracChangeset for help on using the changeset viewer.