|
|
|
from flask_login import current_user
|
|
|
|
from models.distribusimodel import Distribusis
|
|
|
|
from models.usermodel import User
|
|
|
|
|
|
|
|
|
|
|
|
class DistribusisInfo:
|
|
|
|
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
|
|
|
|
|
|
|
|
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}""",
|
|
|
|
)
|
|
|
|
publicthemes.append(publictheme)
|
|
|
|
return publicthemes
|
|
|
|
|
|
|
|
def visibledistribusis():
|
|
|
|
distribusis = Distribusis.query.filter(
|
|
|
|
Distribusis.visible.isnot(False)
|
|
|
|
).all()
|
|
|
|
return distribusis
|
|
|
|
|
|
|
|
def getuserdistribusis(useremail):
|
|
|
|
user = User.query.filter_by(email=useremail).first()
|
|
|
|
return Distribusis.query.filter_by(userid=user.id).all()
|