Ejemplo n.º 1
0
    def post(self, id_=None):
        data = tornado.escape.json_decode(self.request.body)

        cb = CardBase(front=data['front'], back=data['back'])
        card = Card(cardbase=cb)
        self.session.add(card)
        self.session.commit()
        self.write(card.asDict())
Ejemplo n.º 2
0
 def get(self, text):
     c = Card()
     cards = []
     card = c.by_name(text)
     if card is None:
         cards = c.match_name(text)
     else:
         cards.append(card)
     return cards
Ejemplo n.º 3
0
    def get(self, text):
	c= Card()
	cards = []
	card = c.by_name(text)	
	if card is None:
	    cards = c.match_name(text)
	else:
	    cards.append(card)
	return cards
Ejemplo n.º 4
0
def add_card_to(card_schema: CardSchema, username=Depends(auth_wrapper)):
    try:
        with SQLITE_DB.atomic():
            query = PersonORM.select().where(PersonORM.username == username)
            for person in query:
                CardORM.create(card_id=card_schema.card_id,
                               title=card_schema.title,
                               PAN=card_schema.PAN,
                               expiry_mm=card_schema.expiry_mm,
                               expiry_yyyy=card_schema.expiry_yyyy,
                               security_code=card_schema.security_code,
                               date=card_schema.date,
                               owner=person)

    except Exception as error:
        raise error
    return dict(message="Card successfully registered")
Ejemplo n.º 5
0
def make_transfer(transfer_schema: TransferSchema, username=Depends(auth_wrapper)):
    try:
        with SQLITE_DB.atomic():
            person = Person.select().where(Person.username == username).get()
            friend = Person.select().where(Person.user_id == transfer_schema.friend_id).get()
            card = Card.select().where(Card.card_id == transfer_schema.billing_card.card_id).get()

            BankStatement.create(
                user_id=person,
                friend_id=friend,
                value=transfer_schema.total_to_transfer,
                date=datetime.today().date(),
                from_card=card
            )
    except Exception as error:
        raise error
Ejemplo n.º 6
0
def all_bank_statement(username=Depends(auth_wrapper)):
    try:
        with SQLITE_DB.atomic():
            bs_list = []
            query = BankStatementORM.select()
            for bs in query:
                person = PersonORM.select().where(
                    PersonORM.id == bs.user_id).get()
                friend = PersonORM.select().where(
                    PersonORM.id == bs.friend_id).get()
                card = CardORM.select().where(CardORM.id == bs.from_card).get()
                bs_dict = dict(user_id=person.user_id,
                               friend_id=friend.user_id,
                               value=bs.value,
                               date=bs.date,
                               from_card=card.card_id)
                bs_list.append(bs_dict)
            return bs_list
    except Exception as error:
        raise error
Ejemplo n.º 7
0
def bank_statement_by_userid(userid: str, username=Depends(auth_wrapper)):
    try:
        with SQLITE_DB.atomic():
            person = PersonORM.select().where(
                PersonORM.user_id == userid).get()
            query = BankStatementORM.select().where(
                BankStatementORM.user_id == person.id)
            bs_person_list = []
            for bs in query:
                friend = PersonORM.select().where(
                    PersonORM.id == bs.friend_id).get()
                card = CardORM.select().where(CardORM.id == bs.from_card).get()

                bs_dict = dict(user_id=person.user_id,
                               friend_id=friend.user_id,
                               value=bs.value,
                               date=bs.date,
                               from_card=card.card_id)
                bs_person_list.append(bs_dict)
            return bs_person_list
    except Exception as error:
        pass
Ejemplo n.º 8
0
def get_all_cards_by_person(username=Depends(auth_wrapper)):
    try:
        with SQLITE_DB.atomic():
            person = PersonORM.select().where(
                PersonORM.username == username).get()
            query = (CardORM.select().where(CardORM.owner == person))
            cards = []
            for card_row in query:
                card_dict = {
                    "card_id": card_row.card_id,
                    "title": card_row.title,
                    "PAN": card_row.PAN,
                    "expiry_mm": card_row.expiry_mm,
                    "expiry_yyyy": card_row.expiry_yyyy,
                    "security_code": card_row.security_code,
                    "date": card_row.date
                }
                cards.append(card_dict)

            return cards
    except Exception as error:
        raise error
Ejemplo n.º 9
0
 def get(self):
     c = Card()
     return c.pick_n(1)
Ejemplo n.º 10
0
 def get(self, id=230):
     c = Card()
     return c.show(start=int(id))
Ejemplo n.º 11
0
 def get(self):
     c = Card()
     return c.pick_n(1)
Ejemplo n.º 12
0
 def get(self, id=230):
     c = Card()
     return c.show(start=int(id))