stc

a simple time card webapp
git clone _git@git.brennen.work:stc.git
Log | Files | Refs | README

.old.app.py (2426B)


      1 import datetime
      2 import json
      3 from models import Users
      4 from flask import Flask, render_template, abort, redirect, url_for, request, session, jsonify;
      5 from flask_login import UserMixin, login_user, LoginManager, login_required, logout_user, current_user;
      6 from pymongo import MongoClient;
      7 from flask_bcrypt import Bcrypt;
      8 # import routes
      9 
     10 OrganizationName = "Youth Employment Program"
     11 
     12 app = Flask(__name__)
     13 
     14 
     15 # Mongo setup
     16 client = MongoClient('localhost', 27017)
     17 bcrypt = Bcrypt(app)
     18 db = client['simple_timecard_database']
     19 app.config['SECRET_KEY'] = 'secretkey'
     20 # Mongo setup
     21 
     22 
     23 # Database collections/documents
     24 users_col = db.users_collection # Make aditional user info single document/array
     25 
     26 time_col = db.time_data_collection
     27 
     28 fleet_col = db.fleet_collection
     29 
     30 agreement_col = db.agreement_collection
     31 # Database collections/documents
     32 
     33 
     34 # Page Routes
     35 @app.route('/') #main route should check if user is logged in, then redirect to /dashboard else redirect to /login
     36 def hello():
     37     return render_template('index.html',ORGNAME = OrganizationName) #This implimentation is messy, maybe abstract to a defPage()?
     38 
     39 @app.route("/login")
     40 def login():
     41     return render_template('login.html',ORGNAME = OrganizationName)
     42 
     43 @app.route("/dashboard")
     44 def dashboard():
     45     return render_template('dashboard/layout.html',currenttime=datetime.datetime.utcnow(),ORGNAME=OrganizationName)
     46 
     47 @app.route("/admin")
     48 def admin():
     49     return render_template ('admin/layout.html',ORGNAME=OrganizationName)
     50 
     51 @app.route("/hours")#modify to take userid ex. /hours<userid> for "admin"
     52 def hours():#userid goes into call to db to get user[] -> then returns formatted table (punchclock/index.html
     53     return render_template ('dashboard/punchclock/index.html',ORGNAME=OrganizationName)
     54 
     55 @app.route("/fleet")
     56 def fleet():
     57     return render_template('dashboard/fleet/index.html',ORGNAME=OrganizationName)
     58 
     59 @app.route("/admin/roles")
     60 def roles():
     61     return render_template('admin/roles/index.html',ORGNAME=OrganizationName)
     62 
     63 @app.route("/admin/agreement")
     64 def agreement():
     65     return render_template('admin/agreement/index.html',ORGNAME=OrganizationName)
     66 
     67 @app.route("/docs")
     68 def knowlegebase():
     69     return render_template('knowlegebase/index.html',ORGNAME=OrganizationName)
     70 
     71 # Page Routes
     72 
     73 
     74 # Model Routes
     75 
     76 @app.route('/user/signup', methods=['GET'])
     77 def signup():
     78     return Users().signup()
     79 
     80 # Model Routes
     81 
     82 if __name__ == '__main__':
     83     app.run(debug=True)