Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
166 commits
Select commit Hold shift + click to select a range
1f16087
add sql sample data
lterray Aug 28, 2017
e19eb01
Merge branch 'master' into 2nd-tw-week
lterray Jun 28, 2018
05af02a
Remove drop sequence from sample SQL
szrudi Sep 25, 2018
ddb6759
Add connection.py template as data_handler
kovacsgergo128 Sep 9, 2019
9b028a6
Base server module
Spumi Sep 10, 2019
78492a9
Added: dictionary generator functions for adding questions and answers
Spumi Sep 10, 2019
e60c20f
Added working data directory
Spumi Sep 10, 2019
f5f50f7
Added data files
Spumi Sep 10, 2019
4b4540a
Added csvreader for answers and questions
Spumi Sep 10, 2019
a3b5e2d
Added csv writer and append feature
Spumi Sep 10, 2019
6bea474
Create Home page and List html
mateRajnai Sep 10, 2019
e660fcf
Create list functionality
mateRajnai Sep 10, 2019
975c821
Merge branch 'master' of https://github.com/Spumi/ask-mate-python
mateRajnai Sep 10, 2019
afaba31
Create list functionality
mateRajnai Sep 10, 2019
2af6099
Fixed dictinary value type
Spumi Sep 10, 2019
400b02f
Html layout changes
Spumi Sep 10, 2019
dc08dea
Merge branch 'master' of github.com:Spumi/ask-mate-python
Spumi Sep 10, 2019
fa1b0b1
Fixed merging issues
Spumi Sep 10, 2019
3afcbc9
Add display_question.html template
kovacsgergo128 Sep 10, 2019
c238014
Add get_question and get_answer to data_handler module
kovacsgergo128 Sep 10, 2019
5fc985a
Add /question/<question_id> route to server module
kovacsgergo128 Sep 10, 2019
ae0330c
Refactor question and answer stroring code
Spumi Sep 10, 2019
29d7234
Add link to /list referring to question/guestion id
mateRajnai Sep 10, 2019
8da7bf2
Correct function definition of sorting data
mateRajnai Sep 10, 2019
ce9223a
Merge branch 'master' of https://github.com/Spumi/ask-mate-python
mateRajnai Sep 10, 2019
27337dc
Merge branch 'master' of github.com:Spumi/ask-mate-python
kovacsgergo128 Sep 10, 2019
0957cfb
Finish question display functionality
kovacsgergo128 Sep 10, 2019
b375ab8
Merge branch 'master' of github.com:Spumi/ask-mate-python
kovacsgergo128 Sep 10, 2019
db4c22e
Added id generator
Spumi Sep 10, 2019
dd08357
Merge branch 'master' of github.com:Spumi/ask-mate-python
Spumi Sep 10, 2019
5a78ed6
Fix question display funcionality
kovacsgergo128 Sep 10, 2019
332f018
Merge branch 'master' of github.com:Spumi/ask-mate-python
kovacsgergo128 Sep 10, 2019
412d746
Add general sorting - not complete
mateRajnai Sep 10, 2019
bd87a2b
Create delete_question function
mateRajnai Sep 10, 2019
7cc5119
Add delete question link
mateRajnai Sep 10, 2019
49b2610
Create modify_question_database function
mateRajnai Sep 10, 2019
ff439d0
Add general sorting
mateRajnai Sep 10, 2019
e7ffdb1
Add new question and edit question buttons to display_question template
kovacsgergo128 Sep 10, 2019
138449c
Replace new question button to delete button as new question button …
kovacsgergo128 Sep 10, 2019
b76a48a
Fixed issue causing questions saved as answers
Spumi Sep 11, 2019
eb3e93c
fixed error causing question id for asnwers to be 0
Spumi Sep 11, 2019
b4fdbe1
Fixed: answer id generation
Spumi Sep 11, 2019
c2d59f1
refactor in server module
Spumi Sep 11, 2019
ebe1d6a
Added links to post answers and questions
Spumi Sep 11, 2019
8c08146
Fix URL problem in sort functionality
mateRajnai Sep 11, 2019
4f6ddd0
Fix URL bug in sorting
mateRajnai Sep 11, 2019
3dca545
Added feature: vote up question
Spumi Sep 11, 2019
9935612
Added save questions functinality to data handler
Spumi Sep 11, 2019
6c67802
Add header capitalize to display_question template
kovacsgergo128 Sep 11, 2019
64d494b
fixed list of dict saving in connection module
Spumi Sep 11, 2019
64d59ff
Add edit-question.html template
kovacsgergo128 Sep 11, 2019
fd681f1
Add update question function to data handler module
kovacsgergo128 Sep 11, 2019
3c887bd
Add edit_question route to server
kovacsgergo128 Sep 11, 2019
1487f1c
Merge branch 'master' of github.com:Spumi/ask-mate-python
kovacsgergo128 Sep 11, 2019
48b45fa
Merge branch 'master' of github.com:Spumi/ask-mate-python
Spumi Sep 11, 2019
c22bc45
Merge branch 'master' of github.com:Spumi/ask-mate-python
Spumi Sep 11, 2019
0c88111
Remove add-question button from index page
mateRajnai Sep 11, 2019
2af0ee5
Correct delete question URL in form tag
mateRajnai Sep 11, 2019
caa6779
Small name modifikation
mateRajnai Sep 11, 2019
0262995
Merge branch 'master' of https://github.com/Spumi/ask-mate-python
mateRajnai Sep 11, 2019
4dcbb07
Fix variable name (id) in edit-question temlate
kovacsgergo128 Sep 11, 2019
5dfe41b
Correct update_question function in data handler module
kovacsgergo128 Sep 11, 2019
c095d98
Correct edit_question route in server
kovacsgergo128 Sep 11, 2019
2f02061
Fixed crash at id generation when the list has 0 elements
Spumi Sep 11, 2019
eac068d
Fix edit_question func in server
kovacsgergo128 Sep 11, 2019
dfbd184
Merge branch 'master' of github.com:Spumi/ask-mate-python
kovacsgergo128 Sep 11, 2019
0023394
Remove functionality variable
mateRajnai Sep 11, 2019
6951270
Merge branch 'master' of https://github.com/Spumi/ask-mate-python
mateRajnai Sep 11, 2019
8330bf9
Add delete record to data_handler module - currentyl used to delete a…
kovacsgergo128 Sep 11, 2019
ac3825a
Add delete_answer func to server
kovacsgergo128 Sep 11, 2019
603cf9b
Add delete_answer button to display_question template
kovacsgergo128 Sep 11, 2019
f389f12
Merge branch 'master' of github.com:Spumi/ask-mate-python
kovacsgergo128 Sep 11, 2019
09d7ffc
Create and implement readable date function
mateRajnai Sep 11, 2019
4d59c56
Create and implement readable time function
mateRajnai Sep 11, 2019
ca7b3b6
added vote feature
Spumi Sep 11, 2019
27b0c01
Merge branch 'master' of github.com:Spumi/ask-mate-python
Spumi Sep 11, 2019
d12bb58
Add up and down vote buttons to display_question template
kovacsgergo128 Sep 11, 2019
35e8d68
Merge branch 'master' of github.com:Spumi/ask-mate-python
kovacsgergo128 Sep 11, 2019
de3de56
Added upload file feature
Spumi Sep 11, 2019
50bdaa3
Fix answer voting buttons
kovacsgergo128 Sep 11, 2019
e3eb79d
Change answer vote function to redirect to particular question site
kovacsgergo128 Sep 11, 2019
bfab5bc
Merge branch 'master' of github.com:Spumi/ask-mate-python
kovacsgergo128 Sep 11, 2019
49decd2
Add question voting buttons to display_question template
kovacsgergo128 Sep 11, 2019
55854bc
Finish delete question functionality
mateRajnai Sep 11, 2019
85d04bd
Remove redundant data saving function
mateRajnai Sep 11, 2019
5aa9db9
added upload/display image feature
Spumi Sep 11, 2019
df3819d
Merge branch 'master' of github.com:Spumi/ask-mate-python
Spumi Sep 11, 2019
d1e0fe3
Added folder containing user uploaded images
Spumi Sep 11, 2019
9307755
Refactor: Moved functions to util module
Spumi Sep 11, 2019
299eb11
Create %asking if really want to delete% functionality
mateRajnai Sep 11, 2019
7d68832
Add search for keywords functionality
mateRajnai Sep 12, 2019
4e6d82c
Merge add/eedit question pages intoa single html
Spumi Sep 12, 2019
8f766ec
Revert merging of htmls
Spumi Sep 12, 2019
a8a35b1
Fix: issue question upload when not uploading image sometimes causing
Spumi Sep 12, 2019
5294d58
Take out search for question
mateRajnai Sep 12, 2019
b21d1ff
Merge branch 'master' of https://github.com/Spumi/ask-mate-python
mateRajnai Sep 12, 2019
9838fa6
Add search-for-keywords functionality
mateRajnai Sep 12, 2019
8ba2eeb
Page title changes according to context (add/edit)
Spumi Sep 12, 2019
5b1a300
Sorting answers by date on display question page
Spumi Sep 12, 2019
3831ef0
Modify title order on main page
mateRajnai Sep 12, 2019
34efcba
Merge branch 'master' of https://github.com/Spumi/ask-mate-python
mateRajnai Sep 12, 2019
ca96449
Refactor
Spumi Sep 12, 2019
1f0771d
Merge branch 'master' of github.com:Spumi/ask-mate-python
Spumi Sep 12, 2019
e3a319a
Change main page style
mateRajnai Sep 12, 2019
9d3abab
Merge branch 'master' of https://github.com/Spumi/ask-mate-python
mateRajnai Sep 12, 2019
c0cb550
Change main page style
mateRajnai Sep 12, 2019
4023123
Refactor list_question function
mateRajnai Sep 12, 2019
54550ad
Change style
mateRajnai Sep 12, 2019
a62f47c
Fixed issue not showing image on question details
Spumi Sep 12, 2019
f3c3731
Add some design to display question
kovacsgergo128 Sep 12, 2019
355c067
Merge branch 'master' of github.com:Spumi/ask-mate-python
kovacsgergo128 Sep 12, 2019
ee5d4b8
Refactor update question and delete record functions
kovacsgergo128 Sep 12, 2019
42cd9c5
Add 'sure?' question to delete answer feature
kovacsgergo128 Sep 12, 2019
d65bd97
Refactor in server module
Spumi Sep 13, 2019
58a8091
Write docstrings for handle_list_question and convert_to_readable_dat…
mateRajnai Sep 13, 2019
0b57167
Move handle_list_question (util) into list_question (server)
mateRajnai Sep 13, 2019
55c6af3
Move headers form connection to data_handler, delete redundant comments
mateRajnai Sep 13, 2019
9877190
add sql sample data
lterray Aug 28, 2017
f5bf4db
Merge branch 'master' of github.com:Spumi/ask-mate-python
Spumi Sep 23, 2019
ee32710
Add connection and data manager module - connection to database and t…
kovacsgergo128 Sep 23, 2019
e2ecf8a
Add sqlconnection
Spumi Sep 23, 2019
906f2d3
Merge branch '2nd-tw-week' of github.com:Spumi/ask-mate-python into 2…
Spumi Sep 23, 2019
63b9bb6
Merge branch '2nd-tw-week' of github.com:Spumi/ask-mate-python into 2…
kovacsgergo128 Sep 23, 2019
3fe8205
Implemented: list now questions uses sql
Spumi Sep 23, 2019
eeeb8d8
Delete data_manager.py inserted earlier locally
kovacsgergo128 Sep 23, 2019
7957d0a
Merge branch '2nd-tw-week' of github.com:Spumi/ask-mate-python into 2…
kovacsgergo128 Sep 23, 2019
d45984a
Changed: Added sql support question/answer to sql
Spumi Sep 23, 2019
c19fca1
Rewrite question_display to use database in server module
kovacsgergo128 Sep 23, 2019
5df6d7d
Merge branch '2nd-tw-week' of github.com:Spumi/ask-mate-python into 2…
Spumi Sep 23, 2019
36cdf1b
Merge branch '2nd-tw-week' of github.com:Spumi/ask-mate-python into 2…
Spumi Sep 23, 2019
83feb59
delete_question to SQL - refactor needed
mateRajnai Sep 23, 2019
3b211ba
Merge branch '2nd-tw-week' of https://github.com/Spumi/ask-mate-pytho…
mateRajnai Sep 23, 2019
7eabca6
delete_question convert to SQL - refactor needed
mateRajnai Sep 23, 2019
4acabf6
Reworked vote system to use sql instead of csv
Spumi Sep 23, 2019
8f21737
Fixed: htmldoest display missing image when no image is uploaded
Spumi Sep 23, 2019
ff8ca5b
Put search_for_questions to SQL; Search in answer added
mateRajnai Sep 23, 2019
3f8a943
Refactor search_for_questions function
mateRajnai Sep 23, 2019
7388481
Remove sorting_data function from util.py
mateRajnai Sep 23, 2019
c3668bc
Remove convert_to_date function
mateRajnai Sep 23, 2019
cadaa39
Exchange to SQL in delete_question, search_for_keywords
mateRajnai Sep 24, 2019
9ecd92a
Fix bug in delete_question func on server.py
mateRajnai Sep 24, 2019
cc6670a
Change delete_record func in data_handler to use database
kovacsgergo128 Sep 24, 2019
66129c4
Modify delete_answer in server module as database return question_id …
kovacsgergo128 Sep 24, 2019
75f37dd
Merge branch '2nd-tw-week' of github.com:Spumi/ask-mate-python into 2…
kovacsgergo128 Sep 24, 2019
160bfe1
Search keywords in questions put into SQL (search_for_q func)
mateRajnai Sep 24, 2019
db6f21e
Added backend functions for comments
Spumi Sep 24, 2019
961b61b
Merge branch '2nd-tw-week' of github.com:Spumi/ask-mate-python into 2…
Spumi Sep 24, 2019
93d8368
Added comment display feature to html
Spumi Sep 24, 2019
d8d4eb5
Fixed: User is now retuned to question display after posting a comment
Spumi Sep 24, 2019
e2ac18b
Added display comment feature for answers
Spumi Sep 24, 2019
a80a090
Put search_for_question into SQL with several bugs
mateRajnai Sep 24, 2019
cb0e8a5
Fix bugs in search_for_questions func
mateRajnai Sep 24, 2019
ef45b9f
Simplify search_for_questions; there is a bug to correct
mateRajnai Sep 24, 2019
8c31ec6
Simplify search_for_question; still one bug
mateRajnai Sep 24, 2019
a97e7b5
Add handle_edit_question to util module
kovacsgergo128 Sep 24, 2019
20e5992
Rewrite get_question in data_handler to use database
kovacsgergo128 Sep 24, 2019
b04a218
Rewrite get_question_related_answers in data_handler to use database
kovacsgergo128 Sep 24, 2019
0735772
Add escape_single_quote to data handler
kovacsgergo128 Sep 24, 2019
dc53441
Refactor display_question to use get question and get question relate…
kovacsgergo128 Sep 24, 2019
8d13d0b
Rewrite and rename update_question to update entry which can be used…
kovacsgergo128 Sep 24, 2019
7a59bc7
Rewrite edit question route now it saves the image as well
kovacsgergo128 Sep 24, 2019
6c6a7f7
Cast question_id into string to handle form action properly
kovacsgergo128 Sep 24, 2019
9cbdf8e
Merge branch '2nd-tw-week' of github.com:Spumi/ask-mate-python into 2…
kovacsgergo128 Sep 24, 2019
ca2e960
Correct comment display issues written in email 20190924 20:30
kovacsgergo128 Sep 24, 2019
9d7fe46
Add default ordering by submission time to answer display
kovacsgergo128 Sep 24, 2019
6ad0fe6
Insert escape_single_quote into add new entry function
kovacsgergo128 Sep 24, 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
74 changes: 74 additions & 0 deletions connection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import csv
import os
import psycopg2
import psycopg2.extras


