Skip to content
Open

Web #32

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
289 commits
Select commit Hold shift + click to select a range
fac2d3c
Add new question finished
Nov 12, 2019
ed90252
add vote function in data_manager
kiglarka Nov 12, 2019
df39f42
Add documentation to functions
balintsimon Nov 12, 2019
364e512
Add edit page for both question and answer
balintsimon Nov 12, 2019
57e6e5a
Started view number count
Nov 12, 2019
9676aa9
Add rewrite line by update file
balintsimon Nov 12, 2019
5a92149
Merge branch 'master' of https://github.com/balintsimon/ask-mate-python
kiglarka Nov 12, 2019
e73a007
blabla
Nov 12, 2019
6d86f37
Merge branch 'master' of https://github.com/balintsimon/ask-mate-python
kiglarka Nov 12, 2019
a0439e6
add sorting decorator to data_manager.py
Rhyvan Nov 12, 2019
eb80cf1
Add appending capability to update_file()
balintsimon Nov 12, 2019
9250dcc
Merge branch 'master' of https://github.com/balintsimon/ask-mate-python
kiglarka Nov 12, 2019
869938d
.
Nov 12, 2019
30e263d
generate_id
Nov 12, 2019
66a53ff
Add write edited question to file
balintsimon Nov 12, 2019
e232d87
Merge remote-tracking branch 'origin/master'
balintsimon Nov 12, 2019
1c8b8f6
Add modded generate_id
balintsimon Nov 12, 2019
0d951ef
working add new question
Nov 12, 2019
32a940b
Merge branch 'master' of https://github.com/balintsimon/ask-mate-python
Nov 12, 2019
f3266e1
add moidy vote number in story
kiglarka Nov 12, 2019
41cbd59
add modify vote
kiglarka Nov 12, 2019
1f680c5
add sorting to list.html and server.py
Rhyvan Nov 12, 2019
5ddf7f9
Add new form.html to cover all q&a add&modify
balintsimon Nov 12, 2019
83cd2dd
Merge branch 'master' of github.com:balintsimon/ask-mate-python
balintsimon Nov 12, 2019
55a3dae
html merged
Nov 12, 2019
924a80f
Merge branch 'master' of https://github.com/balintsimon/ask-mate-python
Nov 12, 2019
ee1f417
Add reformatted question page
balintsimon Nov 12, 2019
6f63a72
fix sorting error by converting nums from str to int
Rhyvan Nov 12, 2019
d19f3de
Add reformatted form
balintsimon Nov 12, 2019
30ff543
Merge remote-tracking branch 'origin/master'
balintsimon Nov 12, 2019
7c370a5
fixing form template
Nov 12, 2019
05f22cf
Merge branch 'master' of https://github.com/balintsimon/ask-mate-python
Nov 12, 2019
d393371
working html merge
Nov 12, 2019
a01fe51
Correct typos
balintsimon Nov 12, 2019
a38c13c
Add method to POST
balintsimon Nov 12, 2019
39179f4
Readd Update file capability
balintsimon Nov 12, 2019
335fda9
Merge remote-tracking branch 'origin/master'
balintsimon Nov 12, 2019
638b635
add app.route to vote questions&answers
kiglarka Nov 12, 2019
766325a
Merge branch 'master' of https://github.com/balintsimon/ask-mate-python
kiglarka Nov 12, 2019
d33d471
now shows images
Nov 12, 2019
6b4da60
Merge branch 'master' of https://github.com/balintsimon/ask-mate-python
Nov 12, 2019
17c6782
question page now shows the image
Nov 12, 2019
98b3eec
add minor changes on vote function
kiglarka Nov 12, 2019
c85fb8e
resolving merge conflict
kiglarka Nov 12, 2019
494854f
question page now more user friendly
Nov 12, 2019
37c4811
Add custom action method
balintsimon Nov 12, 2019
c4608c7
Add format style against html injection
balintsimon Nov 12, 2019
71e18a1
Add answer feature
Nov 12, 2019
dc393f7
current state of voting
kiglarka Nov 13, 2019
9c7a687
resolving merge conflicts
kiglarka Nov 13, 2019
45c91ae
Add answer feature
Nov 13, 2019
bbaa5dd
merge conflict solved
Nov 13, 2019
bc8ce00
Add correct write to file
balintsimon Nov 13, 2019
f44ca43
extend sorting and html render keeps user's choice
Rhyvan Nov 13, 2019
3e5afce
Add styling to index page
balintsimon Nov 13, 2019
92d70df
add vote
kiglarka Nov 13, 2019
746d05b
resolving merge conflicts
kiglarka Nov 13, 2019
ffa537b
Add working vote up and down on question
balintsimon Nov 13, 2019
8d42024
Add return question page upon vote on question
balintsimon Nov 13, 2019
88b37db
Add vote on answers button
balintsimon Nov 13, 2019
41b1ae9
add child template to populate question.html
Rhyvan Nov 13, 2019
8c28992
vote buttons
Nov 13, 2019
bb41c9b
Add vote on answers
balintsimon Nov 13, 2019
c498a58
.
Nov 13, 2019
1886269
Merge branch 'master' of https://github.com/balintsimon/ask-mate-python
Nov 13, 2019
a2a6471
Add answer upvote arrows
Nov 13, 2019
3e0b873
add delete question option
Rhyvan Nov 13, 2019
2a9a784
Comments out image related sections in add new answer, so it works
balintsimon Nov 13, 2019
ea747be
add delete answer option
Rhyvan Nov 13, 2019
6b9d49f
Add question vote arrows
Nov 13, 2019
6824f88
merge conflict fixed
Nov 13, 2019
883cf9a
Add return to question page upon delete answer
balintsimon Nov 13, 2019
a03ecbf
Merge branch 'master' of github.com:balintsimon/ask-mate-python
balintsimon Nov 13, 2019
b8c3f14
add child template block to question.html, with css
Rhyvan Nov 13, 2019
9334cf2
add view counter
kiglarka Nov 13, 2019
9da7ad3
Add css index page design
Nov 13, 2019
4a4b539
Merge branch 'master' of https://github.com/balintsimon/ask-mate-python
Nov 13, 2019
0575c0b
view counter fine-tuning (WIP)
kiglarka Nov 13, 2019
e25b394
change redirection upon vote
kiglarka Nov 13, 2019
6cb82d4
reverse fine-tuning view back to original
kiglarka Nov 13, 2019
4381044
Voting on answer redirects back to the question detail page
balintsimon Nov 13, 2019
2a9b4cd
fix css scaling
Rhyvan Nov 13, 2019
f61e1a7
refactor get single line by id
balintsimon Nov 14, 2019
4b521f2
Refactor vote function
balintsimon Nov 14, 2019
16cf074
Merge branch 'master' of github.com:balintsimon/ask-mate-python
balintsimon Nov 14, 2019
33dcd58
Corrects view number display in viewing question details
balintsimon Nov 14, 2019
9270373
Delete display ID on main page
balintsimon Nov 14, 2019
028af37
Modify question detail page title to display question in head instead…
balintsimon Nov 14, 2019
40952ff
Displays question title in ''s
balintsimon Nov 14, 2019
45fd4b9
Finalize index css
Nov 14, 2019
f49c530
merge conflict solved
Nov 14, 2019
ac2ba04
Refactor CSV writing functions
balintsimon Nov 14, 2019
0a31111
add image upload function
Rhyvan Nov 14, 2019
53c61ae
Merge branch 'master' of https://github.com/balintsimon/ask-mate-python
Rhyvan Nov 14, 2019
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
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
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
19c83e0
add JS to display authorized buttons only
Rhyvan Dec 11, 2019
b4ff8ce
Merge branch 'development' into web
Rhyvan Dec 11, 2019
2d63a4e
fix username display in comments for question
Rhyvan Dec 11, 2019
931a552
fix display that visitors can't see any buttons which requires login
Rhyvan Dec 11, 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/
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