Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
383 commits
Select commit Hold shift + click to select a range
745662f
Add upload image
balintsimon Nov 14, 2019
d80ba8e
extends /upload-file route with function
Rhyvan Nov 14, 2019
2b82da3
Add delete picture upon deletion of question
balintsimon Nov 14, 2019
2342c74
add presentation link to readme
kiglarka Nov 14, 2019
72f7fb2
update gitignore
kiglarka Nov 14, 2019
7e32e31
Merge branch 'master' of https://github.com/balintsimon/ask-mate-python
kiglarka Nov 14, 2019
3194bc0
add answer now loads from child template
Rhyvan Nov 14, 2019
f002107
upload files in anwers
Rhyvan Nov 14, 2019
bce438c
Delete picture upload upon posting new question (remains at edit ques…
balintsimon Nov 14, 2019
110936e
Add question/answer css style
Nov 14, 2019
fa4f342
merge conflict fixed
Nov 14, 2019
f6e8a60
Add form.css tweak
Nov 14, 2019
fff930b
Corrects error at answer posting (now image addition does not work)
balintsimon Nov 14, 2019
ee51278
Delete picture addition upon adding new question
balintsimon Nov 14, 2019
87b4ca8
Add 2 new questions
balintsimon Nov 15, 2019
cd0ed2f
fix bug that redirected early if no image selected when writing answer
Rhyvan Nov 15, 2019
4a28206
add function descriptions to data_manager.py
Rhyvan Nov 15, 2019
4c38366
add sql sample data
lterray Aug 28, 2017
149b150
initialize SQL database
Rhyvan Nov 25, 2019
9137e9a
Refactor and add write new question to database
balintsimon Nov 25, 2019
f085751
Add write answer to file (untested)
balintsimon Nov 25, 2019
e826a72
manage_question with SQL
Nov 25, 2019
8e6b5ee
Add working add answer
balintsimon Nov 25, 2019
7b2307a
edit question using SQL
Nov 26, 2019
0af8412
Merge branch 'master' of https://github.com/balintsimon/ask-mate-python
Nov 26, 2019
5e4668e
answer table fixed
Nov 26, 2019
2412c8d
Add vote on question
balintsimon Nov 26, 2019
d4c9e84
Add vote on answer
balintsimon Nov 26, 2019
bcd9915
Delete old function to modify votes
balintsimon Nov 26, 2019
fa350c4
Add view counter
balintsimon Nov 26, 2019
2ea73cd
Refactor unused code related to CSV
balintsimon Nov 26, 2019
be1b825
Add delete answer to question
balintsimon Nov 26, 2019
b5a7036
Delete question, related answer and comments
balintsimon Nov 26, 2019
a3e270c
Refactor unused code
balintsimon Nov 26, 2019
2db684a
Correct error at headers
balintsimon Nov 26, 2019
800e7dd
Add edit and delete answer
balintsimon Nov 26, 2019
f89ec74
handle view number exceptions
kiglarka Nov 26, 2019
7f355f8
Merge branch 'master' of https://github.com/balintsimon/ask-mate-python
kiglarka Nov 26, 2019
198b938
Format timestamp
balintsimon Nov 26, 2019
b22dfb3
add comments to questions, answers (backend)
Rhyvan Nov 26, 2019
438df9d
Merge branch 'master' of https://github.com/balintsimon/ask-mate-python
kiglarka Nov 26, 2019
60c64a0
Corrects add answer
balintsimon Nov 26, 2019
61836fc
Deleted modify view counter
balintsimon Nov 26, 2019
f172784
merge
Rhyvan Nov 26, 2019
58bafbd
merge3
Rhyvan Nov 26, 2019
2cbba39
add comment functions
Rhyvan Nov 26, 2019
5432019
Add search
Nov 26, 2019
eafb4d8
remove + sign
kiglarka Nov 26, 2019
eeab237
merge conflict solved
Nov 26, 2019
4dff5f7
Merge branch 'master' of https://github.com/balintsimon/ask-mate-python
Nov 26, 2019
ab50c66
index.css fixed
Nov 26, 2019
5613790
Clicking on the logo brings back to the home page
Nov 26, 2019
46ec955
home page and search bar are now more user friendly
Nov 26, 2019
b7e8f3c
restyle Edit/Delete/Comment Answers links
kiglarka Nov 26, 2019
3225f68
Refactor old functions
balintsimon Nov 26, 2019
bac5804
Add picture mechanics
balintsimon Nov 26, 2019
e8d7625
Add show picture on main page
balintsimon Nov 26, 2019
bdf4a2d
Add image capabilities to /static/images folder
balintsimon Nov 26, 2019
52f47a5
replace python sort decorator with SQL sorting
Rhyvan Nov 27, 2019
dd2b1ba
Add picture upload and modify
balintsimon Nov 27, 2019
dec338b
Merge branch 'master' of github.com:balintsimon/ask-mate-python
balintsimon Nov 27, 2019
50e592b
add index page
Rhyvan Nov 27, 2019
e29cc0d
add edit and delete comment
kiglarka Nov 27, 2019
13e2129
Merge branch 'master' of https://github.com/balintsimon/ask-mate-python
kiglarka Nov 27, 2019
e9a4584
change route to edit answer
kiglarka Nov 27, 2019
3f13287
add html for displaying question comments
Rhyvan Nov 27, 2019
ec6af63
comment implement(not working)
Nov 27, 2019
45831f8
merge conflict solved
Nov 27, 2019
40c89b9
fix view counter
kiglarka Nov 27, 2019
29ad82c
Merge branch 'master' of https://github.com/balintsimon/ask-mate-python
kiglarka Nov 27, 2019
2d80f84
refactor
kiglarka Nov 27, 2019
472670d
display comments on html
Rhyvan Nov 27, 2019
ce0e5b2
modified data
Nov 27, 2019
eceb600
add delete comments function
Rhyvan Nov 27, 2019
b800fc2
main page messages sliced
Nov 27, 2019
aa62250
Merge branch 'master' of https://github.com/balintsimon/ask-mate-python
Nov 27, 2019
a41a134
add list page filter to show message
balintsimon Nov 27, 2019
2b99960
recycle bin image as delete
Rhyvan Nov 27, 2019
e6337bf
add confirmation before delete
Rhyvan Nov 27, 2019
c8d3eed
Change commit submission time upon edition
balintsimon Nov 27, 2019
28ab269
Add sort answers on questions page by vote and submission time
balintsimon Nov 27, 2019
a4d6005
Add get commit function
balintsimon Nov 27, 2019
fb25c89
Corrects get comment data
balintsimon Nov 27, 2019
2fce565
add edit comment functions
Rhyvan Nov 27, 2019
b52b04c
add edit comment functions
Rhyvan Nov 27, 2019
4183deb
comment display sorted by id
Rhyvan Nov 27, 2019
46780a5
add manage-question.css
kiglarka Nov 27, 2019
2a81fbd
Merge branch 'master' of https://github.com/balintsimon/ask-mate-python
kiglarka Nov 27, 2019
431ec6a
Refactor: delete util.py and dependencies
balintsimon Nov 27, 2019
1809c6f
Refactor vote on answer
balintsimon Nov 27, 2019
aa434f1
Refactor delete answer to original spec
balintsimon Nov 27, 2019
ed52180
Refactor code
balintsimon Nov 27, 2019
ab49e6b
change nav links in question
kiglarka Nov 27, 2019
7bf517c
Merge branch 'master' of https://github.com/balintsimon/ask-mate-python
kiglarka Nov 27, 2019
d70995b
Add search results in answers
balintsimon Nov 27, 2019
ba9c387
Merge branch 'master' of github.com:balintsimon/ask-mate-python
balintsimon Nov 27, 2019
1506b5f
add current version of question css
kiglarka Nov 27, 2019
c3f524d
update question css
kiglarka Nov 27, 2019
85be863
Merge branch 'master' of https://github.com/balintsimon/ask-mate-python
kiglarka Nov 27, 2019
59e844f
search button design
Nov 28, 2019
f42dfaf
Merge branch 'master' of https://github.com/balintsimon/ask-mate-python
Nov 28, 2019
9f5eeb9
Add zoom picture on cover
balintsimon Nov 28, 2019
e1b3edc
Merge branch 'master' of github.com:balintsimon/ask-mate-python
balintsimon Nov 28, 2019
0f5f950
Correct image hover
balintsimon Nov 28, 2019
5bba0aa
Corrects edit count display of comment
balintsimon Nov 28, 2019
7626f75
add border bottom to title
Nov 28, 2019
09e7db7
refactored question.html and design layout
Rhyvan Nov 28, 2019
4b415f6
Add style to add and edit comment page
balintsimon Nov 28, 2019
2990308
Merge branch 'webdesign'
Rhyvan Nov 28, 2019
2ee58a7
Merge branch 'master' of https://github.com/balintsimon/ask-mate-python
Rhyvan Nov 28, 2019
b609ba9
fix css
Rhyvan Nov 28, 2019
87a6305
Rewrite zoom picture and edit time
balintsimon Nov 28, 2019
d2adcae
Add several line display in message body
balintsimon Nov 28, 2019
7447401
Add header to add or modify comment page
balintsimon Nov 28, 2019
ba710d5
Adds white background to question image on view question
balintsimon Nov 28, 2019
378b175
refine css
Rhyvan Nov 28, 2019
6a81c69
Reverse changes
balintsimon Nov 28, 2019
3b9ae9a
Corrects none input in comment edit time on dispaly
balintsimon Nov 28, 2019
505842f
Delete image hover
balintsimon Nov 28, 2019
75c50b7
add photos to static
kiglarka Nov 28, 2019
0534a0b
fix answer vote
kiglarka Nov 28, 2019
71a1caa
Fix answer vote route
balintsimon Nov 28, 2019
f2c9b9c
Merge branch 'master' of github.com:balintsimon/ask-mate-python
balintsimon Nov 28, 2019
384f780
Reverse last update
balintsimon Nov 28, 2019
8ce0f7c
Fix sort: now sorts whole list
balintsimon Nov 28, 2019
4925362
set body max-width and centered
Rhyvan Nov 28, 2019
1a6f2ea
Adds Rudi's modifications
balintsimon Nov 29, 2019
a08c976
add user table
Dec 9, 2019
b568e19
Merge branch 'master' of https://github.com/balintsimon/ask-mate-python
Dec 9, 2019
82b3c56
add branches
Dec 9, 2019
5bebcd5
add password hash
Dec 9, 2019
5c6b833
add create user function
kiglarka Dec 9, 2019
b041148
fix user table attributes in .sql file
Rhyvan Dec 9, 2019
b5e0cfb
Merge branch 'master' of https://github.com/balintsimon/ask-mate-python
Rhyvan Dec 9, 2019
ab16959
Merge branch 'master' into register
Dec 9, 2019
c60e350
add user database update
Dec 9, 2019
193145b
modify data table attributes, constraints to enable q&a&comment user …
Rhyvan Dec 9, 2019
5238043
login halfway
Dec 9, 2019
8c45851
Solve merge conflict
balintsimon Dec 9, 2019
97e8038
Add login-register with css style
Dec 9, 2019
4b22bf0
solve merge conflict
Dec 9, 2019
8c2878e
login-register finished
Dec 9, 2019
9a52666
not working
Dec 10, 2019
2573e61
Initial commit for new SQL
balintsimon Dec 10, 2019
1929f5c
Resolve merge conflict
balintsimon Dec 10, 2019
b146385
insert username variables to html files
Rhyvan Dec 10, 2019
c8c6fc7
Resolve merge conflict
balintsimon Dec 10, 2019
6c19c2d
sorting works desc
Dec 10, 2019
1133def
Fix already existing user re-registration error
balintsimon Dec 10, 2019
32f842e
Add logout
balintsimon Dec 10, 2019
12ab173
Merge remote-tracking branch 'origin/development' into web
Rhyvan Dec 10, 2019
f7d1854
modify reference names in html to insert database values
Rhyvan Dec 10, 2019
3b8d88c
Corrects SQL request
balintsimon Dec 10, 2019
2eb7ab6
Delete typos and outdated references
balintsimon Dec 10, 2019
8bb988d
finish sorting branch
Dec 10, 2019
0be509c
start sql to list users
kiglarka Dec 11, 2019
2e435ef
add all questions button
Dec 11, 2019
19c83e0
add JS to display authorized buttons only
Rhyvan Dec 11, 2019
b4ff8ce
Merge branch 'development' into web
Rhyvan Dec 11, 2019
e6353ae
hotfix finished
Dec 11, 2019
ad0b15b
Initial commit for user vote SQL table
balintsimon Dec 11, 2019
fb8ca57
add list user page
kiglarka Dec 11, 2019
2d63a4e
fix username display in comments for question
Rhyvan Dec 11, 2019
d3ee224
resolve merge conflicts on database branch
kiglarka Dec 11, 2019
4dbb308
merge conflict solved
Dec 11, 2019
2679cac
fuck my merge conflict
Dec 11, 2019
a60e9be
resolve merge confilct
kiglarka Dec 11, 2019
a6b030a
update on list users
kiglarka Dec 11, 2019
5615e59
add new column to question table: accepted_answer
Rhyvan Dec 11, 2019
1ee3d88
Add basic SQL
balintsimon Dec 11, 2019
e4fca16
add accept button, visible by question author
Rhyvan Dec 11, 2019
43c0716
Add vote functionality without visual cue
balintsimon Dec 11, 2019
f99494d
new accepted answer is written to database
Rhyvan Dec 11, 2019
ea40a57
hide ACCEPT button at accepted answer
Rhyvan Dec 11, 2019
49e0ff9
Merge development to feature/vote
balintsimon Dec 11, 2019
cac2ad2
SQL order by accepterd_answer
Rhyvan Dec 11, 2019
09fc2b9
Dual vote mechanism
balintsimon Dec 11, 2019
931a552
fix display that visitors can't see any buttons which requires login
Rhyvan Dec 11, 2019
6833829
add css style to accepted answer
Rhyvan Dec 11, 2019
a90954a
add list user
kiglarka Dec 11, 2019
ea2d128
Merge branch 'database' into development
kiglarka Dec 11, 2019
42201d0
fix SQL sorting by accepted answer
Rhyvan Dec 11, 2019
e50233d
fix list all user and resolve route to user page
kiglarka Dec 11, 2019
2a333ee
fix list users and add route to user page
kiglarka Dec 11, 2019
3a8cdde
add blank template to user page
kiglarka Dec 11, 2019
3312ef8
add function so questions can be voted up, down or reset vote by same…
balintsimon Dec 11, 2019
929638c
add view of user questions
kiglarka Dec 11, 2019
044e20d
Merge pull request #1 from balintsimon/web
Rhyvan Dec 11, 2019
10be6af
merged reputation(accept button) to development
Rhyvan Dec 11, 2019
e7aa60e
fix answer block that shifted, and few indentation
Rhyvan Dec 11, 2019
6a73bf5
add new question form
Dec 11, 2019
6344fe7
add full feature vote on questions and answers
balintsimon Dec 11, 2019
783c113
finish question form
Dec 11, 2019
59ea071
fix route, deleting question now loads main page
Rhyvan Dec 11, 2019
a08e754
fix bug in '/list' route, causing SQL crash
Rhyvan Dec 11, 2019
e908696
add gaining reputation via question feature
Rhyvan Dec 11, 2019
c41190f
fix user page
kiglarka Dec 11, 2019
9a02350
Merge branch 'database' into development
kiglarka Dec 11, 2019
11158f3
resolve merge conflicts
balintsimon Dec 11, 2019
8b3d227
Merge branch 'development' of github.com:balintsimon/ask-mate-python …
balintsimon Dec 11, 2019
036c616
merge feature_repu
balintsimon Dec 11, 2019
e0f149f
fix missing answer[username] in SQL getting answer
Rhyvan Dec 11, 2019
a4b9659
unknown modifications
balintsimon Dec 11, 2019
665a598
merge development into feature_repu
Rhyvan Dec 11, 2019
ba3bc33
correct typo
balintsimon Dec 11, 2019
6c41d32
add calc reputation to vote up/down on question and answer
balintsimon Dec 11, 2019
fed14eb
add calc reputation functionality to vote on answer
balintsimon Dec 12, 2019
b122950
reputation is shown next to username
Rhyvan Dec 12, 2019
f01b774
fix delete accepted answer
balintsimon Dec 12, 2019
e5cd5a2
Merge branch 'feature/vote' of github.com:balintsimon/ask-mate-python…
balintsimon Dec 12, 2019
2f95b76
add master header to list, list all users and user page
kiglarka Dec 12, 2019
748b4ec
adding answer get css style, focus set
Rhyvan Dec 12, 2019
ae9f96f
resolve sort issue
kiglarka Dec 12, 2019
a5abaac
Merge branch 'development' of github.com:balintsimon/ask-mate-python …
kiglarka Dec 12, 2019
596f7f1
finished new question modal
Dec 12, 2019
f07cd51
solve merge conflict
Dec 12, 2019
a378a58
fix deletion
balintsimon Dec 12, 2019
d1fdf24
modify css to change hover color in nav links
kiglarka Dec 12, 2019
5cd9329
Merge branch 'development' of github.com:balintsimon/ask-mate-python …
balintsimon Dec 12, 2019
8d8e705
add master header
kiglarka Dec 12, 2019
9462d71
Merge branch 'development' of github.com:balintsimon/ask-mate-python …
kiglarka Dec 12, 2019
9747c8d
fix display
Rhyvan Dec 12, 2019
d86f165
hotfix for ask question
Dec 12, 2019
7d0cde1
add reputation calculation for answer acceptance
balintsimon Dec 12, 2019
48c034f
fix minor display problems on question page
Rhyvan Dec 12, 2019
1472155
add user link in navigation
kiglarka Dec 12, 2019
eb23e6e
resolve mere conflicts
kiglarka Dec 12, 2019
7ad264c
fix modal box
balintsimon Dec 12, 2019
ff67932
Add links to login, register page
balintsimon Dec 12, 2019
9b08259
fix reputation on question user
balintsimon Dec 12, 2019
ad8f16a
Hide vote arrows upon user's vote
balintsimon Dec 12, 2019
f511a1a
fix answer vote arrow hide by Andi
balintsimon Dec 12, 2019
292846e
update SQL with admin data to pre-defined questions and answers
balintsimon Dec 12, 2019
3a9d71d
revert edit question page style to old design
balintsimon Dec 12, 2019
b8856aa
add new styling and appereance to add_comment blocks
Rhyvan Dec 12, 2019
dc29991
fix accepting answer
balintsimon Dec 12, 2019
15dd9af
fix delete question link
balintsimon Dec 12, 2019
0e6104b
fix show question without user logged in
balintsimon Dec 12, 2019
44cfbe6
fix modal design difference between add and edit question
Dec 12, 2019
e54f739
Merge branch 'development' of https://github.com/balintsimon/ask-mate…
Dec 12, 2019
ba93786
fix delete question issue on accepted answer
balintsimon Dec 12, 2019
dc203cf
fix ask question without user
balintsimon Dec 12, 2019
ec12a16
question page design is now more clean
Dec 12, 2019
ef499d9
Merge branch 'development' of https://github.com/balintsimon/ask-mate…
Dec 12, 2019
a94abf6
modify add comment display, and add link to userpage
Rhyvan Dec 12, 2019
4f11188
merge mew comment style to dev
Rhyvan Dec 12, 2019
772e7f9
login design adjust
Dec 12, 2019
d59130e
Merge branch 'development' of https://github.com/balintsimon/ask-mate…
Dec 12, 2019
e62ca89
modal box placed higher
Dec 12, 2019
4cf8b35
vote arrows change
Dec 12, 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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
temp_pictures/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -101,4 +103,4 @@ ENV/
.mypy_cache/

# pycharm files
.idea/
.idea/
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.pythonPath": "venv/bin/python3.7"
}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# wswp-ask-mate
Web and SQL with Python / 1st TW week / Ask Mate project

please run >>>>>>>>>>>>>>>>>> pip install -r requirements.txt

Presentation: 1st week https://docs.google.com/presentation/d/1su5RmQHdyfDgrQiKhYdD0PO9AavsXH64DfdY59Jnf3A/edit?usp=sharing
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
Loading