You are on page 1of 4

Documentation

The project is a flask app which is developed using Python

1) How to run:
You just a text editor to run this code (VS code) is preferable. Open the terminal and
simply run the command python main.py in order to start execution of the program.
Furthermore, you need to have following things installed which can be done using following
commands:
 Pip install firebase
 Pip install python_jwt
 Pip install gcloud
 pip install cryptodom or
 pip pycryptodome==3.4.3
2) Template Folder:
The template folder consist of HTML files which make up the view
3) Python Files
The project consist of following python files
 Room.py
 Users.py
 DataHandler.py
 main.py

4) Room.py
Room file has a class named room and has two functions
1) def __init__(self):
This is the constructor of class room it declares the attributes, which
room class object will have. The attributes are

 Room Number (which also works as key)


 Beds : int (number of beds in room)
 AC : string (if the room has AC or not)
 Window : string (if the room has window or not)
 Rate : int (record of rate of room)
 Booked : bool (verifies if room is booked or not)
2) def getiterable(self):
This function do the work of converting data types into a list, list
is used as data structure to store information into database. Once the data related to
room is inserted into it than this function converts the information stored in different
variables into a iterable list.
5) User.py
User file has class named user which has two functions
1) def __init__(self):
This is the constructor of class user it declares the attributes, which
user class object will have. The attributes are

 ID : int (which also works as key)


 email : string (this string stores email of the user)
 password : string (this string stores the password of
the user)
 name : string (this string will hold the name of the
user)
2) def matchEmailPassword(email, password):
This function is a validatory one. This function
receives email and password as argument and then compare the credentials with the
data present in the database and return True if credential exits in the database else
returns False.

6) DataHanlder.py
This is the class which act as the controller all the data manipulation
occurs in this file. In this class the previous are imported. The csv class is also imported.
DataHandler class has following functions in it:
1) def __init__(self):
This is the constructor of class datahandler it declares the attributes,
which user class object will have. The attribute along with their data structures are as
follow
 users : List() (this is a List which stores all the
user)
 rooms : List() (this is a List which stores all the
available rooms)
2) def readAllUsers():

This function reads all the available users from the database and then
iterate over the list and the attributes are stored into the object of USER is read and stored
into the list of user.

3) def readAllRooms():
This function reads all the available rooms from the database file and
then iterate over the list and the attributes are stored into the of the object of ROOM is
read and stored into the list of user.

5) def addRoom(room_number, beds, ac, window, rate, booked):


The function
addRoom() has basic functionality of adding new room to the database of
available rooms. It receives all the information related to the room and then try
inserting into database. If the room is tried to be added twice the function will
not insert data into database and return FALSE but if the room is unique
meaning inserted for the first time the function will return TRUE after
successful insertion.
6) def validateUser(email,password):
The basic functionality of this function
validateUser() is to validate if the new user who is trying to log in has a account
or not. The data is sent to function matchEmailPassword(email, password) of
class USER and validation is completed.
7) def getBookedRooms(self , obj):
This function has the functionality of
displaying booked rooms. Firstly, the project read all the rooms from the database
than results are filtered on basis of rooms which have been booked by user. All
booked rooms are appended into the list which is returned to the view class
(main.py).
8) def bookTheRoom(self , roomNumber, obj):
The functionality of this function is
to book a room for user. User enters the room number which he wants to book through
view the room number and the object of database is passed to the function. The function
validates if the room is not booked already and returns failure if so. If room hasn’t been
booked yet the room is booked for success signal is returned.

9) def searchRooms(self ,obj, bed, ac, window):


This function searches the room based
on the queries of the user. The view ask users for number of beds he wants, if window
is required and ac. This information is sent to searchRoom() function. The function
filters room based on these credentials and then send the list of room if any.
10) def cancelRoom(self ,obj, roomNumber):
This function has the functionality of
cancelling a room’s booking. Room Number is sent to the function. The function retrieve
data from the database, than iterate over the result. If the entered room number is present in
the database and is also booked it returns successful cancellation signal. If the entered
room number is not present or is not booked yet invalidity signal is returned to the view.

11) def deleteRoom(self ,obj, roomNumber):


This function has basic functionality of
deleting a room permanently from the database. Room Number which has to be deleted is
sent to this function the function first check if room exits in the database, if it does then
booking is checked. If room is booked it can’t be deleted and failure signal is returned to
the view. Only not booked room can be deleted.

7) Main.py
This file act as a view. All the views are rendered from this file and data is
manipulated between controller and then model classes. The class has following
functions in it. These functions responds to different on screen events which takes place
at model.

1) def main():
When the app start execution main run and this function starts its
execution at first. This function renders the log in page. User enter his email
and password and validateUser() is called if the credential are valid user is
logged into the account and userAccount.html page is rendered this is the main
menu page and control is handled to the userAccount() function. In case
credentials are not validated invalid credentials message is displayed and user
are asked to reenter the credentials.
2) def userAccount():
This function renders all the rooms in the database to
user on logging in. Along with this all the buttons which provides different are render.
Display all room, search specific room, book a room, delete a room, add a new room, delete a
room, delete booking, log out all these are displayed here in the view.
 If user clicks on the button Display all rooms readAllRooms() function is called from
DataHandler which returns all the available rooms.
 If user clicks the button add new room, a new pages is rendered and control is
handled to the addRoom() function which ask user to enter room number, beds, ac,
window, rate of room and calls bookRoom() function.
 If user clicks the button add delete room, a new pages is rendered and control is
handled to the deleteRoom() function. The new page ask user to enter the room
number. After this function from DataHandler is called which delete The Room if it
has not been booked already.
 If user clicks the button bookRoom() new page is rendered which asks the user to
enter the room which he wants to book and bookRoom() function is called from the
DataHandler class.
 When use clicks the button log out it is retured to the log in pages where he has to log
in again.

You might also like