def csv_to_dict(file_path):
with open(file_path, 'r', newline='') as f:
reader = csv.DictReader(f)
database = [dict(row) for row in reader]
return database


def dict_to_csv(file_path, data, is_answers=False):
with open(file_path, 'w', newline='') as f:
writer = csv.DictWriter(f, ANSWER_DATA_HEADER if is_answers else QUESTION_DATA_HEADER)
writer.writeheader()
writer.writerows(data)


def append_to_csv(file_path, data):
with open(file_path, 'a', newline='') as f:
writer = csv.writer(f)
writer.writerows([data.values()])


# 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.


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
3 changes: 3 additions & 0 deletions data/answer.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id,submission_time,vote_number,question_id,message,image
0,1493398154,4,0,"You need to use brackets: my_list = []",
1,1493088154,35,0,"Look it up in the Python docs",
14 changes: 14 additions & 0 deletions data/question.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
id,submission_time,view_number,vote_number,title,message,image
0,1493368154,29,7,"How to make lists in Python?","I am totally new to this, any hints?",
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)",
146 changes: 146 additions & 0 deletions data_handler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
import os
from datetime import datetime

from psycopg2 import sql

import connection
from util import string_builder

ANSWER_DATA_FILE_PATH = os.getcwd() + "/data/answer.csv"
QUESTION_DATA_FILE_PATH = os.getcwd() + "/data/question.csv"


