distribusi-verse/verse/distribusikan/distribusisinfo.py

39 lines
1.3 KiB
Python
Raw Normal View History

2022-03-19 16:19:51 +01:00
from flask_login import current_user
2024-04-28 13:04:07 +02:00
2024-04-28 15:34:29 +02:00
from models.distribusi_model import Distribusis
from models.user_model import User
2022-03-19 16:19:51 +01:00
class DistribusisInfo:
2024-05-28 23:02:17 +02:00
def userdistribusinames():
distribusinames = []
user = User.query.filter_by(email=current_user.email).first()
for distribusi in Distribusis.query.filter_by(userid=user.id).all():
distribusinames.append(distribusi.distribusiname)
return distribusinames
2022-03-19 16:19:51 +01:00
2024-05-28 23:02:17 +02:00
def publicthemes():
publicthemes = []
distribusis = Distribusis.query.filter(
Distribusis.publictheme.isnot(None)
).all()
for distribusi in distribusis:
user = User.query.filter_by(id=distribusi.userid).first()
publictheme = (
f"{distribusi.distribusiname}/{distribusi.publictheme}",
f"""{distribusi.publictheme} used in {distribusi.distribusiname}
made by {user.username}""",
2024-05-28 23:02:17 +02:00
)
publicthemes.append(publictheme)
return publicthemes
2024-05-28 23:02:17 +02:00
def visibledistribusis():
distribusis = Distribusis.query.filter(
Distribusis.visible.isnot(False)
).all()
return distribusis
2024-05-28 23:02:17 +02:00
def getuserdistribusis(useremail):
user = User.query.filter_by(email=useremail).first()
return Distribusis.query.filter_by(userid=user.id).all()