diff --git a/src/app/docs/build/html/searchindex.js b/src/app/docs/build/html/searchindex.js
index 59b678b..af43ccb 100644
--- a/src/app/docs/build/html/searchindex.js
+++ b/src/app/docs/build/html/searchindex.js
@@ -1 +1 @@
-Search.setIndex({docnames:["index"],envversion:{"sphinx.domains.c":1,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":1,"sphinx.domains.javascript":1,"sphinx.domains.math":2,"sphinx.domains.python":1,"sphinx.domains.rst":1,"sphinx.domains.std":1,sphinx:56},filenames:["index.rst"],objects:{"views.forms":{get_task_form_elements:[0,1,1,""]},"views.index":{Index:[0,2,1,""]},"views.index.Index":{GET:[0,3,1,""]},views:{forms:[0,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","function","Python function"],"2":["py","class","Python class"],"3":["py","method","Python method"]},objtypes:{"0":"py:module","1":"py:function","2":"py:class","3":"py:method"},terms:{"class":0,"int":0,"return":0,The:0,budget:0,defin:0,descript:0,determin:0,element:0,form:0,get:0,get_task_form_el:0,identifi:0,index:0,input:0,main:0,modul:0,page:0,param:0,project:0,search:0,self:[],set:0,show:0,str:0,task:0,task_descript:0,task_titl:0,titl:0,type:0,url:0,using:0,variabl:0,view:0,which:0},titles:["Welcome to beelance2\u2019s documentation!"],titleterms:{beelance2:0,document:0,indic:0,tabl:0,welcom:0}})
\ No newline at end of file
+Search.setIndex({docnames:["index"],envversion:{"sphinx.domains.c":1,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":1,"sphinx.domains.javascript":1,"sphinx.domains.math":2,"sphinx.domains.python":1,"sphinx.domains.rst":1,"sphinx.domains.std":1,sphinx:56},filenames:["index.rst"],objects:{"models.login":{get_users:[0,1,1,""],match_user:[0,1,1,""]},"models.project":{get_categories:[0,1,1,""],get_project_by_id:[0,1,1,""],get_projects_by_participant_and_status:[0,1,1,""],get_projects_by_status_and_category:[0,1,1,""],get_projects_by_status_and_owner:[0,1,1,""],set_project:[0,1,1,""],set_task:[0,1,1,""]},"models.register":{set_user:[0,1,1,""]},"views.forms":{get_new_project_form:[0,1,1,""],get_project_form_elements:[0,1,1,""],get_task_form_elements:[0,1,1,""]},"views.index":{Index:[0,2,1,""]},"views.index.Index":{GET:[0,3,1,""]},"views.login":{Login:[0,2,1,""]},"views.login.Login":{GET:[0,3,1,""],POST:[0,3,1,""]},"views.logout":{Logout:[0,2,1,""]},"views.logout.Logout":{GET:[0,3,1,""]},"views.new_project":{New_project:[0,2,1,""]},"views.new_project.New_project":{GET:[0,3,1,""],POST:[0,3,1,""],compose_form:[0,3,1,""],get_task_count:[0,3,1,""]},"views.open_projects":{Open_projects:[0,2,1,""]},"views.open_projects.Open_projects":{GET:[0,3,1,""]},"views.project":{Project:[0,2,1,""]},"views.project.Project":{GET:[0,3,1,""]},"views.register":{Register:[0,2,1,""]},"views.register.Register":{GET:[0,3,1,""],POST:[0,3,1,""]},"views.utils":{get_nav_bar:[0,1,1,""]},models:{login:[0,0,0,"-"],project:[0,0,0,"-"],register:[0,0,0,"-"]},views:{forms:[0,0,0,"-"],utils:[0,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","function","Python function"],"2":["py","class","Python class"],"3":["py","method","Python method"]},objtypes:{"0":"py:module","1":"py:function","2":"py:class","3":"py:method"},terms:{"boolean":0,"class":0,"int":0,"new":0,"return":0,"true":0,The:0,about:0,add:0,adding:0,address:0,all:0,applic:0,attempt:0,authent:0,bar:0,belong:0,budget:0,categori:0,category_nam:0,categoryid:0,catergoryid:0,check:0,citi:0,client:0,code:0,combin:0,compani:0,complet:0,compos:0,compose_form:0,contain:0,correct:0,correspond:0,count:0,countri:0,creat:0,credenti:0,data:0,databas:0,defin:[],descript:0,determin:0,divid:0,element:0,elemet:0,exist:0,fals:0,filter:0,form:0,four:0,from:0,full:0,full_nam:0,gener:0,get:0,get_categori:0,get_nav_bar:0,get_new_project_form:0,get_project_by_id:0,get_project_form_el:0,get_projects_by_participant_and_statu:0,get_projects_by_status_and_categori:0,get_projects_by_status_and_own:0,get_task_count:0,get_task_form_el:0,get_us:0,html:0,identifi:0,index:0,info:0,input:0,its:0,kill:0,list:0,live:0,log:0,login:0,logout:0,main:0,make:0,markup:0,match_us:0,model:0,modul:0,name:0,nav:0,navig:0,new_project:0,number:0,object:0,one:0,open:0,open_project:0,other:0,out:0,own:0,owner:0,page:0,param:0,particip:0,password:0,phone:0,phone_numb:0,post:0,postal:0,postal_cod:0,project:0,project_descript:0,project_statu:0,project_titl:0,projectid:0,readi:0,redirect:0,regist:0,registr:0,remov:0,repres:0,reset:0,retreiv:0,retriev:0,search:0,select:0,self:[],session:0,set:0,set_project:0,set_task:0,set_us:0,show:0,singl:0,specif:0,state:0,statu:0,store:0,str:0,street:0,street_address:0,task:0,task_descript:0,task_titl:0,titl:0,type:0,uniqu:0,url:0,use:0,user:0,userid:0,usernam:0,using:0,util:0,variabl:0,view:0,web:0,where:0,which:0},titles:["Welcome to beelance2\u2019s documentation!"],titleterms:{beelance2:0,document:0,indic:0,tabl:0,welcom:0}})
\ No newline at end of file
diff --git a/src/app/docs/source/index.rst b/src/app/docs/source/index.rst
index e01cea5..55e9d89 100644
--- a/src/app/docs/source/index.rst
+++ b/src/app/docs/source/index.rst
@@ -13,9 +13,44 @@ Welcome to beelance2's documentation!
.. autoclass:: views.index.Index
:members:
+.. autoclass:: views.login.Login
+ :members:
+
+
+.. autoclass:: views.logout.Logout
+ :members:
+
+
+.. autoclass:: views.new_project.New_project
+ :members:
+
+
+.. autoclass:: views.open_projects.Open_projects
+ :members:
+
+
+.. autoclass:: views.project.Project
+ :members:
+
+
+.. autoclass:: views.register.Register
+ :members:
+
.. automodule:: views.forms
:members:
+.. automodule:: views.utils
+ :members:
+
+.. automodule:: models.login
+ :members:
+
+.. automodule:: models.project
+ :members:
+
+.. automodule:: models.register
+ :members:
+
Indices and tables
==================
diff --git a/src/app/models/login.py b/src/app/models/login.py
index 813519c..7c12600 100644
--- a/src/app/models/login.py
+++ b/src/app/models/login.py
@@ -1,6 +1,10 @@
from models.database import db
def get_users():
+ """
+ Retreive all registrered users from the database
+ :return: users
+ """
cursor = db.cursor()
query = ("SELECT userid, username from users")
cursor.execute(query)
@@ -9,6 +13,15 @@ def get_users():
return users
def match_user(username, password):
+ """
+ Check if user credentials are correct, return if exists
+
+ :param username: The user attempting to authenticate
+ :param password: The corresponding password
+ :type username: str
+ :type password: str
+ :return: user
+ """
cursor = db.cursor()
query = ("SELECT userid, username from users where username = \"" + username +
"\" and password = \"" + password + "\"")
diff --git a/src/app/models/project.py b/src/app/models/project.py
index e545fad..5d4e1b3 100644
--- a/src/app/models/project.py
+++ b/src/app/models/project.py
@@ -1,6 +1,11 @@
from models.database import db
def get_categories():
+ """
+ Get all categories
+
+ :return: List of categories
+ """
cursor = db.cursor()
query = ("SELECT * FROM project_category")
cursor.execute(query)
@@ -9,6 +14,21 @@ def get_categories():
return categories
def set_project(categoryid, userid, project_title, project_description, project_status):
+ """
+ Store a project in the database
+
+ :param categoryid: The id of the corresponding category
+ :param userid: The id of the project owner
+ :param project_title: The title of the project
+ :param project_description: The project description
+ :param project_status: The status of the project
+ :type categoryid: str
+ :type userid: str
+ :type project_title: str
+ :type project_description: str
+ :type project_status: str
+ :return: The id of the new project
+ """
cursor = db.cursor()
query = ("INSERT INTO projects VALUES (NULL, \"" +
categoryid + "\", \"" + userid + "\", \"" + project_title + "\", \"" +
@@ -20,6 +40,12 @@ def set_project(categoryid, userid, project_title, project_description, project_
return projectid
def get_project_by_id(projectid):
+ """
+ Retrieve a project by its id
+ :param projectid: The project id
+ :type projectid: str
+ :return: The selected project
+ """
cursor = db.cursor()
query = ("SELECT * FROM projects WHERE projectid = \"" +
projectid + "\"")
@@ -28,6 +54,15 @@ def get_project_by_id(projectid):
return project
def get_projects_by_status_and_category(categoryid, project_status):
+ """
+ Retrieve all projects from a category with a specific status
+
+ :param catergoryid: The id of the category
+ :param project_status: The status to filter on
+ :type catergoryid: str
+ :type project_status: str
+ :return: A list of projects
+ """
cursor = db.cursor()
query = ("SELECT * FROM projects WHERE project_status = \"" +
project_status + "\" AND categoryid = \"" + categoryid + "\"")
@@ -36,6 +71,15 @@ def get_projects_by_status_and_category(categoryid, project_status):
return projects
def get_projects_by_status_and_owner(userid, project_status):
+ """
+ Retrieve all projects owned by a user with a specific status
+
+ :param userid: The id of the owner
+ :param project_status: The status to filter on
+ :type userid: str
+ :type project_status: str
+ :return: A list of projects
+ """
cursor = db.cursor()
query = ("SELECT * FROM projects WHERE project_status = \"" +
project_status + "\" AND userid = \"" + userid + "\"")
@@ -44,6 +88,15 @@ def get_projects_by_status_and_owner(userid, project_status):
return projects
def get_projects_by_participant_and_status(userid, project_status):
+ """
+ Retrieve all projects where the user is a participant with specific status
+
+ :param userid: The id of the participant
+ :param project_status: The status to filter on
+ :type userid: str
+ :type project_status: str
+ :return: A list of projects
+ """
cursor = db.cursor()
query = ("SELECT * FROM projects, projects_users WHERE projects.project_status = \"" +
project_status + "\" AND projects_users.userid = \"" + userid +
@@ -53,10 +106,23 @@ def get_projects_by_participant_and_status(userid, project_status):
return projects
def set_task(projectid, task_title, task_description, budget):
+ """
+ Create a task
+
+ :param projectid: The corresponding project id
+ :param task_title: The title of the task
+ :param task_description: The description of the task
+ :param budget: The task budget
+ :type projectid: str
+ :type task_title: str
+ :type task_description: str
+ :type budget: str
+ """
cursor = db.cursor()
query = ("INSERT INTO tasks (projectid, title, task_description, budget, task_status) VALUES (\"" +
projectid + "\", \"" + task_title + "\", \"" +
task_description + "\", \"" + budget + "\", \"waiting for delivery\")")
cursor.execute(query)
db.commit()
+ cursor.close
diff --git a/src/app/models/register.py b/src/app/models/register.py
index 8ffeefd..9758033 100644
--- a/src/app/models/register.py
+++ b/src/app/models/register.py
@@ -2,6 +2,29 @@ from models.database import db
def set_user(username, password, full_name, company, phone_number,
street_address, city, state, postal_code, country):
+ """
+ Register a new user in the database
+ :param username: The users unique user name
+ :param password: The password
+ :param full_name: The users full name
+ :param company: The company the user represents
+ :param phone_number: The phone number of the user
+ :param street_address: The street address of the user
+ :param city: The city where the user lives
+ :param state: The state where the user lives
+ :param postal_code: The corresponding postal code
+ :param country: The users country
+ :type username: str
+ :type password: str
+ :type full_name: str
+ :type company: str
+ :type phone_number: str
+ :type street_address: str
+ :type city: str
+ :type state: str
+ :type postal_code: str
+ :type country: str
+ """
cursor = db.cursor()
query = ("INSERT INTO users VALUES (NULL, \"" + username + "\", \"" +
password + "\", \"" + full_name + "\" , \"" + company + "\", \"" +
diff --git a/src/app/views/new_project.py b/src/app/views/new_project.py
index e3f3e25..dabd294 100644
--- a/src/app/views/new_project.py
+++ b/src/app/views/new_project.py
@@ -37,7 +37,6 @@ class New_project:
# Add a set of task fields to the form
if data["Add Task"]:
project_form = self.compose_form(data, True)
- print("add task")
return render.new_project(nav, project_form)
except Exception as e:
try:
@@ -49,12 +48,9 @@ class New_project:
try:
# Post the form data and save the project in the database
if data["Create Project"]:
- print("Create project")
projectid = models.project.set_project(data.category_name, str(session.userid),
data.project_title, data.project_description, "open")
- print("id:", projectid)
task_count = self.get_task_count(data)
- print(task_count)
# Save the tasks in the database
for i in range(0, task_count):
models.project.set_task(str(projectid), (data["task_title_" + str(i)]),
@@ -64,19 +60,26 @@ class New_project:
raise e
def get_task_count(self, data):
- task_count = 0
- # Remove the four other elements from count and divide by the number of variables in one task.
+ """
+ Determine the number of tasks created by removing
+ the four other elements from count and divide by the
+ number of variables in one task.
+
+ :param data: The data object from web.input
+ :return: The number of tasks opened by the client
+ """
task_count = int((len(data) - 4) / 3)
- """while True:
- try:
- if data["task_title_"+str(task_count)] or data["task_description_"+str(task_count)] or data["task_budget_"+str(task_count)]:
- task_count += 1
- except Exception as e:
- pass
- break"""
return task_count
def compose_form(self, data, add):
+ """
+ Compose a new project form by adding or removing a task
+
+ :param data: The data object from web.input
+ :param add: True or False
+ :type add: boolean
+ :return: A complete project form object
+ """
task_count = self.get_task_count(data)
# A task is either added or removed
if not add and task_count >= 1:
diff --git a/src/app/views/open_projects.py b/src/app/views/open_projects.py
index 4c5fa60..dc427ba 100644
--- a/src/app/views/open_projects.py
+++ b/src/app/views/open_projects.py
@@ -7,8 +7,12 @@ render = web.template.render('templates/')
class Open_projects:
- # Get projects
def GET(self):
+ """
+ Get all open projects
+
+ :return: A page containing all open projects
+ """
session = web.ctx.session
data = web.input(categoryid=0)
open_projects=[]
diff --git a/src/app/views/project.py b/src/app/views/project.py
index 98270bf..a3850ed 100644
--- a/src/app/views/project.py
+++ b/src/app/views/project.py
@@ -8,8 +8,13 @@ render = web.template.render('templates/')
class Project:
- # Get main page
def GET(self):
+ """
+ Show info about a single project
+
+ :return: Project info page
+ """
+
# Get session
session = web.ctx.session
# Get navbar
diff --git a/src/app/views/register.py b/src/app/views/register.py
index b44e26f..52bef93 100644
--- a/src/app/views/register.py
+++ b/src/app/views/register.py
@@ -9,14 +9,22 @@ render = web.template.render('templates/')
class Register:
- # Get the registration form
def GET(self):
+ """
+ Get the registration form
+
+ :return: A page with the registration form
+ """
session = web.ctx.session
nav = get_nav_bar(session)
return render.register(nav, register_form)
- # Register new user in database
def POST(self):
+ """
+ Register new user in database
+
+ :return: Main page
+ """
data = web.input()
models.register.set_user(data.username, data.password,
data.full_name, data.company, data.phone_number, data.street_address,
diff --git a/src/app/views/utils.py b/src/app/views/utils.py
index ccb1d53..102e545 100644
--- a/src/app/views/utils.py
+++ b/src/app/views/utils.py
@@ -1,5 +1,10 @@
def get_nav_bar(session):
+ """
+ Generates the page nav bar
+
+ :return: The navigation bar HTML markup
+ """
result = '