diff --git a/spec/spec.md b/spec/spec.md index ea41bab..179b03f 100644 --- a/spec/spec.md +++ b/spec/spec.md @@ -96,7 +96,8 @@ TODO: Figure out what to do for this. # HTML Templates -HTML Templates are the raw HTML that is used, and filled in, by variable data provided by the system. Templates should be wrote and saved on the file system of the hosting computer, and loaded upon start up. These loaded templates should be filled in with data provided by the system, then the assembled HTML should be given as a response to users. +HTML Templates are the raw HTML that is used, and filled in, by variable data provided by the system. Templates should be wrote and saved on the file system of the hosting computer, and loaded upon start up. These loaded templates should be filled in with data provided by the system, then the assembled HTML should be given as a response to users. +The Templates should utilize purely lower-case variable names. # Payment Verification diff --git a/src/database.cpp b/src/database.cpp index 5ca3d9e..62e21ce 100644 --- a/src/database.cpp +++ b/src/database.cpp @@ -2,7 +2,6 @@ #include #include #include -#include #include "crow.h" @@ -21,7 +20,7 @@ namespace Database { * Case for boolean return values because the default return value is f/t instead of 0/1 or false/true */ const static std::string PREPARED_STATEMENT_SELECT_ITEM_BY_ID = "selectItemByID"; - const static std::string SQL_STATEMENT_SELECT_ITEM_BY_ID = "SELECT id , customerEmailAddress, freelancer, templateName, currencyPreference, priceUpFront, priceOnDeliver, requestDescription, (CASE WHEN requests.accepted THEN 1 ELSE 0 END) AS accepted, upFrontInvoiceID, onDeliverInvoiceID, (CASE WHEN requests.upFrontPaid THEN 1 ELSE 0 END) AS upFrontPaid, (CASE WHEN requests.onDeliverPaid THEN 1 ELSE 0 END) AS onDeliverPaid FROM requests WHERE id=$1;"; + const static std::string SQL_STATEMENT_SELECT_ITEM_BY_ID = "SELECT id , customerEmailAddress, freelancer, templateName, currencyPreference, priceUpFront, priceOnDeliver, requestDescription, (CASE WHEN requests.accepted THEN 1 ELSE 0 END) AS accepted, upFrontInvoiceID, onDeliverInvoiceID, (CASE WHEN requests.upFrontPaid THEN 1 ELSE 0 END) AS upFrontPaid, (CASE WHEN requests.onDeliverPaid THEN 1 ELSE 0 END) AS onDeliverPaid FROM requests WHERE id=$1;"; /* * Struct Representing an item in Requests @@ -109,14 +108,7 @@ namespace Database { crow::json::wvalue convertResultRowToJSON(pqxx::result &result, int row = 0){ crow::json::wvalue returnJson; for (int i = 0; i < result.columns(); ++i) { - std::string realColName = result.column_name(i); - for (std::string columnNameReal: JSON_ITEM_NAMES) { - if (boost::algorithm::to_lower_copy(columnNameReal) == realColName) { - realColName = columnNameReal; - break; - } - } - returnJson[realColName] = result.at(row).at(i).c_str(); + returnJson[result.column_name(i)] = result.at(row).at(i).c_str(); } return returnJson; } diff --git a/templates/test.html b/templates/test.html index 693c151..118adb7 100644 --- a/templates/test.html +++ b/templates/test.html @@ -1,13 +1,13 @@

id: {{id}}

-

customerEmailAddress: {{customerEmailAddress}}

+

customerEmailAddress: {{customeremailaddress}}

freelancer: {{freelancer}}

-

templateName: {{templateName}}

-

currencyPreference: {{currencyPreference}}

-

priceUpFront: {{priceUpFront}}

-

priceOnDeliver: {{priceOnDeliver}}

-

requestDescription: {{requestDescription}}

-

upFrontInvoiceID: {{upFrontInvoiceID}}

-

onDeliverInvoiceID: {{onDeliverInvoiceID}}

-

upFrontPaid: {{upFrontPaid}}

-

onDeliverPaid: {{onDeliverPaid}}

+

templateName: {{templatename}}

+

currencyPreference: {{currencypreference}}

+

priceUpFront: {{priceupfront}}

+

priceOnDeliver: {{priceondeliver}}

+

requestDescription: {{requestdescription}}

+

upFrontInvoiceID: {{upfrontinvoiceid}}

+

onDeliverInvoiceID: {{ondeliverinvoiceid}}

+

upFrontPaid: {{upfrontpaid}}

+

onDeliverPaid: {{ondeliverpaid}}

accepted: {{accepted}}