Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
b0463d5
Make files
borosTamas Feb 12, 2019
7b77c7a
index template, collect questions
borosTamas Feb 12, 2019
cc6e6bb
commit before the lunch just for safe
borosTamas Feb 13, 2019
9a00662
aííaíí
LibLev Feb 13, 2019
b2e4550
It works now
borosTamas Feb 13, 2019
9829b27
Merge remote-tracking branch 'origin/master'
LibLev Feb 13, 2019
427a940
collect answer
LibLev Feb 13, 2019
c2f22c5
question page looks shit but works
borosTamas Feb 13, 2019
419ed20
Merge remote-tracking branch 'origin/master'
borosTamas Feb 13, 2019
be35d50
question page looks bad but its working
borosTamas Feb 13, 2019
23b9ae4
implement add new question, write to csv in progress
Zollli Feb 13, 2019
afe3262
Merge remote-tracking branch 'origin/master'
Zollli Feb 13, 2019
5a4794c
question page looks better
borosTamas Feb 13, 2019
76f8766
Merge branch 'master' of https://github.com/borosTamas/ask-mate-python
borosTamas Feb 13, 2019
1666314
upgradet question page with answers
borosTamas Feb 13, 2019
f1bcec0
add answer
LibLev Feb 13, 2019
cc6ed68
Merge remote-tracking branch 'origin/master'
LibLev Feb 13, 2019
1f8f677
there is a problem with the file path
borosTamas Feb 13, 2019
48d7617
implement add questions write to file, add questions in index page
Zollli Feb 14, 2019
915b233
dani belenyult
LibLev Feb 14, 2019
e5a69ef
Merge remote-tracking branch 'origin/master'
LibLev Feb 14, 2019
fb3d9b8
dani belenyult
LibLev Feb 14, 2019
9e3dfc5
Merge branch 'master' of /home/boros/codecool/web_sql/ask-mate-python…
borosTamas Feb 14, 2019
80cb165
implement edit questions
Zollli Feb 14, 2019
f7fc8da
Merge branch 'new_question'
Zollli Feb 14, 2019
2257c26
ad question page changed, update question wotking, + submission time
borosTamas Feb 14, 2019
763191e
Merge remote-tracking branch 'origin/master'
borosTamas Feb 14, 2019
5b7bd87
add answer is fucked the system
LibLev Feb 14, 2019
3610430
Merge remote-tracking branch 'origin/master'
LibLev Feb 14, 2019
ed04bd0
vote counter
borosTamas Feb 14, 2019
12f751e
Dani belenyúlt...
LibLev Feb 18, 2019
95212c3
Most megint működik
borosTamas Feb 18, 2019
ca12f5b
add sql sample data
lterray Aug 28, 2017
0d66ea8
connenction been updated
LibLev Feb 26, 2019
2fd850f
collect question and answer, show question
borosTamas Feb 26, 2019
b829aa1
collect question and answer, show question
borosTamas Feb 26, 2019
f6466d7
update question/answer and add answer are ready to use
LibLev Feb 26, 2019
086b4a2
write q/a in progress
Zollli Feb 26, 2019
da13e70
view number ready
borosTamas Feb 26, 2019
f31186e
megy a baszakodás
LibLev Feb 26, 2019
c5e4dac
post answer
LibLev Feb 26, 2019
b9b6a6c
write q/a in progress
Zollli Feb 26, 2019
3077629
Merge branch 'master' of https://github.com/borosTamas/ask-mate-python
Zollli Feb 26, 2019
ab04c26
ADD_question complete
Zollli Feb 26, 2019
855b84c
edit answer is ready to use
LibLev Feb 26, 2019
15e9640
Merge remote-tracking branch 'origin/master'
LibLev Feb 26, 2019
cbe05de
add question been fixed
LibLev Feb 27, 2019
9a019b3
show top 5 question and show all question
LibLev Feb 27, 2019
533c0b9
search question kinda working
borosTamas Feb 27, 2019
57647ed
vote in progress
Zollli Feb 27, 2019
74635d6
search question kinda working really
borosTamas Feb 27, 2019
7ecfc16
implemented vote
Zollli Feb 27, 2019
35398da
Merge branch 'master' of https://github.com/borosTamas/ask-mate-python
Zollli Feb 27, 2019
80c6cf1
Merge branch 'vote'
Zollli Feb 27, 2019
f0d6d12
all question html added
LibLev Feb 27, 2019
e223d15
Merge branch 'master' of /home/boros/codecool/web_sql/ask-mate-python…
borosTamas Feb 27, 2019
e041f89
sort is fuckin' ready
LibLev Feb 27, 2019
71b1ae6
Merge remote-tracking branch 'origin/master'
borosTamas Feb 27, 2019
15f658f
add comment to question
borosTamas Feb 27, 2019
090bcfb
we get delete question back
borosTamas Feb 27, 2019
653f3f2
question page been edited
LibLev Feb 27, 2019
632bca0
vote been fixed
LibLev Feb 27, 2019
9a68a9c
add comment in progress
LibLev Feb 28, 2019
4284742
Add comment to answer is ready, more info in the main page
borosTamas Feb 28, 2019
9b3e027
search works everywhere
borosTamas Feb 28, 2019
8e66b19
css in progress
Zollli Feb 28, 2019
499ee04
really working show comments
borosTamas Feb 28, 2019
a69f912
Merge branch 'css'
Zollli Feb 28, 2019
f7d956e
Merge remote-tracking branch 'origin/master'
borosTamas Feb 28, 2019
b57fbcc
css in progress
Zollli Feb 28, 2019
b02400f
Merge remote-tracking branch 'origin/master'
borosTamas Feb 28, 2019
ef04372
somewhere in the way of css
borosTamas Feb 28, 2019
e3f472f
css in progress
Zollli Feb 28, 2019
31fafbb
Merge branch 'master' into css
Zollli Feb 28, 2019
82f0854
css index,all question,home finished
Zollli Feb 28, 2019
11bcf0d
vote fixed
Zollli Feb 28, 2019
23cf800
last push i hope, edit answer and ediq question, drops back to questi…
borosTamas Feb 28, 2019
8cacf60
valami
LibLev Mar 4, 2019
a3e90c5
css has been updated
LibLev Mar 11, 2019
d0070df
new background
LibLev Mar 11, 2019
e1a0fb4
add sql sample data
lterray Aug 28, 2017
d1b3c59
Remove drop sequence from sample SQL
szrudi Sep 25, 2018
a18fb89
question_data_manager
LibLev Mar 11, 2019
eb68812
add answer_data_manager.py
Zollli Mar 11, 2019
8178179
Merge branch 'hotfix/answer_comment' into develop
borosTamas Mar 11, 2019
dd3adab
Hotfix on show all comments for an answer
borosTamas Mar 11, 2019
12830f7
Merge branch 'question_manager' into develop
Zollli Mar 11, 2019
03b2932
Merge branch 'develop' of https://github.com/borosTamas/ask-mate-pyth…
borosTamas Mar 11, 2019
cf82454
deleted data_manager, comment_data_manager created,
Zollli Mar 11, 2019
0184b38
user table has been created in database
LibLev Mar 12, 2019
2647c89
login buttons and html
borosTamas Mar 12, 2019
0ad1da5
Merge remote-tracking branch 'origin/develop' into develop
borosTamas Mar 12, 2019
d32bc8b
added vote to answer
Zollli Mar 12, 2019
003896b
Merge branch 'vote_answer' into develop
Zollli Mar 12, 2019
2a094f5
fixed comment_data_manager
Zollli Mar 12, 2019
21a2572
registration complete
borosTamas Mar 12, 2019
d762705
Merge branch 'develop' into registration
Zollli Mar 12, 2019
d227126
registration complete
borosTamas Mar 12, 2019
41cb51c
login in progress:
LibLev Mar 12, 2019
503e0b4
Merge branch 'develop' into loginfeature
LibLev Mar 12, 2019
4f3e5a2
login in server almost done...
LibLev Mar 12, 2019
e8881b7
just save
borosTamas Mar 12, 2019
a82da19
fixed askmate sql, deleted head<<<---
Zollli Mar 12, 2019
3304697
Merge remote-tracking branch 'origin/loginfeature' into gain_reputation
borosTamas Mar 12, 2019
873ddb1
too many changes is one brach, add user id for new question and answe…
borosTamas Mar 12, 2019
f2a1615
Merge remote-tracking branch 'origin/gain_reputation' into loginfeature
LibLev Mar 12, 2019
5e1d2e3
now you can log in but if you do anything on the page its automatical…
LibLev Mar 12, 2019
fc949cf
now you can login and logout but if you want to open an other page it…
LibLev Mar 12, 2019
06a867c
signin button has been changed
LibLev Mar 12, 2019
cabf9a9
Merge branch 'loginfeature' into List_users
borosTamas Mar 13, 2019
275a1cf
list all users
borosTamas Mar 13, 2019
6adb96a
Merge branch 'gain_reputation' into acept_answer_feature
borosTamas Mar 13, 2019
2dc968f
now you can login and if you go any other page from the index it's st…
LibLev Mar 13, 2019
49300a4
merge thing
borosTamas Mar 13, 2019
ee8a8ca
Merge branch 'loginfeature' into acept_answer_feature
borosTamas Mar 13, 2019
b6c95e4
accept answer done
borosTamas Mar 13, 2019
887ae50
sho images from url
borosTamas Mar 13, 2019
676f091
now you can login and stay login, if you try to use an invalid userna…
LibLev Mar 13, 2019
35c85e2
bind comment to user merged
borosTamas Mar 13, 2019
69d3b27
Merge remote-tracking branch 'origin/develop' into develop
LibLev Mar 13, 2019
fd25b06
now you can login and stay login, if you try to use an invalid userna…
LibLev Mar 13, 2019
6fdc3a0
reputation answer, question vote up,down ready
Zollli Mar 13, 2019
ed73ffa
Merge branch 'answer_reputation' into develop
Zollli Mar 13, 2019
140b49b
save progress
borosTamas Mar 13, 2019
0c7f5f4
now its ugly but its working
LibLev Mar 13, 2019
fd0213f
css table are looking superb >.<
LibLev Mar 13, 2019
fc0433d
save progress2
borosTamas Mar 13, 2019
655cd21
Merge branch 'develop' into user_page
borosTamas Mar 13, 2019
5282ce6
asdasdasd
LibLev Mar 13, 2019
edc0072
save progress3
borosTamas Mar 13, 2019
64f5fd6
Merge branch 'develop' into user_page
borosTamas Mar 13, 2019
e95e4ab
save progress4, minor bugfixes
borosTamas Mar 13, 2019
91241f7
logout burn in user page, defaultbutton has been created
LibLev Mar 13, 2019
d73c99f
done
borosTamas Mar 13, 2019
bdff83f
Merge remote-tracking branch 'origin/develop' into develop
borosTamas Mar 13, 2019
2b0de6e
bugfix on redirect
borosTamas Mar 13, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#TODO redirect
#TODO login/logout
#TODO CSS

