# <center><i class="fa fa-edit"></i> Smart Dispenser: `members_addtional_Card` Subfunction Testing Cont. </center> ###### tags: `Internship` :::info **Goal:** - [x] Test run the current code - [x] Make changes to current code accordingly **Resources:** [PyQt](https://hackmd.io/Ibk_VuuWRXOjkION4wk3tg) [newXinXingPyQtStructure](https://drive.google.com/drive/u/0/folders/1Ahr8zkZgUv8ujauLKGz1ZSzkZq0M9_mx) [CodiMD](https://hackmd.io/c/codimd-documentation/%2F%40codimd%2Fextra-supported-syntax#Flow-Chart) [冠辰參考的筆記](https://www.wongwonggoods.com/page/4/?s=pyqt&ct_post_type=post%3Apage&ct_product_price=1) ::: --- :::spoiler **Expand Catalog** [TOC] ::: --- ### Figures *Figure 1. Open a new collection members_additional_card* ![](https://i.imgur.com/HIZq4rs.jpg) *Figure 2. Flowchart* ![](https://i.imgur.com/KeSi6dk.jpg) --- ### Changes to Code :::warning Ended up making a delete function in addition to the planned ones ([can be referenced here](https://hackmd.io/@tiffanycheng/ry3LHLn55)) ::: **Delete Function** * A delete function was added to delete all occurrences of the unregistered user with the additonal card ID in `members_data` as designed in flowchart(See Figure 2). * Had to double check with Ren about how to identify if a user is unregistered. * Originally thought there would be a delete function in `XinxingQt.py` since it is served to query and update the collection. However, it did not include one. ![](https://i.imgur.com/g76ICap.png) **Main Method** * Previously prompted the user to input the primary card ID before adding data to the `members_addtional_card` collection. * However, this is highly subject to error due to user input. * The user input may be wrong. * Checking if the input they enter is correct is too tedious. * Instead, it is easier to find when the `primaryCard` field is equal to the `additionalCard` field. * Then, take that field and put it in the collection as the `primaryCard` for the user. * This translates to the long search query using the and expression for when the `SchoolID` is `s and ` when the `primaryCard` field is equal to the `additionalCard` field. * The partition is conveniently set upso that index `0` of `index[2]` is the first digit in the primary Card ID. * The verify function is called again just to make sure the system has correctly extracted a 10 digit string. * Added the last line to delete all occurrences of the unregistered user with the additonal card ID in `members_data`. ![](https://i.imgur.com/SNo3kxT.png) :::warning The domain for the [Smart Dispenser's MongoDB](mongodb://admin:bmwee8097218@140.118.122.115:30415/) was down so I could not test my code until the next day (7/8) :::