Giter VIP home page Giter VIP logo

employees's Introduction

Employees

This was originally a test assignment written (mainly) on Flask + SQLAlchemyORM. It complies with the following requirements:

Madndatory:

Create a webpage that displays an employee hierarchy as a tree structure containing the following data:

  • Name
  • Position
  • Date of hire
  • Salary
  • Each employee has only 1 supervisor
  • The database must contain at least 50,000 employees and 5 levels of hierarchy.

Optional:

  1. Create the database using Flask migrations.
  2. Use Twitter Bootstrap to create basic styles for your page.
  3. Create a separate page to display a list of employees with all the employees’ information.
  4. Extend task #3 with the ability to sort and search by any field without reloading the page (e.g. by using ajax).
  5. Using standard Flask functions, add user authentication and create a section available only for registered users.
  6. Transfer the functionality developed in tasks 3 and 6 to a section accessible only to registered users.
  7. In the section accessible only to registered users, implement the remaining CRUD operations for employee records, including changing the superviosr.
  8. Implement lazy loading for the employees tree.

Installing

Run following commands (in that order recommended)

Python

With Python PIP installed run:

pip install -r requirements.txt

For MySQL DB

If used with MySQL as opposed to the default SQLite, also requires MySQL client:

pip install -r optional-requirements.txt

Please checl SQLalchemy documentation on requirements for running other SQL dialects.

Javascript and CSS

With NPM installed:

npm install

This installs the bower package manager to handle the UI necessary components. Then run:

node_modules/bower/bin/bower install

Quickstart

Database

The application uses the 'DATABASE_URL' environment variable to connect to the database. If unspecified, the application will be using the deafult SQLite database in the 'app.db' file in the root directory of the app.

Schema

This package uses flask-Migrate. To upgrade an empty schema run these commands:

flask db upgrade

Seeding

Package includes a seeder which relies on the seeding/positions.txt file data that follows following format:

top_lvl_position_name, number_of_employees, salary
2_lvl_position_name, number_of_employees, salary
...

Posiitons are evaluated top down, with each employee on a level getting as many subordinates as is indicated on the next level down. E.g. in the example provided file (that wil lresult in 65843 employees generated by default), each Country Manager gets 8 Regional Managers in their subordination, each of which gets 8 Branch managers in turn, and so on. Names of the employees are generated randomly as provided by the Faker package (included in the requirements.txt.).

To seed the DB, please use the flask shell command to run interpreter with necessary context already in place and then execute following code:

seeder = DbSeeder()
seeder.seed()
db.session.commit()

This will populate the Database with the entire hierarchy structure as provided in the seeding/positions.txt file. Alternatively, you can set an arbitrary number of levels to be processed from the top, if you would like a smaller hierarchy without having to change the positions file, like so:

seeder = DbSeeder()
seeder.seed(4)
db.session.commit()

This will result in seeding only the top 4 levels of the file.

Running

You can run the application locally with the following command:

flask run

Which (by default) will start serving the application at http://127.0.0.1:5000/

employees's People

Contributors

longneko avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.