USER PAGE:
#TODO querry find all questions from user
#TODO querry find all answers from user
#TODO querry find all comment from user
#TODO server function use this and send the datas to the html
#TODO user page html
134 changes: 134 additions & 0 deletions answer_data_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import connection

@connection.connection_handler
def delete_answer(cursor, q_id, a_id):
cursor.execute("""
delete from comment
where question_id = %(q_id)s or answer_id = %(a_id)s;
delete from answer
where question_id = %(q_id)s and id = %(a_id)s
""",
{'q_id': q_id, 'a_id': a_id})


@connection.connection_handler
def collect_answers(cursor, q_id):
cursor.execute("""
SELECT * from answer
where question_id = %(q_id)s
""",
{'q_id': q_id})
result = cursor.fetchall()
return result


@connection.connection_handler
def find_answer(cursor, a_id):
cursor.execute("""
SELECT * from answer
where id = %(a_id)s
""",
{'a_id': a_id})
result = cursor.fetchall()
return result


@connection.connection_handler
def update_answer(cursor, datas):
cursor.execute("""
UPDATE answer
SET message=%s, image=%s
WHERE id=%s""",
(datas['message'], datas['image'], int(datas['id'])))


@connection.connection_handler
def collect_all_answer(cursor):
cursor.execute("""
SELECT * FROM answer
""")
result = cursor.fetchall()
return result