def get_answers():
database = connection.csv_to_dict(ANSWER_DATA_FILE_PATH)
return database


def get_questions():
database = connection.csv_to_dict(QUESTION_DATA_FILE_PATH)
return database


def save_questions(data):
database = connection.dict_to_csv(QUESTION_DATA_FILE_PATH, data)
return database


def save_answers(data):
database = connection.dict_to_csv(ANSWER_DATA_FILE_PATH, data, True)
return database


def add_entry(entry, is_answer=False):
table = "answer"
if not is_answer:
table = "question"

entry = escape_single_quotes(entry)
query = """INSERT INTO {table}
({columns}) VALUES ({values});
""".format(columns=string_builder(entry.keys()),
values=string_builder(entry.values(), False),
table=table)
print(query)
execute_query(query)


def get_question(question_id):
question_query = f"""SELECT * FROM question
WHERE id={int(question_id)};"""
question_data = execute_query(question_query)
return question_data


def get_answer(answer_id, answer_database):
for answer_data in answer_database:
if answer_data['id'] == answer_id:
return answer_data


def get_question_related_answers(question_id):
answers_query = f"""SELECT * FROM answer
WHERE question_id={int(question_id)}
ORDER BY submission_time DESC;"""
answers_of_question = execute_query(answers_query)
return answers_of_question


