Skip to content

Commit

Permalink
Merge pull request #19 from ArpithaVijayakumar/feature/add_Application
Browse files Browse the repository at this point in the history
Changes to DDL and pending API
  • Loading branch information
Krishika510 authored Nov 3, 2021
2 parents 54bc62b + e8a7be1 commit be7aba7
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 32 deletions.
10 changes: 6 additions & 4 deletions Controller/application_controller.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
from flask import render_template, request
from flask_restful import Resource
from flask_login import login_required

from DAO.application_dao import application_dao

class Application(Resource):
def __init__(self):
self.headers = {'Content-Type': 'text/html'}
self.application = application_dao()

@login_required
def get(self):
return {'about':"hello!"}

@login_required
def post(self):
some_json=request.get_json()
return {'you sent': some_json}, 201
def post(self, email, company_name, location, job_profile, salary, username, password, security_question, security_answer, notes,
date_applied):
return self.application.add_application(email, company_name, location, job_profile, salary, username, password, security_question, security_answer, notes,
date_applied)

@login_required
def put(self):
Expand Down
7 changes: 6 additions & 1 deletion Controller/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
from flask_login import login_required, logout_user
from werkzeug.utils import redirect
from Controller.user_controller import User
from Controller.application_controller import Application
home_route = Blueprint('home_route', __name__)

user = User()
application = Application()
email = ''


data = {
"wishlist": ["Microsoft", "Google", "Uber"],
Expand Down Expand Up @@ -58,6 +62,7 @@ def loginUser():
email = request.form["username"]
password = request.form["password"]
result = user.get(email,password)
print(result)
error = ""
if(result == 0):
error = "Email does not exits. Please enter a valid email."
Expand Down Expand Up @@ -98,7 +103,7 @@ def add_new_application():
security_answer = request.form["securityAnswer"]
notes = request.form["notes"]
date_applied = request.form["dateApplied"]
result = user.post(company_name, location, job_profile, salary, username, password, security_question, security_answer, notes,
result = application.post(email, company_name, location, job_profile, salary, username, password, security_question, security_answer, notes,
date_applied)
if (result==0):
error = "This job application could not be stored in the database. Please try again."
Expand Down
21 changes: 18 additions & 3 deletions DAO/application_dao.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
from sql_helper import sql_helper
from DAO.sql_helper import sql_helper
from DAO import user_dao

user = user_dao()

class application_dao:
def create_application(self):
pass
def add_application(self, email, company_name, location, job_profile, salary, username, password, security_question, security_answer, notes,
date_applied):

userId = self.__db.run_query("SELECT user_id FROM user WHERE email='"+email+"'")[0][0]

self.__db.run_query("CALL CreateCompany('"+company_name+"');")
companyId = self.__db.run_query("SELECT company_id FROM company WHERE company_name='"+company_name+"'")[0][0]

self.__db.run_query("CALL CreateRoles('"+job_profile+"');")
roleId = self.__db.run_query("SELECT role_id FROM roles WHERE role='"+job_profile+"'")[0][0]

self.__db.run_query("CALL CreateRecruiter('"+job_profile+"');")

return self.__db.run_query("CALL CreateApplication('userId','"+name+"','"+password+"');")

def get_application(self):
pass
Expand Down
2 changes: 2 additions & 0 deletions DAO/user_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def get_user(self, email, password):
return data
else:
return 2

def get_user_id(self, email):


def update_details(self):
Expand Down
24 changes: 0 additions & 24 deletions sql/ddl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,6 @@ CREATE TABLE IF NOT EXISTS `wolftrack`.`roles` (
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `wolftrack`.`recruiter`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `wolftrack`.`recruiter` ;

CREATE TABLE IF NOT EXISTS `wolftrack`.`recruiter` (
`recruiter_id` INT NOT NULL AUTO_INCREMENT,
`company_id` INT NOT NULL,
`name` VARCHAR(45) NOT NULL,
`email` VARCHAR(45) NULL,
`link` VARCHAR(45) NULL,
PRIMARY KEY (`recruiter_id`),
INDEX `company_id_idx` (`company_id` ASC) VISIBLE,
FOREIGN KEY (`company_id`)
REFERENCES `wolftrack`.`company` (`company_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `wolftrack`.`application`
-- -----------------------------------------------------
Expand All @@ -99,7 +79,6 @@ CREATE TABLE IF NOT EXISTS `wolftrack`.`application` (
`user_id` INT NOT NULL,
`company_id` INT NOT NULL,
`role_id` INT NOT NULL,
`recruiter_id` INT NULL,
`application_date` TIMESTAMP NOT NULL,
`job_description` VARCHAR(100) NULL,
`salary` FLOAT NULL,
Expand All @@ -111,7 +90,6 @@ CREATE TABLE IF NOT EXISTS `wolftrack`.`application` (
INDEX `user_id_idx` (`user_id` ASC) VISIBLE,
INDEX `role_id_idx` (`role_id` ASC) VISIBLE,
INDEX `company_id_idx` (`company_id` ASC) VISIBLE,
INDEX `recruiter_id_idx` (`recruiter_id` ASC) VISIBLE,
FOREIGN KEY (`user_id`)
REFERENCES `wolftrack`.`user` (`user_id`)
ON DELETE NO ACTION
Expand All @@ -124,8 +102,6 @@ CREATE TABLE IF NOT EXISTS `wolftrack`.`application` (
REFERENCES `wolftrack`.`company` (`company_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
FOREIGN KEY (`recruiter_id`)
REFERENCES `wolftrack`.`recruiter` (`recruiter_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
Expand Down

0 comments on commit be7aba7

Please sign in to comment.