@connection.connection_handler
def add_answer(cursor, form_data):
cursor.execute("""
INSERT INTO answer(submission_time, vote_number, question_id, message, image,user_id,accepted)
VALUES (%s, %s, %s, %s, %s,%s,%s)""",
(form_data['submission_time'], form_data['vote_number'], form_data['question_id'],
form_data['message'], form_data['image'], form_data['user_id'], form_data['accepted']))


@connection.connection_handler
def accept_answer(cursor, a_id):
cursor.execute("""
Update answer
set accepted = TRUE
where id = %(a_id)s
""",
{'a_id': a_id})


@connection.connection_handler
def update_vote_number_answer(cursor, vote, a_id):
cursor.execute("""
UPDATE answer
set vote_number = %(vote)s
WHERE id = %(a_id)s
""",
{'vote': vote, 'a_id': a_id})


@connection.connection_handler
def update_view_number(cursor, q_id):
cursor.execute("""
update question
set view_number = view_number+1
where id = %(q_id)s
""",
{'q_id': q_id})


@connection.connection_handler
def update_reputation(cursor,user_id,new_reputation):
cursor.execute("""
UPDATE "user"
SET reputation = %(new_reputation)s
WHERE id = %(user_id)s
""",
{'user_id':user_id, 'new_reputation':new_reputation})


@connection.connection_handler
def get_userid_used_answer(cursor,a_id):
cursor.execute("""
SELECT user_id FROM answer
WHERE id = %(a_id)s
""",
{'a_id':a_id})

