def job_mission_publish(): print("job_mission_publish") from models.Mission import Mission from models.Account import Account mission_list = Mission.objects(is_publish=True, is_send=False) for row in mission_list: account_list = None if row.acc_type == 0 and row.creator_acc_type == 20: account_list = Account.objects(acc_parent_id=row.creator_acc_id, acc_confirmed=True) if row.acc_type == 0 and row.creator_acc_type == 30: account_list = Account.objects(acc_type__ne=30, acc_confirmed=True) if row.acc_type == 20 and row.creator_acc_type == 30: account_list = Account.objects(acc_type=20, acc_confirmed=True) for account in account_list: mission = Mission() mission.mission_id = str(row.id) mission.acc_id = str(account._id) mission.mission_title = row.mission_title mission.mission_body = row.mission_body mission.mission_completed = False mission.mission_completed_date = None mission.is_publish = True mission.is_send = True mission.save() from AppRun import application template = application.jinja_env.get_or_select_template( "templates/acc_mission.html") context = {'link': "request.host_url"} from models.MailQue import MailQue MailQue.add_quee(acc_id=str(account._id), body=template.render(context), subject="Cankan VIP için yeni bir görevin var", to=account.acc_email) row.is_send = True row.count_publish = account_list.count() row.save() print("job_mission_publish OK!")
def parse_csv(path: str, encoding="windows-1252"): _transactions = [] _offset = 8 with open(path, encoding=encoding, newline="") as csv_file: _reader = reader(csv_file, delimiter=";", quotechar='"') for _row in _reader: _line = _reader.line_num if _line == 1: _account_number = _row[1] elif _line == 2: _account_type = _row[1] elif _line == 3: _account_currency = _row[1] elif _line == 4: _account_balance_date = parse_date(_row[1]) elif _line == 5: _account_balance_euros = parse_amount(_row[1]) elif _line == 6: _account_balance_francs = parse_amount(_row[1]) elif _line > _offset: _transactions.append( Transaction(date=parse_date(_row[0]), memo=_row[1], amount=parse_amount(_row[2]), amount_francs=parse_amount(_row[3]))) _account = Account(number=_account_number, type=_account_type, currency=_account_currency, balance_date=_account_balance_date, balance=_account_balance_euros, balance_francs=_account_balance_francs) _data = Data(account=_account, transactions=_transactions) return _data
def register_account(user_id): account = db.session.query(Account).get(user_id) db.session.commit() if account == None: account = Account(user_id, 0) db.session.add(account) db.session.commit() return True return False
def main(): client = Client("Ana", 20, "ana@ana") clientrepository = ClientRepository() account = Account(1234, 20000, client) accountrepository = AccountRepository() clientrepository.save(client) accountrepository.save(account) print("clientes") clientrepository.get() print("cuentas") accountrepository.get()
def post(self): try: SS = StorageSecurity() parser = reqparse.RequestParser() parser.add_argument("user") parser.add_argument("website") parser.add_argument("username") parser.add_argument("password") args = parser.parse_args() print(args) #encrypt the password args["password"] = SS.encrypt(args["password"]) Account.save(args) return {"status": "success"}, 200 except Exception as e: print(e) return {"status": "failure", "msg": "server error"}, 500
def register_account(user_id): #Consulta por llave primaria account = db.session.query(Account).get(user_id) db.session.commit( ) #Es posible que esto no sea necesario con otro motor de BD, pero en SQLite evita problemas de hilos if account == None: account = Account(user_id, 0) db.session.add(account) db.session.commit() return True return False
def get(self): try: SS = StorageSecurity() parser = reqparse.RequestParser() parser.add_argument("user") args = parser.parse_args() accounts = Account.getByUserId(args["user"]) if accounts and len(accounts) > 0: """ decrypt the passwords """ for account in accounts: account["password"] = SS.decrypt(account["password"]) return accounts elif accounts and len(accounts) == 0: return {"msg": "No accounts found"} except Exception as e: print(e) return {"status": "failed", "msg": "server error"}, 500
def new_account(): user_id = get_jwt_identity() user = User.query.get(user_id) if not user: return abort(401, description="Invalid user") account_fields = account_schema.load(request.json) new_account = Account() new_account.company_name = account_fields["company_name"] new_account.website = account_fields["website"] new_account.industry = account_fields["industry"] new_account.is_active = account_fields["is_active"] user.account_id.append(new_account) db.session.add(new_account) db.session.commit() return jsonify(account_schema.dump(new_account))
def __init__(self): self.data: Dict[int, Account] = {0: Account(0), 1: Account(1)}
from models.Account import Account from app import app user = Account(firstName="Will", lastName="Vuong", age="12") @app.route('/') def Hello(): return user print(user.firstName) # if __name__ == '__main__': # app.run()