-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deserealizadores con marshmallow y endpoints funcionando correctamente
- Loading branch information
Showing
6 changed files
with
160 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
class Node: | ||
def __init__(self, data=None, next_node=None): | ||
self.data = data | ||
self.next_node = next_node | ||
|
||
class LinkedList: | ||
def __init__(self): | ||
self.head = None | ||
self.last_node = None | ||
|
||
def to_list(self): | ||
l = [] | ||
if self.head is None: | ||
return l | ||
|
||
node = self.head | ||
while node: | ||
l.append(node.data) | ||
node = node.next_node | ||
return l | ||
|
||
def print_ll(self): | ||
ll_string = "" | ||
node = self.head | ||
if node is None: | ||
print(None) | ||
while node: | ||
ll_string += f" {str(node.data)} ->" | ||
node = node.next_node | ||
ll_string += " None" | ||
print(ll_string) | ||
|
||
def insert_beginning(self, data): | ||
if self.head is None: | ||
self.head = Node(data, None) | ||
self.last_node = self.head | ||
|
||
new_node = Node(data, self.head) | ||
self.head = new_node | ||
|
||
|
||
def insert_at_end(self, data): | ||
if self.head is None: | ||
self.insert_beginning(data) | ||
return | ||
|
||
self.last_node.next_node = Node(data, None) | ||
self.last_node = self. last_node.next_node | ||
|
||
def get_user_by_id(self, user_id): | ||
node = self.head | ||
while node: | ||
if node.data["id"] is int(user_id): | ||
return node.data | ||
node = node.next_node | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from flask_sqlalchemy import model | ||
from sepomex.__init__ import ma | ||
from sepomex.models import User, States, Records | ||
|
||
|
||
class UserSchema(ma.SQLAlchemyAutoSchema): | ||
class Meta: | ||
model = User | ||
load_instance = True | ||
include_relationships= True | ||
|
||
class StateSchema(ma.SQLAlchemyAutoSchema): | ||
class Meta: | ||
model = States | ||
include_relationships= True | ||
load_instance = True | ||
|
||
class StateSchemaNoRel(ma.SQLAlchemyAutoSchema): | ||
class Meta: | ||
model = States | ||
load_instance = True | ||
|
||
class RecordSchema(ma.SQLAlchemyAutoSchema): | ||
class Meta: | ||
model = Records | ||
load_instance = True | ||
include_fk = True |