result = cursor.fetchall()
return result


@connection.connection_handler
def get_reputation(cursor,user_id):
cursor.execute("""
SELECT reputation FROM "user"
WHERE id = %(user_id)s
""",
{'user_id':user_id})
result = cursor.fetchone()
return result


@connection.connection_handler
def get_all_answes_form_user(cursor, u_id):
cursor.execute("""Select question_id, question.title as question_title, answer.message as answer, answer.vote_number as vote_number from answer
join question on question_id=question.id
where answer.user_id= %(u_id)s
""",
{'u_id':u_id})
result=cursor.fetchall()
return result
76 changes: 76 additions & 0 deletions comment_data_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import connection


@connection.connection_handler
def update_view_number(cursor, q_id):
cursor.execute("""
update question
set view_number = view_number+1
where id = %(q_id)s
""",
{'q_id': q_id})


@connection.connection_handler
def update_vote_number(cursor, vote, q_id):
cursor.execute("""
UPDATE question
set vote_number = %(vote)s
WHERE id = %(q_id)s
""",
{'vote': vote, 'q_id': q_id})


@connection.connection_handler
def add_comment_to_question(cursor, q_id, comment_message, u_id, s_time):
cursor.execute("""
insert into comment(question_id, message, user_id, submission_time)
values (%(q_id)s,%(comment_message)s,%(u_id)s,%(s_time)s)

""",
{'q_id': q_id, 'comment_message': comment_message, 'u_id': u_id, 's_time': s_time})


@connection.connection_handler
def add_comment_to_answer(cursor, a_id, comment_message):
cursor.execute("""
insert into comment(answer_id, message)
values (%(a_id)s,%(comment_message)s)

""",
{'a_id': a_id, 'comment_message': comment_message})


@connection.connection_handler
def collect_comment_to_question(cursor, q_id):
cursor.execute("""
Select message from comment
where question_id = %(q_id)s
""",
{'q_id': q_id})
result = cursor.fetchall()
return result


@connection.connection_handler
def collect_comment_to_answer(cursor, a_id):
cursor.execute("""
Select message, answer_id from comment
where answer_id = %(a_id)s
""",
{'a_id': a_id})
result = cursor.fetchall()
return result


@connection.connection_handler
def get_all_comments_from_user(cursor, u_id):
cursor.execute("""
Select comment.message as comment, question.title as question, question.id as q_id, answer.question_id as question_id, answer.message as answer from comment
full join answer on comment.answer_id = answer.id
full join question on comment.question_id = question.id
where comment.user_id = %(u_id)s
""",
{'u_id': u_id})
result = cursor.fetchall()
return result
51 changes: 51 additions & 0 deletions connection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Creates a decorator to handle the database connection/cursor opening/closing.
# Creates the cursor with RealDictCursor, thus it returns real dictionaries, where the column names are the keys.
import os
import psycopg2
import psycopg2.extras


def get_connection_string():
# setup connection string
# to do this, please define these environment variables first
user_name = os.environ.get('PSQL_USER_NAME')
password = os.environ.get('PSQL_PASSWORD')
host = os.environ.get('PSQL_HOST')
database_name = os.environ.get('PSQL_DB_NAME')

env_variables_defined = user_name and password and host and database_name

if env_variables_defined:
# this string describes all info for psycopg2 to connect to the database
return 'postgresql://{user_name}:{password}@{host}/{database_name}'.format(
user_name=user_name,
password=password,
host=host,
database_name=database_name
)
else:
raise KeyError('Some necessary environment variable(s) are not defined')


def open_database():
try:
connection_string = get_connection_string()
connection = psycopg2.connect(connection_string)
connection.autocommit = True
except psycopg2.DatabaseError as exception:
print('Database connection problem')
raise exception
return connection


def connection_handler(function):
def wrapper(*args, **kwargs):
connection = open_database()
# we set the cursor_factory parameter to return with a RealDictCursor cursor (cursor which provide dictionaries)
dict_cur = connection.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
ret_value = function(dict_cur, *args, **kwargs)
dict_cur.close()
connection.close()
return ret_value

return wrapper
12 changes: 12 additions & 0 deletions password_hash.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import bcrypt


def hash_password(plain_text_password):
# By using bcrypt, the salt is saved into the hash itself
hashed_bytes = bcrypt.hashpw(plain_text_password.encode('utf-8'), bcrypt.gensalt())
return hashed_bytes.decode('utf-8')


def verify_password(plain_text_password, hashed_password):
hashed_bytes_password = hashed_password.encode('utf-8')
return bcrypt.checkpw(plain_text_password.encode('utf-8'), hashed_bytes_password)
Loading