Skip to content
Open
Show file tree
Hide file tree
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 Dec 9, 2019
e7c146f
get all questions, get all answers
tothmate911 Dec 9, 2019
d4e26a2
lists.html
Pivi14 Dec 9, 2019
bc9d363
get all answers, get all questions fix
tothmate911 Dec 9, 2019
6afc6ff
Merge branch 'master' of https://github.com/tothmate911/ask-mate-python
Pivi14 Dec 9, 2019
e395185
"requirements.txt delete pkg-resoursces==0.0.0"
Pivi14 Dec 9, 2019
4b67240
Filestructure
Blaon Dec 9, 2019
c360ec1
data handler get question by id
tothmate911 Dec 9, 2019
8c8049e
Merge branch 'master' of github.com:tothmate911/ask-mate-python
tothmate911 Dec 9, 2019
b7e541a
list designe
Pivi14 Dec 9, 2019
a3e7fd9
Merge branch 'master' of https://github.com/tothmate911/ask-mate-python
Pivi14 Dec 9, 2019
1434cf8
Basic server
Blaon Dec 9, 2019
6cb0f6d
Merge branch 'master' of https://github.com/tothmate911/ask-mate-python
Pivi14 Dec 9, 2019
9f8194a
add question updated not finished
Blaon Dec 9, 2019
a9fa849
Merge branch 'master' of http://github.com/tothmate911/ask-mate-python
Blaon Dec 9, 2019
6aae923
next id generator
tothmate911 Dec 9, 2019
b7e9d36
"lists.html designe rework"
Pivi14 Dec 9, 2019
92e0919
Merge remote-tracking branch 'origin/master'
Pivi14 Dec 9, 2019
45396fc
"lists.html done"
Pivi14 Dec 9, 2019
3addb81
"lists.html done, answer.html answers added"
Pivi14 Dec 10, 2019
341a08f
"lists.html done bugfix"
Pivi14 Dec 10, 2019
8aa31e9
"basic answer.html done"
Pivi14 Dec 10, 2019
a893d86
"image easyer"
Pivi14 Dec 10, 2019
f1ee036
"image height add, add_question.html done i hope"
Pivi14 Dec 10, 2019
3c9ead3
"lists.html bugfix, add_question.html comment_name"
Pivi14 Dec 10, 2019
a6e8f26
"test"
Pivi14 Dec 10, 2019
81a6f8c
"lists.html link bugfix"
Pivi14 Dec 10, 2019
b51929e
"lists.html main page is working"
Pivi14 Dec 10, 2019
c61ef86
add question, answer
tothmate911 Dec 10, 2019
8a33387
data_handler Merge branch 'master' of github.com:tothmate911/ask-mate…
tothmate911 Dec 10, 2019
1f99411
answer update
tothmate911 Dec 10, 2019
3275380
answer
tothmate911 Dec 10, 2019
e16aa33
"many work"
Pivi14 Dec 10, 2019
ad26a17
show_question
tothmate911 Dec 10, 2019
7eda26f
First page working
Blaon Dec 10, 2019
5cf65e1
"many work"
Pivi14 Dec 10, 2019
b708d1c
"many work"
Pivi14 Dec 10, 2019
8820d0d
Add question page working, but not adding id
Blaon Dec 10, 2019
71ed39a
Merge branch 'master' of https://github.com/tothmate911/ask-mate-python
Blaon Dec 10, 2019
99443fd
"main functions working"
Pivi14 Dec 10, 2019
597d143
"bugfix"
Pivi14 Dec 11, 2019
f54c3b9
"new master"
Pivi14 Dec 11, 2019
4651912
sort
tothmate911 Dec 11, 2019
b0f5b6f
"vote work in progress"
Pivi14 Dec 11, 2019
8aab04a
"Gigacommit Del Q finished"
Blaon Dec 11, 2019
eaa9042
sort
tothmate911 Dec 11, 2019
e386f8a
vote_up and vote_down append
Pivi14 Dec 11, 2019
3b0ee09
Del a finished?
Blaon Dec 11, 2019
7a4e726
Merge branch 'master' of https://github.com/tothmate911/ask-mate-python
Blaon Dec 11, 2019
b64cc1a
sort
tothmate911 Dec 11, 2019
f41c6c6
edit question in progress
tothmate911 Dec 12, 2019
51e702f
Merge branch 'master' of github.com:tothmate911/ask-mate-python
tothmate911 Dec 12, 2019
fcc876b
CSS: Basic Styling
Blaon Dec 12, 2019
cff5bda
Merge branch 'master' of https://github.com/tothmate911/ask-mate-python
Blaon Dec 12, 2019
73a6f0c
edit question
tothmate911 Dec 12, 2019
6f0db33
edit answer
tothmate911 Dec 12, 2019
9012b11
sort answer in progress
tothmate911 Dec 12, 2019
0aed23e
Merge branch 'master' of github.com:tothmate911/ask-mate-python
tothmate911 Dec 12, 2019
868667c
get image path
tothmate911 Dec 12, 2019
4112d23
sort answers
tothmate911 Dec 12, 2019
5e94456
sort answer
tothmate911 Dec 12, 2019
5549209
Merge branch 'master' of github.com:tothmate911/ask-mate-python
tothmate911 Dec 12, 2019
34590c6
Design GOOD
Blaon Dec 12, 2019
9c30acd
Merge branch 'master' of https://github.com/tothmate911/ask-mate-python
Blaon Dec 12, 2019
a4a6cb4
Ronaldo
tothmate911 Dec 12, 2019
5c796e5
img shown on lists page
Blaon Dec 12, 2019
042a8b7
Merge branch 'master' of https://github.com/tothmate911/ask-mate-python
Blaon Dec 12, 2019
14bd2c7
image add not necessary
tothmate911 Dec 12, 2019
41e30ba
Merge branch 'master' of https://github.com/tothmate911/ask-mate-python
Blaon Dec 12, 2019
2a67c4f
Merge branch 'master' of https://github.com/tothmate911/ask-mate-python
Blaon Dec 12, 2019
3bc2def
delete question start
tothmate911 Dec 13, 2019
587710a
pip8
tothmate911 Dec 13, 2019
be1232a
delete question works
tothmate911 Dec 13, 2019
b8af2d1
delete image bugfix
tothmate911 Dec 13, 2019
1a78b15
wetwegasgae gearg erg arg
Blaon Dec 13, 2019
7b57914
question delete started
tothmate911 Dec 13, 2019
3a56a48
image
tothmate911 Dec 13, 2019
97042dd
sql
tothmate911 Jan 6, 2020
f6ac8ba
db server
tothmate911 Jan 6, 2020
11126d1
add sql sample data
lterray Aug 28, 2017
88eac10
New comment base, but Mate is screwing with us, so i had to commit,pu…
Blaon Jan 7, 2020
59e3d33
Merge remote-tracking branch 'origin/master'
Blaon Jan 7, 2020
724ce0f
get all questions sorted
tothmate911 Jan 7, 2020
7ec52ec
add question
tothmate911 Jan 7, 2020
6a9a052
Search funtion inplemented
Pivi14 Jan 7, 2020
6d25036
Merge branch 'master' of https://github.com/tothmate911/ask-mate-python
Pivi14 Jan 7, 2020
d9ae79d
Can add new comment and write it into SQL database
Blaon Jan 7, 2020
17887ad
Merge remote-tracking branch 'origin/master'
Blaon Jan 7, 2020
b680357
get question no
tothmate911 Jan 7, 2020
38b4f0f
Merge remote-tracking branch 'origin/master'
Blaon Jan 7, 2020
0506237
Merged And working
Blaon Jan 7, 2020
a722d4e
merge
tothmate911 Jan 7, 2020
92a4065
add question
tothmate911 Jan 7, 2020
598984b
sql system
Pivi14 Jan 8, 2020
0916449
Merge remote-tracking branch 'origin/master'
Pivi14 Jan 8, 2020
0f8ad7f
delete answer debug
Pivi14 Jan 8, 2020
2f9a1b2
add answer fixed
Pivi14 Jan 8, 2020
3e268fd
search function fixed
Pivi14 Jan 8, 2020
00ae38b
Q & A Comment write in SQL.... needs to display also
Blaon Jan 8, 2020
8aed1ae
Merge remote-tracking branch 'origin/master'
Blaon Jan 8, 2020
a84b5a2
sort answers
tothmate911 Jan 8, 2020
47715f0
Merge branch 'master' of github.com:tothmate911/ask-mate-python
tothmate911 Jan 8, 2020
2c4defb
display first five question on main page
tothmate911 Jan 8, 2020
2721235
view number added
Pivi14 Jan 8, 2020
846d0ce
delete print
Pivi14 Jan 8, 2020
03eb812
link to all question
tothmate911 Jan 8, 2020
52cc665
Merge branch 'master' of github.com:tothmate911/ask-mate-python
tothmate911 Jan 8, 2020
ed49a1e
answer_id delete
Pivi14 Jan 8, 2020
df4ba2a
Merge remote-tracking branch 'origin/master'
Pivi14 Jan 8, 2020
d7ad2ff
Q&A comment sorting from id
Blaon Jan 8, 2020
f5819d9
Merge remote-tracking branch 'origin/master'
Blaon Jan 8, 2020
83e9a23
Merge remote-tracking branch 'origin/master'
Pivi14 Jan 8, 2020
1a8b405
answer_id delete
Pivi14 Jan 8, 2020
1ded488
view bug fixed
Pivi14 Jan 8, 2020
3566851
css
tothmate911 Jan 8, 2020
4663a5b
merge
tothmate911 Jan 8, 2020
545bb47
images upload and delete fixed
Pivi14 Jan 8, 2020
4c9d664
Merge remote-tracking branch 'origin/master'
Pivi14 Jan 8, 2020
f42e02f
css
tothmate911 Jan 8, 2020
5b2a1f8
Merge branch 'master' of github.com:tothmate911/ask-mate-python
tothmate911 Jan 8, 2020
01b9919
visible
tothmate911 Jan 8, 2020
bbcc964
Commit at individual question works
Blaon Jan 8, 2020
0f4d5dd
Merge remote-tracking branch 'origin/master'
Pivi14 Jan 8, 2020
8dd8883
display bugfix
tothmate911 Jan 8, 2020
74320f6
comment in html
Pivi14 Jan 8, 2020
14dc76f
table
tothmate911 Jan 8, 2020
7c15a3f
Merge remote-tracking branch 'origin/master'
Pivi14 Jan 8, 2020
c9d5b4e
background
tothmate911 Jan 8, 2020
17233a3
comment in html
Pivi14 Jan 8, 2020
ee744fd
Merge remote-tracking branch 'origin/master'
Pivi14 Jan 8, 2020
fdfb9bb
Edit Comment Work in progress
Blaon Jan 8, 2020
e254266
Merge remote-tracking branch 'origin/master'
Blaon Jan 8, 2020
c8ac4c1
Merge remote-tracking branch 'origin/master'
Blaon Jan 8, 2020
639c3b9
delete complite
Pivi14 Jan 8, 2020
0a3889a
css
tothmate911 Jan 8, 2020
a232687
Merge branch 'master' of github.com:tothmate911/ask-mate-python
tothmate911 Jan 8, 2020
9dc5625
display bugfix
tothmate911 Jan 8, 2020
bed53be
image delete bugfix
Pivi14 Jan 8, 2020
5f4f0e2
Del and Edit maybe working?
Blaon Jan 8, 2020
50a9653
Merge remote-tracking branch 'origin/master'
Blaon Jan 8, 2020
ab11da2
Merge branch 'master' of https://github.com/tothmate911/ask-mate-python
Blaon Jan 8, 2020
36e6de2
Merge branch 'master' of github.com:tothmate911/ask-mate-python
tothmate911 Jan 8, 2020
32ff571
0.3.4.5
Blaon Jan 8, 2020
6b4c5ed
Merge remote-tracking branch 'origin/master'
Blaon Jan 8, 2020
8888543
Merge remote-tracking branch 'origin/master'
Pivi14 Jan 8, 2020
9fe472c
0.3.4.6
Blaon Jan 8, 2020
acebd46
apostrophe bugfix, search highlight
Pivi14 Jan 8, 2020
6fdc156
css
tothmate911 Jan 9, 2020
2bcec23
table appear nicer
tothmate911 Jan 9, 2020
4cc5278
tag work in progress
Pivi14 Jan 9, 2020
48b60e0
Merge remote-tracking branch 'origin/master'
Pivi14 Jan 9, 2020
34f2fcd
working on css
tothmate911 Jan 9, 2020
13f43d9
tag work in progress
Pivi14 Jan 9, 2020
d0af9da
Merge remote-tracking branch 'origin/master'
Pivi14 Jan 9, 2020
b75df6e
lists
tothmate911 Jan 9, 2020
16d0101
Merge branch 'master' of github.com:tothmate911/ask-mate-python
tothmate911 Jan 9, 2020
6c7f689
tag functions all done
Pivi14 Jan 9, 2020
826fcbd
css
tothmate911 Jan 9, 2020
18cec3d
Merge branch 'master' of github.com:tothmate911/ask-mate-python
tothmate911 Jan 9, 2020
cf978b5
delete question added
Pivi14 Jan 9, 2020
33bd3c9
view up update
Pivi14 Jan 9, 2020
114b7f5
css
tothmate911 Jan 9, 2020
891ed16
tag bugfix
Pivi14 Jan 9, 2020
a82381a
image full size added
Pivi14 Jan 9, 2020
4eddbc5
image full size complited
Pivi14 Jan 9, 2020
5c92f63
image full size complited
Pivi14 Jan 9, 2020
c327f79
css
tothmate911 Jan 10, 2020
f03efcc
Merge branch 'master' of github.com:tothmate911/ask-mate-python
tothmate911 Jan 10, 2020
1b0e509
reafctor
tothmate911 Jan 14, 2020
700a31f
reafctor
tothmate911 Jan 14, 2020
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
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ target/
# pyenv
.python-version

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# celery beat schedule file
celerybeat-schedule

Expand Down Expand Up @@ -101,4 +110,4 @@ ENV/
.mypy_cache/

# pycharm files
.idea/
.idea/
101 changes: 101 additions & 0 deletions data_handler.py
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
42 changes: 42 additions & 0 deletions database/ask_mate_database.sql
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');
46 changes: 46 additions & 0 deletions database_common.py
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
Loading