def Master(): user = Usuarium() user.set() # Missing some logic here return render_template('master.html', title='Master', user=user)
def retain(): trial = Usuarium() # here we test that the object works as desired, if trial.nm == '' and trial.dpt == '': # that it initialises as an empty string trial.set() # that it activates the object with the active user return len(trial.nm) > 1 and len( trial.dpt) > 1 # and that it retains information correctly
def HR(): user = Usuarium() user.set() list = [] if request.method == 'GET': list = MySQL.get( 'SELECT hr.date, hr.details, e.nature, hr.manager, hr.amount FROM HR hr JOIN expenses e ON hr.expense_id=e.id;' ) return render_template('dpt-hr.html', title='Human Resources', user=user, list=list)
def sales(): user = Usuarium() user.set() list = [] if request.method == 'GET': list = MySQL.get( 'SELECT s.date, e.name, e.surname, s.amount FROM sales s JOIN employee e ON s.employee_id=e.id;' ) return render_template('dpt-sales.html', title='Sales', user=user, list=list)
def nemployee(): user = Usuarium() user.set() grab_data = new_employee() msg = '' if request.method == 'POST': grab_data, mmsg = employee_logic(grab_data, user) return render_template('nemployee.html', title='New employee', form=grab_data, message=msg, user=user)
def deals(): user = Usuarium() user.set() grab_data = deales() msg = '' if request.method == 'POST': grab_data, msg = dealfunct(grab_data) return render_template('deals.html', title='Deals', user=user, form=grab_data, message=msg)
def expenses(): user = Usuarium() user.set() grab_data = new_expense() msg = '' if request.method == 'POST' and user.department() == 'HR': grab_data, msg = fexpenses(grab_data, user) return render_template('expenses.html', title='Expenses page', form=grab_data, user=user, message=msg)
def Mastersales(): user = Usuarium() user.set() grab_data = deletings() msg = 'Dan' list = [] if request.method == 'GET': list = DanSQL().get( ' SELECT s.date, c.company_name, s.amount FROM sales s JOIN client c ON s.client_id=c.id;' ) if request.method == 'POST': action = grab_data.action.data selection = grab_data.selection.data msg = f'Not Dan, POST{action}, {selection}' if int(action) == 1: list = DanSQL().get( f"SELECT * from sales WHERE date='{selection}';") msg = f'Not Dan, POST{action}, {selection}' return render_template('mastersales.html', title='HR edit', form=grab_data, list=list, user=user, message=msg) elif int(action) == 2: DanSQL().write(f"DELETE from sales WHERE date='{selection}';") msg = 'Enty deleted successfully' return render_template('mastersales.html', title='HR edit', form=grab_data, list=list, user=user, message=msg)
def what(): user = Usuarium() user.set() grab_data = deleting() msg = 'Dan' list = [] if request.method == 'GET': list = DanSQL().get( 'SELECT hr.date, hr.details, e.nature, hr.manager, hr.amount FROM HR hr JOIN expenses e ON hr.expense_id=e.id;' ) if request.method == 'POST': action = grab_data.action.data selection = grab_data.selection.data msg = '' if int(action) == 1: list = DanSQL().get(f"SELECT * from HR WHERE date='{selection}';") msg = 'This is what you selected' return render_template('masterhr.html', title='HR edit', form=grab_data, list=list, user=user, message=msg) elif int(action) == 2: DanSQL().write(f"DELETE from HR WHERE date='{selection}';") msg = 'Entry deleted' return render_template('masterhr.html', title='HR edit', form=grab_data, list=list, user=user, message=msg)
def client(): user = Usuarium() user.set() grab_data = new_client() grab = selection() editing = updating() msg = '' if request.method == 'POST': grab_data, msg = process_client(grab_data) editing, msg = navigating_client(editing) return render_template('client.html', form3=editing, message=msg, form1=grab, form=grab_data, user=user)
def login(): user = Usuarium() template = 'login.html' form = verifyU() msg = '' if request.method == 'POST' and user.check(form.login.data, form.passwd.data) == True: user.set() template = identitydirect(user) # Confirms the user and directs us # to the right template elif request.method == 'POST': msg = 'Please, wrong username or password' return render_template(template, title='Log-in', form=form, message=msg, user=user)
app = Flask(__name__) app.config[ 'SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:[email protected]/main' app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.config['SECRET_KEY'] = 'dAnIel52' db = SQLAlchemy(app) """ Now some logic for the app and its routes """ user = Usuarium() # We create an object to control the user login MySQL = DanSQL() @app.route('/home') @app.route('/') def home(): return render_template('home.html') @app.route('/login', methods=['GET', 'POST']) def login(): user = Usuarium()
def runcheck(any): trial = Usuarium( ) # Here we test that out object does the job checking the user return trial.check(any, 'QA123@') # in the login menu
def RedirectLogic(user_dpt): attempt = Usuarium() attempt.dpt = user_dpt # we modify the department directly return identitydirect(attempt) # This method takes in a Usuarium object