mirror of
https://github.com/jwinterm/tubbymemes.git
synced 2026-10-17 05:21:28 +02:00
show user data in meme api export
This commit is contained in:
@@ -43,6 +43,10 @@ class User(db.Model):
|
||||
moderator = db.relationship('Moderator', back_populates='user')
|
||||
memes = db.relationship('Meme', back_populates='user')
|
||||
|
||||
def as_dict(self):
|
||||
return {c.key: getattr(self, c.key)
|
||||
for c in inspect(self).mapper.column_attrs if c.key != 'nonce'}
|
||||
|
||||
def __repr__(self):
|
||||
return str(self.handle)
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ def memes():
|
||||
memes = Meme.query.filter(Meme.approved == True).all()
|
||||
for meme in memes:
|
||||
all_memes[meme.id] = meme.as_dict()
|
||||
all_memes[meme.id]['user'] = meme.user.as_dict()
|
||||
return jsonify(all_memes)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user