2022-03-19 16:19:51 +01:00
|
|
|
from flask_login import current_user
|
|
|
|
|
|
|
|
from usermodel import User
|
|
|
|
from distribusimodel import Distribusis
|
|
|
|
|
|
|
|
|
|
|
|
class DistribusisInfo:
|
2022-03-21 19:54:55 +01:00
|
|
|
def userdistribusinames():
|
2022-03-19 16:19:51 +01:00
|
|
|
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:
|
2022-03-25 15:51:06 +01:00
|
|
|
user = User.query.filter_by(id=distribusi.userid).first()
|
2022-03-19 17:08:04 +01:00
|
|
|
publictheme = (
|
|
|
|
f"{distribusi.distribusiname}/{distribusi.publictheme}",
|
2022-03-25 15:51:06 +01:00
|
|
|
f"""{distribusi.publictheme} used in {distribusi.distribusiname}
|
|
|
|
made by {user.username}""",
|
2022-03-19 16:19:51 +01:00
|
|
|
)
|
2022-03-19 17:08:04 +01:00
|
|
|
publicthemes.append(publictheme)
|
2022-03-19 16:19:51 +01:00
|
|
|
return publicthemes
|
2022-03-20 19:23:39 +01:00
|
|
|
|
|
|
|
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()
|