Beispiel #1
0
 def saveAccount(self, event):
     if self.validate():
         if self.mode == "new":
             msg = "Account has been added"
             newAccount = Account(self.accountTxt.GetValue())
             newAccount.setAccountUsername(self.usernameTxt.GetValue())
             if not self.user.isAccountExist(newAccount):
                 self.user.addAccount(newAccount, self.passTxt.GetValue())
                 indexItem = 1
                 if self.list_ctrl.GetItemCount() > 0:
                     indexItem = self.list_ctrl.GetItemCount() + 1
                 index = self.list_ctrl.InsertItem(indexItem,
                                                   newAccount.accountName)
                 self.list_ctrl.SetItem(index, 1,
                                        newAccount.accountUsername)
                 self.showDialog(msg, "Information",
                                 wx.OK | wx.ICON_INFORMATION)
             else:
                 msg = "Account is already exist."
                 self.showDialog(msg, "Error", wx.OK | wx.ICON_ERROR)
         else:
             msg = "Account has been updated"
             self.user.addAccount(self.selectedAccount,
                                  self.passTxt.GetValue())
             self.showDialog(msg, "Information",
                             wx.OK | wx.ICON_INFORMATION)
         self.clearEditAccount()
Beispiel #2
0
 def create(data):
     product = Product(
         name = data["name"],
         stock = data["stock"],
         income = Account.create(data["income"]),
         profit = Account.create(data["profit"]),
         id_ = data["id"],
         purchases = [],
         fixedprice = data["fixedprice"]
     )
     for p in data["purchases"]:
         product.add_purchase(Purchase.create(p))
     return product
Beispiel #3
0
    def create(data, filepath=None):
        version = data["version"]

        if version >= 1 and version <= 2:
            inventory = Inventory.create(data["inventory"])
            accounts = Accounts.create(data["accounts"])
            usage = Usage.create(data["usage"], inventory, accounts)
            comment = data["comment"]
            cash_in_hand = Account.create(data["cash_in_hand"])
            date = data["date"]
            if date is not None:
                date = dateutils.fromtuple(date)

            if version >= 2:
                id_ = data["id"]
                title = data["title"]
            else:
                id_ = uuid4().hex
                title = None
        else:
            raise VersionError("Unknown document version: " % (repr(version),))

        return Document(
            usage = usage,
            accounts = accounts,
            inventory = inventory,
            date = date,
            comment = comment,
            filepath = filepath,
            version = version,
            cash_in_hand = cash_in_hand,
            title = title,
            id_ = id_
        )
    def test_add_remove_account(self):
        accountName = "Google"
        accountUsername = "******"
        accountPass = "******"        
        account = Account(accountName)
        account.setAccountUsername(accountUsername)
        self.user.addAccount(account, accountPass)

        accountList = self.user.getAccountList()
        self.assertEqual(len(accountList), 3)
        self.assertIn(account, accountList)

        self.assertTrue(self.user.isAccountExist(account))
        
        self.user.removeAccount(account)
        self.assertEqual(len(accountList), 2)
        self.assertNotIn(account, accountList)
 def setUpClass(self):
     testUtil.setupData()
     #setup test user data
     self.user = User("test_user")
     self.user.changePassword("test_password")
     #setup some accounts
     account = Account("Facebook")
     account.setAccountUsername("user_fb")
     self.user.addAccount(account, "pass_fb")
     account2 = Account("Instagram")
     account2.setAccountUsername("user_instagram")
     self.user.addAccount(account2, "pass_instagram")
Beispiel #6
0
 def getAccountList(self, force=False):
     if len(self.accountList) > 0 and not force:
         return self.accountList
     else:
         self.accountList.clear()
         accountData = utils.openData(self.username)
         for key in accountData:
             splitKey = key.split("_**_")
             account = Account(splitKey[0])
             account.setAccountUsername(splitKey[1])
             account.setAccountPassword(accountData[key])
             self.accountList.append(account)
         accountData.close()
         return self.accountList
Beispiel #7
0
def get_account(query):

    source = retrieve(SEARCH_URL.format(query.encode("utf-8")))

    source = source.replace("<em>", '').replace("</em>", '').replace(
        "<!--red_beg-->", '').replace("<!--red_end-->", '')

    name = extract_element(source, ACCOUNT_NAME_XPATH)

    text = extract_element(source, ACCOUNT_TEXT_XPATH)

    info = extract_element(source, ACCOUNT_INFO_XPATH)

    auth = extract_element(source, ACCOUNT_AUTH_XPATH)

    current_app.logger.debug("{name} {text} {info} {auth}".format(
        name=name.encode("utf-8"),
        text=text.encode("utf-8"),
        info=info.encode("utf-8"),
        auth=auth.encode("utf-8")))

    if isinstance(info, list):

        info = ""

    if isinstance(auth, list):

        auth = ""

    account = Account(name, text, info, auth)

    db.session.add(account)

    db.session.commit()

    return account
def create_account():
    form = request.json or request.form.to_dict()
    account = Account(**form)
    db.session.add(account)
    db.session.commit()
    return jsonify(status='ok', result=account.id)