def update_record(record, is_answer=False):
table = "answer"
record = escape_single_quotes(record)
id_ = record['id']
if not is_answer:
table = "question"
query = f"""UPDATE {table}
SET submission_time={"'" + record['submission_time'] + "'"},
title={"'" + record['title'] + "'"},
message={"'" + record['message'] + "'"},
image={"'" + record['image'] + "'"}
WHERE id={id_};
"""
else:
query = f"""UPDATE {table}
SET submission_time={"'" + record['submission_time'] + "'"},
message={"'" + record['title'] + "'"},
image={"'" + record['image'] + "'"}
WHERE id={id_};
"""

execute_query(query)


def delete_record(id, answer=False, delete=False):
if answer:
question_id_query = f"""SELECT question_id FROM answer
WHERE id={id};"""
delete_answer_query = f"""DELETE FROM answer
WHERE id={id};"""
delete_comment_query = f"""DELETE FROM comment
WHERE answer_id={id};"""
question_id = execute_query(question_id_query)[0]['question_id']

if delete:
execute_query(delete_comment_query)
execute_query(delete_answer_query)

return question_id


@connection.connection_handler
def execute_query(cursor, query):
# print(query.startswith("INSERT"))
if query.startswith("SELECT"):
cursor.execute(
sql.SQL(query)
)
result = cursor.fetchall()

