forked from crunk/distribusi-verse
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.3 KiB
39 lines
1.3 KiB
3 years ago
|
from flask_login import current_user
|
||
7 months ago
|
|
||
7 months ago
|
from models.distribusi_model import Distribusis
|
||
|
from models.user_model import User
|
||
3 years ago
|
|
||
|
|
||
|
class DistribusisInfo:
|
||
6 months ago
|
def user_distribusinames():
|
||
6 months ago
|
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
|
||
3 years ago
|
|
||
6 months ago
|
def public_themes():
|
||
6 months ago
|
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}
|
||
3 years ago
|
made by {user.username}""",
|
||
6 months ago
|
)
|
||
|
publicthemes.append(publictheme)
|
||
|
return publicthemes
|
||
3 years ago
|
|
||
6 months ago
|
def visible_distribusis():
|
||
6 months ago
|
distribusis = Distribusis.query.filter(
|
||
|
Distribusis.visible.isnot(False)
|
||
|
).all()
|
||
|
return distribusis
|
||
3 years ago
|
|
||
6 months ago
|
def get_user_distribusis(useremail):
|
||
6 months ago
|
user = User.query.filter_by(email=useremail).first()
|
||
|
return Distribusis.query.filter_by(userid=user.id).all()
|