Freelancer Template base Managment page
This commit is contained in:
42
src/main.cpp
42
src/main.cpp
@@ -625,7 +625,7 @@ int main(int argc, char *argv[]) {
|
||||
});
|
||||
|
||||
/*
|
||||
* Page for freelancer to sign up
|
||||
* Freelancer Profile page
|
||||
*/
|
||||
CROW_ROUTE(app, "/freelancer/profile")
|
||||
([&, configuration](const crow::request& getRequest ) {
|
||||
@@ -638,6 +638,46 @@ int main(int argc, char *argv[]) {
|
||||
return page.render(ctx);
|
||||
});
|
||||
|
||||
/*
|
||||
* Page for freelancer to create/delete/edit Templates
|
||||
*/
|
||||
CROW_ROUTE(app, "/freelancer/templateManagement")
|
||||
([&, configuration](const crow::request& getRequest ) {
|
||||
auto& cookieCtx = app.get_context<crow::CookieParser>(getRequest);
|
||||
crow::mustache::context ctx;
|
||||
string templateHTML = TEMPLATE_FREELANCER_TEMPLATE_MANAGEMENT;
|
||||
if (Utilities::checkCookieLoginState(configuration, cookieCtx)) {
|
||||
ctx = Utilities::getFreelancerTemplates(configuration, cookieCtx.get_cookie(COOKIE_FREELANCER_EMAIL));
|
||||
ctx[MUSTACHE_COOKIE_LOGGED_IN] = true;
|
||||
}
|
||||
auto page = crow::mustache::load(templateHTML);
|
||||
return page.render(ctx);
|
||||
});
|
||||
|
||||
/*
|
||||
* Page for freelancer to create/delete/edit Templates
|
||||
*/
|
||||
CROW_ROUTE(app, "/freelancer/templateManagement/template/<string>").methods("POST"_method)
|
||||
([&, configuration](const crow::request& getRequest, string templateName ) {
|
||||
auto& cookieCtx = app.get_context<crow::CookieParser>(getRequest);
|
||||
crow::mustache::context ctx;
|
||||
string templateHTML = TEMPLATE_FREELANCER_TEMPLATE_MANAGEMENT;
|
||||
if (Utilities::checkCookieLoginState(configuration, cookieCtx))
|
||||
ctx[MUSTACHE_COOKIE_LOGGED_IN] = true;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
auto page = crow::mustache::load(templateHTML);
|
||||
return page.render(ctx);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -24,6 +24,7 @@ namespace TemplateConstCollection {
|
||||
const static std::string TEMPLATE_PASSWORD_RESET_FULFILMENT = "passwordReset_Fulfilment.html";
|
||||
const static std::string TEMPLATE_FREELANCER_REDIRECT_PROFILE = "freelancer_Redirect_Profile.html";
|
||||
const static std::string TEMPLATE_FREELANCER_PROFILE = "freelancer_Profile.html";
|
||||
const static std::string TEMPLATE_FREELANCER_TEMPLATE_MANAGEMENT = "freelancer_Template_Management.html";
|
||||
|
||||
//Mustache Error/Success variable names
|
||||
const static std::string MUSTACHE_ERROR_COMMISSIONS_CLOSED = "ERROR_COMMISSIONS_CLOSED";
|
||||
|
@@ -504,5 +504,23 @@ namespace Utilities {
|
||||
Database::executePreparedStatement_UPDATE_EXPIRATION_LOGIN_LOCK_OUT(connection, emailAddress, configuration.bruteForceMitigationLockSeconds);
|
||||
}
|
||||
}
|
||||
|
||||
crow::json::wvalue getFreelancerTemplates(const Utilities::config& configuration, const std::string& emailAddress) {
|
||||
crow::json::wvalue resultJsonFreelancerTemplate;
|
||||
|
||||
pqxx::connection databaseConnection(configuration.databaseConnectionString);
|
||||
Database::prepareStatements(databaseConnection, {
|
||||
ID_SELECT_FREELANCER_ID,
|
||||
ID_SELECT_FREELANCER_TEMPLATES
|
||||
});
|
||||
pqxx::result idResult = Database::executePreparedStatement_SELECT_FREELANCER_ID(databaseConnection, emailAddress);
|
||||
if (!idResult.empty())
|
||||
{
|
||||
int freelancerID = std::stoi(idResult.at(0).at(0).c_str());
|
||||
pqxx::result resultFreelancerTemplates = Database::executePreparedStatement_SELECT_FREELANCER_TEMPLATES(databaseConnection, freelancerID);
|
||||
resultJsonFreelancerTemplate = Database::convertResultToJSON(resultFreelancerTemplates, "templates");
|
||||
}
|
||||
return resultJsonFreelancerTemplate;
|
||||
}
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user