-
Notifications
You must be signed in to change notification settings - Fork 92
Feature #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tothmate911
wants to merge
170
commits into
CodecoolBase:master
Choose a base branch
from
tothmate911:feature
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feature #35
Changes from all commits
Commits
Show all changes
170 commits
Select commit
Hold shift + click to select a range
b82b5f3
get all questions, get all answers
tothmate911 e7c146f
get all questions, get all answers
tothmate911 d4e26a2
lists.html
Pivi14 bc9d363
get all answers, get all questions fix
tothmate911 6afc6ff
Merge branch 'master' of https://github.com/tothmate911/ask-mate-python
Pivi14 e395185
"requirements.txt delete pkg-resoursces==0.0.0"
Pivi14 4b67240
Filestructure
Blaon c360ec1
data handler get question by id
tothmate911 8c8049e
Merge branch 'master' of github.com:tothmate911/ask-mate-python
tothmate911 b7e541a
list designe
Pivi14 a3e7fd9
Merge branch 'master' of https://github.com/tothmate911/ask-mate-python
Pivi14 1434cf8
Basic server
Blaon 6cb0f6d
Merge branch 'master' of https://github.com/tothmate911/ask-mate-python
Pivi14 9f8194a
add question updated not finished
Blaon a9fa849
Merge branch 'master' of http://github.com/tothmate911/ask-mate-python
Blaon 6aae923
next id generator
tothmate911 b7e9d36
"lists.html designe rework"
Pivi14 92e0919
Merge remote-tracking branch 'origin/master'
Pivi14 45396fc
"lists.html done"
Pivi14 3addb81
"lists.html done, answer.html answers added"
Pivi14 341a08f
"lists.html done bugfix"
Pivi14 8aa31e9
"basic answer.html done"
Pivi14 a893d86
"image easyer"
Pivi14 f1ee036
"image height add, add_question.html done i hope"
Pivi14 3c9ead3
"lists.html bugfix, add_question.html comment_name"
Pivi14 a6e8f26
"test"
Pivi14 81a6f8c
"lists.html link bugfix"
Pivi14 b51929e
"lists.html main page is working"
Pivi14 c61ef86
add question, answer
tothmate911 8a33387
data_handler Merge branch 'master' of github.com:tothmate911/ask-mate…
tothmate911 1f99411
answer update
tothmate911 3275380
answer
tothmate911 e16aa33
"many work"
Pivi14 ad26a17
show_question
tothmate911 7eda26f
First page working
Blaon 5cf65e1
"many work"
Pivi14 b708d1c
"many work"
Pivi14 8820d0d
Add question page working, but not adding id
Blaon 71ed39a
Merge branch 'master' of https://github.com/tothmate911/ask-mate-python
Blaon 99443fd
"main functions working"
Pivi14 597d143
"bugfix"
Pivi14 f54c3b9
"new master"
Pivi14 4651912
sort
tothmate911 b0f5b6f
"vote work in progress"
Pivi14 8aab04a
"Gigacommit Del Q finished"
Blaon eaa9042
sort
tothmate911 e386f8a
vote_up and vote_down append
Pivi14 3b0ee09
Del a finished?
Blaon 7a4e726
Merge branch 'master' of https://github.com/tothmate911/ask-mate-python
Blaon b64cc1a
sort
tothmate911 f41c6c6
edit question in progress
tothmate911 51e702f
Merge branch 'master' of github.com:tothmate911/ask-mate-python
tothmate911 fcc876b
CSS: Basic Styling
Blaon cff5bda
Merge branch 'master' of https://github.com/tothmate911/ask-mate-python
Blaon 73a6f0c
edit question
tothmate911 6f0db33
edit answer
tothmate911 9012b11
sort answer in progress
tothmate911 0aed23e
Merge branch 'master' of github.com:tothmate911/ask-mate-python
tothmate911 868667c
get image path
tothmate911 4112d23
sort answers
tothmate911 5e94456
sort answer
tothmate911 5549209
Merge branch 'master' of github.com:tothmate911/ask-mate-python
tothmate911 34590c6
Design GOOD
Blaon 9c30acd
Merge branch 'master' of https://github.com/tothmate911/ask-mate-python
Blaon a4a6cb4
Ronaldo
tothmate911 5c796e5
img shown on lists page
Blaon 042a8b7
Merge branch 'master' of https://github.com/tothmate911/ask-mate-python
Blaon 14bd2c7
image add not necessary
tothmate911 41e30ba
Merge branch 'master' of https://github.com/tothmate911/ask-mate-python
Blaon 2a67c4f
Merge branch 'master' of https://github.com/tothmate911/ask-mate-python
Blaon 3bc2def
delete question start
tothmate911 587710a
pip8
tothmate911 be1232a
delete question works
tothmate911 b8af2d1
delete image bugfix
tothmate911 1a78b15
wetwegasgae gearg erg arg
Blaon 7b57914
question delete started
tothmate911 3a56a48
image
tothmate911 97042dd
sql
tothmate911 f6ac8ba
db server
tothmate911 11126d1
add sql sample data
lterray 88eac10
New comment base, but Mate is screwing with us, so i had to commit,pu…
Blaon 59e3d33
Merge remote-tracking branch 'origin/master'
Blaon 724ce0f
get all questions sorted
tothmate911 7ec52ec
add question
tothmate911 6a9a052
Search funtion inplemented
Pivi14 6d25036
Merge branch 'master' of https://github.com/tothmate911/ask-mate-python
Pivi14 d9ae79d
Can add new comment and write it into SQL database
Blaon 17887ad
Merge remote-tracking branch 'origin/master'
Blaon b680357
get question no
tothmate911 38b4f0f
Merge remote-tracking branch 'origin/master'
Blaon 0506237
Merged And working
Blaon a722d4e
merge
tothmate911 92a4065
add question
tothmate911 598984b
sql system
Pivi14 0916449
Merge remote-tracking branch 'origin/master'
Pivi14 0f8ad7f
delete answer debug
Pivi14 2f9a1b2
add answer fixed
Pivi14 3e268fd
search function fixed
Pivi14 00ae38b
Q & A Comment write in SQL.... needs to display also
Blaon 8aed1ae
Merge remote-tracking branch 'origin/master'
Blaon a84b5a2
sort answers
tothmate911 47715f0
Merge branch 'master' of github.com:tothmate911/ask-mate-python
tothmate911 2c4defb
display first five question on main page
tothmate911 2721235
view number added
Pivi14 846d0ce
delete print
Pivi14 03eb812
link to all question
tothmate911 52cc665
Merge branch 'master' of github.com:tothmate911/ask-mate-python
tothmate911 ed49a1e
answer_id delete
Pivi14 df4ba2a
Merge remote-tracking branch 'origin/master'
Pivi14 d7ad2ff
Q&A comment sorting from id
Blaon f5819d9
Merge remote-tracking branch 'origin/master'
Blaon 83e9a23
Merge remote-tracking branch 'origin/master'
Pivi14 1a8b405
answer_id delete
Pivi14 1ded488
view bug fixed
Pivi14 3566851
css
tothmate911 4663a5b
merge
tothmate911 545bb47
images upload and delete fixed
Pivi14 4c9d664
Merge remote-tracking branch 'origin/master'
Pivi14 f42e02f
css
tothmate911 5b2a1f8
Merge branch 'master' of github.com:tothmate911/ask-mate-python
tothmate911 01b9919
visible
tothmate911 bbcc964
Commit at individual question works
Blaon 0f4d5dd
Merge remote-tracking branch 'origin/master'
Pivi14 8dd8883
display bugfix
tothmate911 74320f6
comment in html
Pivi14 14dc76f
table
tothmate911 7c15a3f
Merge remote-tracking branch 'origin/master'
Pivi14 c9d5b4e
background
tothmate911 17233a3
comment in html
Pivi14 ee744fd
Merge remote-tracking branch 'origin/master'
Pivi14 fdfb9bb
Edit Comment Work in progress
Blaon e254266
Merge remote-tracking branch 'origin/master'
Blaon c8ac4c1
Merge remote-tracking branch 'origin/master'
Blaon 639c3b9
delete complite
Pivi14 0a3889a
css
tothmate911 a232687
Merge branch 'master' of github.com:tothmate911/ask-mate-python
tothmate911 9dc5625
display bugfix
tothmate911 bed53be
image delete bugfix
Pivi14 5f4f0e2
Del and Edit maybe working?
Blaon 50a9653
Merge remote-tracking branch 'origin/master'
Blaon ab11da2
Merge branch 'master' of https://github.com/tothmate911/ask-mate-python
Blaon 36e6de2
Merge branch 'master' of github.com:tothmate911/ask-mate-python
tothmate911 32ff571
0.3.4.5
Blaon 6b4c5ed
Merge remote-tracking branch 'origin/master'
Blaon 8888543
Merge remote-tracking branch 'origin/master'
Pivi14 9fe472c
0.3.4.6
Blaon acebd46
apostrophe bugfix, search highlight
Pivi14 6fdc156
css
tothmate911 2bcec23
table appear nicer
tothmate911 4cc5278
tag work in progress
Pivi14 48b60e0
Merge remote-tracking branch 'origin/master'
Pivi14 34f2fcd
working on css
tothmate911 13f43d9
tag work in progress
Pivi14 d0af9da
Merge remote-tracking branch 'origin/master'
Pivi14 b75df6e
lists
tothmate911 16d0101
Merge branch 'master' of github.com:tothmate911/ask-mate-python
tothmate911 6c7f689
tag functions all done
Pivi14 826fcbd
css
tothmate911 18cec3d
Merge branch 'master' of github.com:tothmate911/ask-mate-python
tothmate911 cf978b5
delete question added
Pivi14 33bd3c9
view up update
Pivi14 114b7f5
css
tothmate911 891ed16
tag bugfix
Pivi14 a82381a
image full size added
Pivi14 4eddbc5
image full size complited
Pivi14 5c92f63
image full size complited
Pivi14 c327f79
css
tothmate911 f03efcc
Merge branch 'master' of github.com:tothmate911/ask-mate-python
tothmate911 1b0e509
reafctor
tothmate911 700a31f
reafctor
tothmate911 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| import os | ||
| import database_manager | ||
|
|
||
| ANSWER_FILE_PATH = 'sample_data/answer.csv' | ||
| QUESTION_FILE_PATH = 'sample_data/question.csv' | ||
| IMAGE_UPLOAD_PATH = "static/images" | ||
| ALLOWED_IMAGE_TYPE = ["PNG", "JPG"] | ||
| ROOT_PATH = 'static/images' | ||
|
|
||
|
|
||
| def sort_data(list_of_dicts, order_by, order_direction): | ||
| converted_list = convert_numbers_in_list_to_int(list_of_dicts) | ||
| sorted_list_of_dicts = sorted(converted_list, key=lambda item: item[order_by], | ||
| reverse=True if order_direction == 'desc' else False) | ||
| return sorted_list_of_dicts | ||
|
|
||
|
|
||
| def convert_numbers_in_list_to_int(all_data): | ||
| for i in range(len(all_data)): | ||
| all_data[i]['vote_number'] = int(all_data[i]['vote_number']) | ||
| try: | ||
| all_data[i]['view_number'] = int(all_data[i]['view_number']) | ||
| except KeyError: | ||
| continue | ||
| return all_data | ||
|
|
||
|
|
||
| def allowed_image(filename): | ||
| if not "." in filename: | ||
| return False | ||
| ext = filename.rsplit(".", 1)[1] | ||
| if ext.upper() in ALLOWED_IMAGE_TYPE: | ||
| return True | ||
| else: | ||
| return False | ||
|
|
||
|
|
||
| def get_image_path_for_question_by_id(question_id): | ||
| delete_file = [] | ||
| question = database_manager.get_question_by_id(question_id) | ||
| answers_by_question = database_manager.get_all_answer_by_question_id_sorted(question_id) | ||
| delete_file.append(question[0]['image']) | ||
| for answer in answers_by_question: | ||
| delete_file.append(answer['image']) | ||
| return delete_file | ||
|
|
||
|
|
||
| def get_image_path_for_answer_by_id(answer_id): | ||
| answer = database_manager.get_answer_by_id(answer_id) | ||
| return answer[0]['image'] | ||
|
|
||
|
|
||
| def delete_image_by_id(id, answer=False): | ||
| try: | ||
| if answer: | ||
| path = get_image_path_for_answer_by_id(id) | ||
| os.remove(path) | ||
| else: | ||
| path = get_image_path_for_question_by_id(id) | ||
| for file in path: | ||
| os.remove(file) | ||
| except: | ||
| pass | ||
|
|
||
|
|
||
| def apostroph_change(text): | ||
| change = ('title', 'message', 'name') | ||
| new_text = text | ||
| for column in change: | ||
| try: | ||
| new_text[column] = text[column].replace('\'', '\"') | ||
| except: | ||
| continue | ||
| return new_text | ||
|
|
||
| def search_highlight(text, search_word): | ||
| change = ('title', 'message', 'name') | ||
| new_text = text | ||
| for element_index in range(len(text)): | ||
| for column in change: | ||
| try: | ||
| new_text[element_index][column] = text[element_index][column].replace(f'{search_word}', f'<b>{search_word}</b>') | ||
| except: | ||
| continue | ||
| return new_text | ||
|
|
||
| def remove_from_list(questions): | ||
| remove = [] | ||
| for index in range(len(questions)): | ||
| if questions[index]['id'] is None: | ||
| remove.append(questions[index]) | ||
| for element in remove: | ||
| questions.remove(element) | ||
| return questions | ||
|
|
||
| def tag_duplicate_check(tag): | ||
| all_tag = database_manager.all_tag_name() | ||
| for element in all_tag: | ||
| if element['name'] == tag: | ||
| return True | ||
| return False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| DROP TABLE IF EXISTS question; | ||
| DROP TABLE IF EXISTS answer; | ||
| DROP TABLE IF EXISTS comment; | ||
| DROP TABLE IF EXISTS question_tag; | ||
| DROP TABLE IF EXISTS tag_; | ||
|
|
||
| CREATE TABLE question ( | ||
| id SERIAL PRIMARY KEY, | ||
| submission_time integer NOT NULL, | ||
| view_number integer, | ||
| vote_number integer, | ||
| title character varying(2550), | ||
| message character varying(2550) NOT NULL, | ||
| image character varying(2550) | ||
| ); | ||
|
|
||
| CREATE TABLE answer ( | ||
| id SERIAL PRIMARY KEY, | ||
| submission_time character varying(255) NOT NULL, | ||
| vote_number integer, | ||
| question_id integer, | ||
| message character varying(255) NOT NULL, | ||
| image character varying(255) | ||
| ); | ||
|
|
||
| CREATE TABLE comment ( | ||
| id SERIAL PRIMARY KEY, | ||
| question_id integer, | ||
| answer_id integer, | ||
| message character varying(255) NOT NULL, | ||
| submission_time character varying(255) NOT NULL, | ||
| edited_number integer | ||
| ); | ||
|
|
||
| INSERT INTO question VALUES | ||
| (0, 1493368154, 29, 7, 'How to make lists in Python?', 'I am totally new to this, any hints?', NULL), | ||
| (1, 1493068124, 15, 9, 'Wordpress loading multiple jQuery Versions', 'I developed a plugin that uses the jquery booklet plugin (http://builtbywill.com/booklet/#/) this plugin binds a function to $ so I cann call $(''.myBook'').booklet() I could easy managing the loading order with wp_enqueue_script so first I load jquery then I load booklet so everything is fine. BUT in my theme i also using jquery via webpack so the loading order is now following: jquery booklet app.js (bundled file with webpack, including jquery)', 'images/image1.png'), | ||
| (2, 1493015432, 1364, 57, 'Drawing canvas with an image picked with Cordova Camera Plugin', 'I''m getting an image from device and drawing a canvas with filters using Pixi JS. It works all well using computer to get an image. But when I''m on IOS, it throws errors such as cross origin issue, or that I''m trying to use an unknown format. This is the code I''m using to draw the image (that works on web/desktop but not cordova built ios app)', NULL); | ||
|
|
||
| INSERT INTO answer VALUES | ||
| (0, 1493398154, 5, 0, 'You need to use brackets: my_list = []'), | ||
| (1, 1493088154, 35, 0, 'Look it up in the Python docs'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import os | ||
| import psycopg2 | ||
| import psycopg2.extras | ||
| from psycopg2 import sql | ||
|
|
||
|
|
||
| def get_connection_string(): | ||
| 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: | ||
| 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() | ||
| 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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.