From ce726fb6b37eeba80b02581333792d5eef1a55fc Mon Sep 17 00:00:00 2001 From: crunk Date: Sat, 19 Mar 2022 18:17:04 +0100 Subject: [PATCH] removed selector, file renamed --- verse/selector.py | 69 ----------------------------------------------- 1 file changed, 69 deletions(-) delete mode 100644 verse/selector.py diff --git a/verse/selector.py b/verse/selector.py deleted file mode 100644 index c13a302..0000000 --- a/verse/selector.py +++ /dev/null @@ -1,69 +0,0 @@ -import os -import shutil -from flask import flash -from flask_login import current_user -from sqlalchemy.exc import ( - DataError, - DatabaseError, - InterfaceError, - InvalidRequestError, -) - -from usermodel import User -from distribusimodel import Distribusis - - -from forms.selectorform import SelectorForm -from statuspengguna.helper import HasDistribusi -from statuspengguna.helper import DistribusiSelected -from statuspengguna.helper import SelectCurrentDistribusi -from app import db - - -def SelectNewDistribusi(): - print("make a new distribusi") - selectorform = SelectorForm() - SelectCurrentDistribusi("new") - return selectorform - - -def SelectUpdateDistribusi(distribusiname): - print(f"Update this distribusi {distribusiname}") - selectorform = SelectorForm() - SelectCurrentDistribusi(distribusiname) - return selectorform - - -def DeleteDistribusi(distribusiname): - print(f"delete this distribusi {distribusiname}") - selectorform = SelectorForm() - try: - user = User.query.filter_by(email=current_user.email).first() - distribusi = Distribusis.query.filter_by( - distribusiname=distribusiname - ).first() - if distribusi.userid is user.id: - db.session.delete(distribusi) - db.session.commit() - userfolder = os.path.join("stash", distribusi.distribusiname) - shutil.rmtree(userfolder) - cssfolder = os.path.join( - "themes/userthemes", - distribusi.distribusiname - ) - shutil.rmtree(cssfolder) - except (InvalidRequestError, DataError, InterfaceError, DatabaseError): - db.session.rollback() - selectorform.distribusis.errors.append("Unknown error occured!") - flash("An error occured !", "danger") - return selectorform - - -def SelectorVisible(): - has_distribusi = HasDistribusi() - distribusi_selected = DistribusiSelected() - if distribusi_selected: - return False - if not has_distribusi: - return False - return True