def post(self): if security.can_modify(request.cookies.get("user")): try: new_card = model.Card(**request.get_json().get("card")) new_card.commit() return jsonify(new_card.dump()) except marshmallow.exceptions.ValidationError as e: abort(400) else: abort(403)
def load_cards(session): with open('seed_data/u.cards', 'rb') as csvfile: reader = csv.reader(csvfile, delimiter="|") for row in reader: type = row[0] action = row[1] image = row[2] new_card = model.Card(id=None, type=type, action=action, image=image) session.add(new_card) session.commit()
def get_acc(card_id): if (acc_validation(card_id)) == True: cursor = cnn.cursor() query = ( '''SELECT acc_id,first_name,last_name,personal_id,acc_fac,b.career,acc_balance FROM usr_acc as a join career as b on a.acc_career = b.career_ID WHERE acc_id = %s''') cursor.execute(query, (card_id, )) access_acc = cursor.fetchone() acc_info = model.Card(access_acc[0], access_acc[1], access_acc[2], access_acc[3], access_acc[4], access_acc[5], access_acc[6]) cnn.commit() cursor.close() return acc_info else: # print ("Account Error: Doesn't Exist") return False
def new_card(n_fname, n_lname, n_pid, n_acc_fac, n_acc_career, n_acc_balance): cursor = cnn.cursor() query = ('''SELECT * FROM usr_acc WHERE personal_id = %s''') cursor.execute(query, (n_pid, )) val = cursor.fetchone() if val is not None: return print("SYSTEM ERROR: Account already exist") else: new_acc = model.Card(0, n_fname, n_lname, n_pid, n_acc_fac, n_acc_career, n_acc_balance) cursor = cnn.cursor() query1 = ('''INSERT INTO usr_acc VALUES(NULL,%s,%s,%s,%s,%s,%s)''') cursor.execute(query1, ( new_acc.first_name, new_acc.last_name, new_acc.personal_ID, new_acc.faculty, new_acc.career, new_acc.current_balance, )) cnn.commit() print("SYSTEM INFO: New Card Account created successfully") return 0
def setUp(self): self.trick_suit = 's' self.trump_card = model.Card('h', '2')
def callcard(self): self.c1 = model.Card() self.c2 = model.Card() self.app.setPhoto(self.c1) self.app.setPhoto(self.c2)
def test_constructor_card_generation(self): deck = model.Deck(1) self.assertNotEqual(deck.draw(), model.Card(model.Suit.CLUBS, model.Value.ACE))
def test_eq_overide(self): card1 = model.Card(model.Suit.HEARTS, model.Value.FIVE) card2 = model.Card(model.Suit.HEARTS, model.Value.FIVE) card3 = model.Card(model.Suit.CLUBS, model.Value.SEVEN) self.assertEqual(card1, card2) self.assertNotEqual(card1, card3)
def test_constructor(self): card = model.Card(model.Suit.HEARTS, model.Value.JACK) self.assertEqual(card.suit, model.Suit.HEARTS) self.assertEqual(card.value, model.Value.JACK)
def handle_place(self, card, x, y): log("Placing card %s at (%d, %d)", card, x, y) card = model.Card(*card) self.layout[(x,y)] = card self.board.draw_card(card, x, y) time.sleep(.1)