-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from Himanshuu-Gupta/develop
Merging develop branch to main
- Loading branch information
Showing
35 changed files
with
1,835 additions
and
2 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__all__ = ["user_controller", "profile_controller", "application_controller", 'activity_controller', 'home'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from flask import request | ||
from flask_restful import Resource | ||
from flask_login import login_required | ||
|
||
class Activity(Resource): | ||
|
||
def __init__(self): | ||
self.headers = {'Content-Type': 'text/html'} | ||
|
||
@login_required | ||
def get(self): | ||
return {'about':"hello!"} | ||
|
||
@login_required | ||
def post(self): | ||
some_json=request.get_json() | ||
return {'you sent': some_json}, 201 | ||
|
||
@login_required | ||
def put(self): | ||
some_json=request.get_json() | ||
return {'you sent': some_json}, 201 | ||
|
||
@login_required | ||
def delete(self): | ||
some_json=request.get_json() | ||
return {'you sent': some_json}, 201 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from flask import render_template, request | ||
from flask_restful import Resource | ||
from flask_login import login_required | ||
|
||
|
||
class Application(Resource): | ||
def __init__(self): | ||
self.headers = {'Content-Type': 'text/html'} | ||
|
||
@login_required | ||
def get(self): | ||
return {'about':"hello!"} | ||
|
||
@login_required | ||
def post(self): | ||
some_json=request.get_json() | ||
return {'you sent': some_json}, 201 | ||
|
||
@login_required | ||
def put(self): | ||
some_json=request.get_json() | ||
return {'you sent': some_json}, 201 | ||
|
||
@login_required | ||
def delete(self): | ||
some_json=request.get_json() | ||
return {'you sent': some_json}, 201 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from flask import Blueprint | ||
from flask import Flask, render_template, url_for, request | ||
from flask_login import login_required | ||
home_route = Blueprint('home_route', __name__) | ||
|
||
|
||
data = { | ||
"wishlist": ["Microsoft", "Google", "Uber"], | ||
"inprogress": ["Twitter", "Pearson"], | ||
"applied": ["Amazon", "NetApp"], | ||
"offers": ["Perfios"] | ||
} | ||
|
||
upcoming_events = [ | ||
{"duedate": "28th Sept, 2021", | ||
"company": "Apple" | ||
}, | ||
{"duedate": "19th Dec, 2021", | ||
"company": "Microsoft" | ||
}, | ||
{"duedate": "21st Dec, 2021", | ||
"company": "Amazon" | ||
}, | ||
{"duedate": "21st Dec, 2021", | ||
"company": "Amazon" | ||
}, | ||
{"duedate": "21st Dec, 2021", | ||
"company": "Amazon" | ||
} | ||
] | ||
|
||
profile = { | ||
"name": "Jessica Holds", | ||
"Location": "Raleigh, NC", | ||
"phone_number": "", | ||
"social": { | ||
"linkedin": "www.linkedin.com/in/surajdm", | ||
|
||
} | ||
} | ||
|
||
|
||
@home_route.route('', methods=['GET']) | ||
@login_required | ||
def home(): | ||
return render_template('home.html', data=data, upcoming_events=upcoming_events) | ||
|
||
|
||
@home_route.route('/view', methods=['GET']) | ||
@login_required | ||
def view(): | ||
card_selected = request.args.get('user') | ||
return render_template('view_list.html', data=data, upcoming_events=upcoming_events) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from flask import request | ||
from flask_restful import Resource | ||
from flask_login import login_required | ||
|
||
class Profile(Resource): | ||
def __init__(self): | ||
self.headers = {'Content-Type': 'text/html'} | ||
|
||
@login_required | ||
def get(self): | ||
return {'about':"hello!"} | ||
|
||
@login_required | ||
def post(self): | ||
some_json=request.get_json() | ||
return {'you sent': some_json}, 201 | ||
|
||
@login_required | ||
def put(self): | ||
some_json=request.get_json() | ||
return {'you sent': some_json}, 201 | ||
|
||
@login_required | ||
def delete(self): | ||
some_json=request.get_json() | ||
return {'you sent': some_json}, 201 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from flask import make_response, Blueprint, request, jsonify, render_template | ||
from flask_restful import Resource | ||
from DAO.user_dao import user_dao | ||
from flask_login import login_required | ||
|
||
# add_user = Blueprint('add_user', ) | ||
|
||
# Specify the url end point for the function | ||
class User(Resource): | ||
def __init__(self): | ||
self.headers = {'Content-Type': 'text/html'} | ||
self.user = user_dao() | ||
|
||
@login_required | ||
def get(self): | ||
self.user.get_user() | ||
return make_response('Coming Soon!!') | ||
# return make_response(render_template('home.html', data=data, upcoming_events=upcoming_events), 200, headers) | ||
|
||
@login_required | ||
def post(self): | ||
self.user.create_user() | ||
some_json=request.get_json() | ||
return {'you sent': some_json}, 200 | ||
|
||
@login_required | ||
def put(self): | ||
self.user.update_details() | ||
some_json=request.get_json() | ||
return {'you sent': some_json}, 200 | ||
|
||
@login_required | ||
def delete(self): | ||
self.user.delete_user() | ||
some_json=request.get_json() | ||
return {'you sent': some_json}, 200 | ||
|
||
|
||
|
||
|
||
|
||
|
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import pymysql | ||
import os | ||
class sql_helper: | ||
def __init__(self): | ||
self.connection_obj = None | ||
|
||
def connect_database(self): | ||
try: | ||
self.connection_obj = pymysql.connect( | ||
host= os.environ['aws_rds_host'], | ||
port = 3306, | ||
user = os.environ['aws_rds_user'], | ||
password = os.environ['aws_rds_password'], | ||
db = "wolftrack", | ||
autocommit=True | ||
) | ||
except: | ||
pass | ||
#Need to import error handling class | ||
|
||
def disconnect_database(self): | ||
try: | ||
self.connection_obj.close() | ||
except: | ||
pass | ||
#Need to import error handling class | ||
|
||
def run_query(self, query): | ||
self.connect_database() | ||
tempCursor = self.connection_obj.cursor() | ||
tempCursor.execute(query) | ||
output = tempCursor.fetchall() | ||
self.disconnect_database() | ||
return output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
|
||
class user_dao: | ||
def __init__(self): | ||
pass | ||
|
||
def create_user(self): | ||
pass | ||
|
||
def get_user(self): | ||
pass | ||
|
||
def update_details(self): | ||
pass | ||
|
||
def delete_user(self): | ||
pass | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
|
||
class db_connection_issue(Exception): | ||
pass | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from flask import jsonify, Blueprint, make_response, g, current_app | ||
from custom_error_function import * | ||
handle_err = Blueprint('errors', __name__) | ||
|
||
@handle_err.app_errorhandler(db_connection_issue) | ||
def db_connection_failed(e): | ||
return make_response('Not able to connect to the database, check you connection!', 500) | ||
|
||
@handle_err.app_errorhandler(401) | ||
def unauthorized_request(e): | ||
return make_response("Ohh! looks like you missed to sign in. Please log in!.", 401) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
from flask import Blueprint, session, request, redirect, render_template, current_app, make_response | ||
from flask_login import LoginManager, login_user, UserMixin | ||
from datetime import datetime, timedelta | ||
|
||
login_route = Blueprint('admin', __name__) | ||
login_manager = LoginManager() | ||
headers = {'Content-Type': 'text/html'} | ||
|
||
data = { | ||
"wishlist": ["Microsoft", "Google", "Uber"], | ||
"inprogress": ["Twitter", "Pearson"], | ||
"applied": ["Amazon", "NetApp"], | ||
"offers": ["Perfios"] | ||
} | ||
|
||
upcoming_events = [ | ||
{"duedate": "28th Sept, 2021", | ||
"company": "Apple" | ||
}, | ||
{"duedate": "19th Dec, 2021", | ||
"company": "Microsoft" | ||
}, | ||
{"duedate": "21st Dec, 2021", | ||
"company": "Amazon" | ||
}, | ||
{"duedate": "21st Dec, 2021", | ||
"company": "Amazon" | ||
}, | ||
{"duedate": "21st Dec, 2021", | ||
"company": "Amazon" | ||
} | ||
] | ||
|
||
|
||
@login_route.record_once | ||
def on_load(state): | ||
login_manager.init_app(state.app) | ||
|
||
@login_manager.user_loader | ||
def load_user(userid): | ||
return session['userinfo'][userid] | ||
|
||
@login_route.before_app_request | ||
def before_request(): | ||
session.modified = True | ||
current_app.permanent_session_lifetime = timedelta(minutes=30) | ||
if request.endpoint != 'login_manager.login': | ||
if 'userinfo' not in session: | ||
pass | ||
|
||
class User(UserMixin): | ||
pass | ||
|
||
|
||
def is_valid(username, password): | ||
''' Validate the username and password with DB ''' | ||
return True | ||
|
||
|
||
@login_route.route('', methods=["GET", "POST"]) | ||
def login(): | ||
if request.method == 'GET': | ||
return make_response(render_template('login.html'), 200, headers) | ||
username = request.form['username'] | ||
password = request.form['password'] | ||
if not is_valid(username, password): | ||
pass | ||
user = User() | ||
session['userinfo'] = {'userid': username} | ||
user.id = username | ||
if request.method == 'POST': | ||
login_user(user) | ||
|
||
return make_response(render_template('home.html', data=data, upcoming_events=upcoming_events),301,headers) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from flask import Flask, request, render_template, make_response | ||
from flask_restful import Resource, Api | ||
from Login.login import login_route | ||
from Controller.activity_controller import Activity | ||
from Controller.application_controller import Application | ||
from Controller.profile_controller import Profile | ||
from Controller.user_controller import User | ||
from Controller.home import home_route | ||
|
||
app = Flask(__name__) | ||
api = Api(app) | ||
|
||
api.add_resource(User, '/user') | ||
api.add_resource(Activity, '/activity') | ||
api.add_resource(Profile, '/profile') | ||
api.add_resource(Application, '/application') | ||
app.register_blueprint(login_route, url_prefix='/login') | ||
app.register_blueprint(home_route, url_prefix='/') | ||
app.app_context().push() | ||
|
||
|
||
if __name__ == '__main__': | ||
app.config['SECRET_KEY'] = 'Sample' #os.environ.get('SECRET_KEY') | ||
app.app_context().push() | ||
app.run(debug=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
|
||
test | ||
#requirements | ||
flask | ||
flask_restful | ||
pymysql | ||
flask_login |
Binary file not shown.
Binary file not shown.
Oops, something went wrong.