diff --git a/anonkun.py b/anonkun.py index e60eeb5..411acd7 100644 --- a/anonkun.py +++ b/anonkun.py @@ -57,6 +57,7 @@ app.wsgi_app = ProxyFix(app.wsgi_app) app.register_blueprint(views) app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 app.config['SESSION_TYPE'] = 'filesystem' +app.url_map.strict_slashes = False app.jinja_env.trim_blocks = True app.jinja_env.lstrip_blocks = True #app.jinja_env.undefined = "StrictUndefined" diff --git a/anonkun.sql b/anonkun.sql index d39e8cf..d109125 100644 --- a/anonkun.sql +++ b/anonkun.sql @@ -17,8 +17,7 @@ CREATE TABLE `chat_messages` ( CREATE TABLE `quest_meta` ( `quest_id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT, - `canon_title` VARCHAR(300) DEFAULT NULL, - `ident_title` VARCHAR(300) DEFAULT NULL, + `quest_title` VARCHAR(300) DEFAULT NULL, `owner_id` SMALLINT UNSIGNED DEFAULT NULL, `open_post_id` SMALLINT UNSIGNED DEFAULT NULL, PRIMARY KEY (`quest_id`), diff --git a/database.py b/database.py index 7d142c0..9952d1c 100644 --- a/database.py +++ b/database.py @@ -117,16 +117,16 @@ def get_chat_messages(room_id): return res -def insert_quest(canon_title, ident_title, owner_id): +def insert_quest(canon_title, owner_id): """Creates a new quest entry.""" _DB.execute( - "INSERT INTO `quest_meta` (`canon_title`, `ident_title`, `owner_id`) "\ - + "VALUES (%s, %s, %s)", (canon_title, ident_title, owner_id)) + "INSERT INTO `quest_meta` (`quest_title`, `owner_id`) "\ + + "VALUES (%s, %s)", (canon_title, owner_id)) quest_id = _DB.execute( - "SELECT `quest_id` FROM `quest_meta` WHERE `ident_title` = %s" \ + "SELECT `quest_id` FROM `quest_meta` WHERE `owner_id` = %s" \ + "ORDER BY `quest_id` DESC", - (ident_title,)).fetchone()[0] + (owner_id,)).fetchone()[0] return quest_id @@ -142,20 +142,14 @@ def insert_quest_post(quest_id, post_type, post, timestamp): return post_id -def get_quest_meta(quest_id=None, ident_title=None): +def get_quest_meta(quest_id): """ Retrieves all meta info about a quest. Allows searching by either quest_id or ident_title. """ - statement = "SELECT * FROM `quest_meta` WHERE " - if quest_id: - statement += "`quest_id` = %s" - data = _DB.execute(statement, (quest_id,)).fetchone() - elif ident_title: - statement += "`ident_title` = %s" - data = _DB.execute(statement, (ident_title,)).fetchone() - else: - return + data = _DB.execute( + "SELECT * FROM `quest_meta` WHERE `quest_id` = %s", + (quest_id,)).fetchone() return data diff --git a/templates/edit_quest.html b/templates/edit_quest.html index 83bb9ee..0a4774b 100644 --- a/templates/edit_quest.html +++ b/templates/edit_quest.html @@ -2,7 +2,7 @@ {% block title %}Edit {{ quest_title }}{% endblock %} {% block content %}