else:
result = cursor.execute(query)
return result


def handle_add_comment(req):
req.update(submission_time=datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
query ="""INSERT INTO comment ({columns})
VALUES ({value_list})""".format(columns=string_builder(req.keys(), True),
value_list=string_builder(req.values(), False)
)
execute_query(query)


def escape_single_quotes(dictionary):
for key, value in dictionary.items():
if type(value) == str and "'" in value:
dictionary[key] = value.replace("'", "''")
return dictionary


def get_comments(comment_tpe, _id):
comment_tpe += "_id"
query = """SELECT message, submission_time, edited_count FROM comment
WHERE {col} = {id}
""".format(col=comment_tpe, id=_id)
print(query)
return execute_query(query)
127 changes: 127 additions & 0 deletions sample_data/askmatepart2-sample-data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
--
-- PostgreSQL database dump
--

-- Dumped from database version 9.5.6
-- Dumped by pg_dump version 9.5.6

ALTER TABLE IF EXISTS ONLY public.question DROP CONSTRAINT IF EXISTS pk_question_id CASCADE;
ALTER TABLE IF EXISTS ONLY public.answer DROP CONSTRAINT IF EXISTS pk_answer_id CASCADE;
ALTER TABLE IF EXISTS ONLY public.answer DROP CONSTRAINT IF EXISTS fk_question_id CASCADE;
ALTER TABLE IF EXISTS ONLY public.comment DROP CONSTRAINT IF EXISTS pk_comment_id CASCADE;
ALTER TABLE IF EXISTS ONLY public.comment DROP CONSTRAINT IF EXISTS fk_question_id CASCADE;
ALTER TABLE IF EXISTS ONLY public.comment DROP CONSTRAINT IF EXISTS fk_answer_id CASCADE;
ALTER TABLE IF EXISTS ONLY public.question_tag DROP CONSTRAINT IF EXISTS pk_question_tag_id CASCADE;
ALTER TABLE IF EXISTS ONLY public.question_tag DROP CONSTRAINT IF EXISTS fk_question_id CASCADE;
ALTER TABLE IF EXISTS ONLY public.tag DROP CONSTRAINT IF EXISTS pk_tag_id CASCADE;
ALTER TABLE IF EXISTS ONLY public.question_tag DROP CONSTRAINT IF EXISTS fk_tag_id CASCADE;

DROP TABLE IF EXISTS public.question;
DROP SEQUENCE IF EXISTS public.question_id_seq;
CREATE TABLE question (
id serial NOT NULL,
submission_time timestamp without time zone,
view_number integer,
vote_number integer,
title text,
message text,
image text
);

DROP TABLE IF EXISTS public.answer;
DROP SEQUENCE IF EXISTS public.answer_id_seq;
CREATE TABLE answer (
id serial NOT NULL,
submission_time timestamp without time zone,
vote_number integer,
question_id integer,
message text,
image text
);

DROP TABLE IF EXISTS public.comment;
DROP SEQUENCE IF EXISTS public.comment_id_seq;
CREATE TABLE comment (
id serial NOT NULL,
question_id integer,
answer_id integer,
message text,
submission_time timestamp without time zone,
edited_count integer
);


DROP TABLE IF EXISTS public.question_tag;
CREATE TABLE question_tag (
question_id integer NOT NULL,
tag_id integer NOT NULL
);

DROP TABLE IF EXISTS public.tag;
DROP SEQUENCE IF EXISTS public.tag_id_seq;
CREATE TABLE tag (
id serial NOT NULL,
name text
);


ALTER TABLE ONLY answer
ADD CONSTRAINT pk_answer_id PRIMARY KEY (id);

ALTER TABLE ONLY comment
ADD CONSTRAINT pk_comment_id PRIMARY KEY (id);

ALTER TABLE ONLY question
ADD CONSTRAINT pk_question_id PRIMARY KEY (id);

ALTER TABLE ONLY question_tag
ADD CONSTRAINT pk_question_tag_id PRIMARY KEY (question_id, tag_id);

ALTER TABLE ONLY tag
ADD CONSTRAINT pk_tag_id PRIMARY KEY (id);

ALTER TABLE ONLY comment
ADD CONSTRAINT fk_answer_id FOREIGN KEY (answer_id) REFERENCES answer(id);

ALTER TABLE ONLY answer
ADD CONSTRAINT fk_question_id FOREIGN KEY (question_id) REFERENCES question(id);

ALTER TABLE ONLY question_tag
ADD CONSTRAINT fk_question_id FOREIGN KEY (question_id) REFERENCES question(id);

ALTER TABLE ONLY comment
ADD CONSTRAINT fk_question_id FOREIGN KEY (question_id) REFERENCES question(id);

ALTER TABLE ONLY question_tag
ADD CONSTRAINT fk_tag_id FOREIGN KEY (tag_id) REFERENCES tag(id);

INSERT INTO question VALUES (0, '2017-04-28 08:29:00', 29, 7, 'How to make lists in Python?', 'I am totally new to this, any hints?', NULL);
INSERT INTO question VALUES (1, '2017-04-29 09:19:00', 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');
INSERT INTO question VALUES (2, '2017-05-01 10:41:00', 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.
', NULL);
SELECT pg_catalog.setval('question_id_seq', 2, true);

INSERT INTO answer VALUES (1, '2017-04-28 16:49:00', 4, 1, 'You need to use brackets: my_list = []', NULL);
INSERT INTO answer VALUES (2, '2017-04-25 14:42:00', 35, 1, 'Look it up in the Python docs', 'images/image2.jpg');
SELECT pg_catalog.setval('answer_id_seq', 2, true);

INSERT INTO comment VALUES (1, 0, NULL, 'Please clarify the question as it is too vague!', '2017-05-01 05:49:00');
INSERT INTO comment VALUES (2, NULL, 1, 'I think you could use my_list = list() as well.', '2017-05-02 16:55:00');
SELECT pg_catalog.setval('comment_id_seq', 2, true);

INSERT INTO tag VALUES (1, 'python');
INSERT INTO tag VALUES (2, 'sql');
INSERT INTO tag VALUES (3, 'css');
SELECT pg_catalog.setval('tag_id_seq', 3, true);

INSERT INTO question_tag VALUES (0, 1);
INSERT INTO question_tag VALUES (1, 3);
INSERT INTO question_tag VALUES (2, 3);
Loading