mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Remove dynamic cast because it lead to errors again and agin (Poco::AutoPtr don't work correct with that)
This commit is contained in:
parent
a08113eea7
commit
cee7d7ac3c
@ -15,10 +15,10 @@ PendingTasksManager::~PendingTasksManager()
|
|||||||
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
|
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
|
||||||
mCheckForFinishedTimer.stop();
|
mCheckForFinishedTimer.stop();
|
||||||
|
|
||||||
for (auto it = mPendingTasks.begin(); it != mPendingTasks.end(); it++) {
|
for (auto it = mPendingGradidoTransactions.begin(); it != mPendingGradidoTransactions.end(); it++) {
|
||||||
delete it->second;
|
delete it->second;
|
||||||
}
|
}
|
||||||
mPendingTasks.clear();
|
mPendingGradidoTransactions.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
PendingTasksManager* PendingTasksManager::getInstance()
|
PendingTasksManager* PendingTasksManager::getInstance()
|
||||||
@ -37,31 +37,32 @@ int PendingTasksManager::load()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PendingTasksManager::addTask(Poco::AutoPtr<controller::PendingTask> task)
|
|
||||||
|
int PendingTasksManager::addTask(Poco::AutoPtr<model::gradido::Transaction> gradidoTransactionTask)
|
||||||
{
|
{
|
||||||
if (task.isNull() || !task->getModel()) {
|
if (gradidoTransactionTask.isNull() || !gradidoTransactionTask->getModel()) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto model = task->getModel();
|
|
||||||
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
|
|
||||||
auto pending_task_list = getTaskListForUser(model->getUserId());
|
|
||||||
pending_task_list->push_back(task);
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
|
auto model = gradidoTransactionTask->getModel();
|
||||||
|
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
|
||||||
|
auto pending_task_list = getGradidoTransactionsForUser(model->getUserId());
|
||||||
|
pending_task_list->push_back(gradidoTransactionTask);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PendingTasksManager::removeTask(Poco::AutoPtr<controller::PendingTask> task)
|
|
||||||
|
bool PendingTasksManager::removeTask(Poco::AutoPtr<model::gradido::Transaction> gradidoTransactionTask)
|
||||||
{
|
{
|
||||||
if (task.isNull() || !task->getModel()) {
|
if (gradidoTransactionTask.isNull() || !gradidoTransactionTask->getModel()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto model = task->getModel();
|
auto model = gradidoTransactionTask->getModel();
|
||||||
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
|
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
|
||||||
auto pending_task_list = getTaskListForUser(model->getUserId());
|
auto pending_task_list = getGradidoTransactionsForUser(model->getUserId());
|
||||||
bool removed = false;
|
bool removed = false;
|
||||||
for (auto it = pending_task_list->begin(); it != pending_task_list->end(); it++) {
|
for (auto it = pending_task_list->begin(); it != pending_task_list->end(); it++) {
|
||||||
if (task.get() == it->get()) {
|
if (gradidoTransactionTask.get() == it->get()) {
|
||||||
pending_task_list->erase(it);
|
pending_task_list->erase(it);
|
||||||
removed = true;
|
removed = true;
|
||||||
break;
|
break;
|
||||||
@ -71,41 +72,42 @@ bool PendingTasksManager::removeTask(Poco::AutoPtr<controller::PendingTask> task
|
|||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
PendingTasksManager::PendingTaskList* PendingTasksManager::getTaskListForUser(int userId)
|
|
||||||
|
PendingTasksManager::PendingGradidoTaskList* PendingTasksManager::getGradidoTransactionsForUser(int userId)
|
||||||
{
|
{
|
||||||
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
|
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
|
||||||
auto it = mPendingTasks.find(userId);
|
auto it = mPendingGradidoTransactions.find(userId);
|
||||||
if (it == mPendingTasks.end()) {
|
if (it == mPendingGradidoTransactions.end()) {
|
||||||
auto pending_list = new PendingTaskList;
|
auto pending_list = new PendingGradidoTaskList;
|
||||||
mPendingTasks.insert(std::pair<int, PendingTaskList*>(userId, pending_list));
|
mPendingGradidoTransactions.insert(std::pair<int, PendingGradidoTaskList*>(userId, pending_list));
|
||||||
return pending_list;
|
return pending_list;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
const PendingTasksManager::PendingTaskList* PendingTasksManager::getTaskListForUser(int userId) const
|
|
||||||
|
|
||||||
|
const PendingTasksManager::PendingGradidoTaskList* PendingTasksManager::getGradidoTransactionsForUser(int userId) const
|
||||||
{
|
{
|
||||||
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
|
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
|
||||||
auto it = mPendingTasks.find(userId);
|
auto it = mPendingGradidoTransactions.find(userId);
|
||||||
if (it != mPendingTasks.end()) {
|
if (it != mPendingGradidoTransactions.end()) {
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PendingTasksManager::hasPendingTask(Poco::AutoPtr<controller::User> user, model::table::TaskType type)
|
bool PendingTasksManager::hasPendingGradidoTransaction(Poco::AutoPtr<controller::User> user, model::table::TaskType type)
|
||||||
{
|
{
|
||||||
auto model = user->getModel();
|
auto model = user->getModel();
|
||||||
int user_id = model->getID();
|
int user_id = model->getID();
|
||||||
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
|
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
|
||||||
auto it = mPendingTasks.find(user_id);
|
auto it = mPendingGradidoTransactions.find(user_id);
|
||||||
if (it != mPendingTasks.end()) {
|
if (it != mPendingGradidoTransactions.end()) {
|
||||||
auto task_list = it->second;
|
auto task_list = it->second;
|
||||||
for (auto task = task_list->begin(); task != task_list->end(); it++) {
|
for (auto taskIt = task_list->begin(); taskIt != task_list->end(); taskIt++) {
|
||||||
auto task_model = (*task)->getModel();
|
if ((*taskIt)->getModel()->getTaskType() == type) {
|
||||||
if (type == task_model->getTaskType()) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -114,20 +116,21 @@ bool PendingTasksManager::hasPendingTask(Poco::AutoPtr<controller::User> user, m
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Poco::AutoPtr<controller::PendingTask>> PendingTasksManager::getPendingTasks(Poco::AutoPtr<controller::User> user, model::table::TaskType type)
|
|
||||||
|
std::vector<Poco::AutoPtr<model::gradido::Transaction>> PendingTasksManager::getPendingGradidoTransactions(Poco::AutoPtr<controller::User> user, model::table::TaskType type)
|
||||||
{
|
{
|
||||||
auto model = user->getModel();
|
auto model = user->getModel();
|
||||||
int user_id = model->getID();
|
int user_id = model->getID();
|
||||||
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
|
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
|
||||||
std::vector<Poco::AutoPtr<controller::PendingTask>> results;
|
std::vector<Poco::AutoPtr<model::gradido::Transaction>> results;
|
||||||
|
|
||||||
auto it = mPendingTasks.find(user_id);
|
auto it = mPendingGradidoTransactions.find(user_id);
|
||||||
if (it != mPendingTasks.end()) {
|
if (it != mPendingGradidoTransactions.end()) {
|
||||||
auto task_list = it->second;
|
auto task_list = it->second;
|
||||||
results.reserve(task_list->size());
|
results.reserve(task_list->size());
|
||||||
for (auto taskIt = task_list->begin(); taskIt != task_list->end(); taskIt++) {
|
for (auto taskIt = task_list->begin(); taskIt != task_list->end(); taskIt++) {
|
||||||
auto task_model = (*taskIt)->getModel();
|
auto task_model = (*taskIt)->getModel();
|
||||||
if (type == task_model->getTaskType()) {
|
if (task_model->getTaskType() == type) {
|
||||||
results.push_back(*taskIt);
|
results.push_back(*taskIt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -135,48 +138,42 @@ std::vector<Poco::AutoPtr<controller::PendingTask>> PendingTasksManager::getPend
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Poco::AutoPtr<controller::PendingTask>> PendingTasksManager::getTransactionsUserMustSign(Poco::AutoPtr<controller::User> user)
|
std::vector<Poco::AutoPtr<model::gradido::Transaction>> PendingTasksManager::getTransactionsUserMustSign(Poco::AutoPtr<controller::User> user)
|
||||||
{
|
{
|
||||||
// TODO: don't use cast here, because can lead to errors
|
// TODO: don't use cast here, because can lead to errors
|
||||||
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
|
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
|
||||||
std::vector<Poco::AutoPtr<controller::PendingTask>> transactions_to_sign;
|
std::vector<Poco::AutoPtr<model::gradido::Transaction>> transactions_to_sign;
|
||||||
|
|
||||||
for (auto map_it = mPendingTasks.begin(); map_it != mPendingTasks.end(); map_it++)
|
for (auto map_it = mPendingGradidoTransactions.begin(); map_it != mPendingGradidoTransactions.end(); map_it++)
|
||||||
{
|
{
|
||||||
auto list = map_it->second;
|
auto list = map_it->second;
|
||||||
for (auto list_it = list->begin(); list_it != list->end(); list_it++)
|
for (auto list_it = list->begin(); list_it != list->end(); list_it++)
|
||||||
{
|
{
|
||||||
if ((*list_it)->getModel()->isGradidoTransaction()) {
|
if((*list_it)->mustSign(user)) {
|
||||||
auto transaction = dynamic_cast<model::gradido::Transaction*>(list_it->get());
|
transactions_to_sign.push_back(*list_it);
|
||||||
if (transaction->mustSign(user)) {
|
|
||||||
transactions_to_sign.push_back(*list_it);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return transactions_to_sign;
|
return transactions_to_sign;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Poco::AutoPtr<controller::PendingTask>> PendingTasksManager::getTransactionSomeoneMustSign(Poco::AutoPtr<controller::User> user)
|
std::vector<Poco::AutoPtr<model::gradido::Transaction>> PendingTasksManager::getTransactionSomeoneMustSign(Poco::AutoPtr<controller::User> user)
|
||||||
{
|
{
|
||||||
// TODO: don't use cast here, because can lead to errors
|
// TODO: don't use cast here, because can lead to errors
|
||||||
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
|
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
|
||||||
std::vector<Poco::AutoPtr<controller::PendingTask>> transactions_to_sign;
|
std::vector<Poco::AutoPtr<model::gradido::Transaction>> transactions_to_sign;
|
||||||
|
|
||||||
if (user->getModel()->getRole() != model::table::ROLE_ADMIN) {
|
if (user->getModel()->getRole() != model::table::ROLE_ADMIN) {
|
||||||
return transactions_to_sign;
|
return transactions_to_sign;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto map_it = mPendingTasks.begin(); map_it != mPendingTasks.end(); map_it++)
|
for (auto map_it = mPendingGradidoTransactions.begin(); map_it != mPendingGradidoTransactions.end(); map_it++)
|
||||||
{
|
{
|
||||||
auto list = map_it->second;
|
auto list = map_it->second;
|
||||||
for (auto list_it = list->begin(); list_it != list->end(); list_it++)
|
for (auto list_it = list->begin(); list_it != list->end(); list_it++)
|
||||||
{
|
{
|
||||||
if ((*list_it)->getModel()->isGradidoTransaction()) {
|
if ((*list_it)->needSomeoneToSign(user)) {
|
||||||
auto transaction = dynamic_cast<model::gradido::Transaction*>(list_it->get());
|
transactions_to_sign.push_back(*list_it);
|
||||||
if (transaction->needSomeoneToSign(user)) {
|
|
||||||
transactions_to_sign.push_back(*list_it);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -189,27 +186,25 @@ void PendingTasksManager::checkForFinishedTasks(Poco::Timer& timer)
|
|||||||
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
|
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
|
||||||
try {
|
try {
|
||||||
|
|
||||||
for (auto map_it = mPendingTasks.begin(); map_it != mPendingTasks.end(); map_it++)
|
for (auto map_it = mPendingGradidoTransactions.begin(); map_it != mPendingGradidoTransactions.end(); map_it++)
|
||||||
{
|
{
|
||||||
auto list = map_it->second;
|
auto list = map_it->second;
|
||||||
for (auto list_it = list->begin(); list_it != list->end(); list_it++)
|
for (auto list_it = list->begin(); list_it != list->end(); list_it++)
|
||||||
{
|
{
|
||||||
if ((*list_it)->getModel()->isGradidoTransaction()) {
|
auto transaction = *list_it;
|
||||||
auto transaction = dynamic_cast<model::gradido::Transaction*>(list_it->get());
|
auto json = transaction->getModel()->getResultJson();
|
||||||
auto json = transaction->getModel()->getResultJson();
|
bool removeIt = false;
|
||||||
bool removeIt = false;
|
if (!json.isNull()) {
|
||||||
if (!json.isNull()) {
|
auto state = json->get("state");
|
||||||
auto state = json->get("state");
|
if (!state.isEmpty() && state.toString() == "success") {
|
||||||
if (!state.isEmpty() && state.toString() == "success") {
|
removeIt = true;
|
||||||
removeIt = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (removeIt) {
|
|
||||||
transaction->deleteFromDB();
|
|
||||||
list_it = list->erase(list_it);
|
|
||||||
if (!list->size() || list_it == list->end()) break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (removeIt) {
|
||||||
|
transaction->deleteFromDB();
|
||||||
|
list_it = list->erase(list_it);
|
||||||
|
if (!list->size() || list_it == list->end()) break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -224,10 +219,11 @@ void PendingTasksManager::checkForFinishedTasks(Poco::Timer& timer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Poco::AutoPtr<controller::PendingTask> PendingTasksManager::getPendingTask(int pendingTaskId)
|
|
||||||
|
Poco::AutoPtr<model::gradido::Transaction> PendingTasksManager::getPendingGradidoTransaction(int pendingTaskId)
|
||||||
{
|
{
|
||||||
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
|
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
|
||||||
for (auto map_it = mPendingTasks.begin(); map_it != mPendingTasks.end(); map_it++)
|
for (auto map_it = mPendingGradidoTransactions.begin(); map_it != mPendingGradidoTransactions.end(); map_it++)
|
||||||
{
|
{
|
||||||
auto list = map_it->second;
|
auto list = map_it->second;
|
||||||
for (auto list_it = list->begin(); list_it != list->end(); list_it++)
|
for (auto list_it = list->begin(); list_it != list->end(); list_it++)
|
||||||
|
|||||||
@ -13,9 +13,10 @@
|
|||||||
#ifndef GRADIDO_LOGIN_SERVER_SINGLETON_MANAGER_PENDING_TASKS_MANAGER
|
#ifndef GRADIDO_LOGIN_SERVER_SINGLETON_MANAGER_PENDING_TASKS_MANAGER
|
||||||
#define GRADIDO_LOGIN_SERVER_SINGLETON_MANAGER_PENDING_TASKS_MANAGER
|
#define GRADIDO_LOGIN_SERVER_SINGLETON_MANAGER_PENDING_TASKS_MANAGER
|
||||||
|
|
||||||
#include "../controller/PendingTask.h"
|
#include "controller/PendingTask.h"
|
||||||
#include "../controller/User.h"
|
#include "model/gradido/Transaction.h"
|
||||||
#include "../model/gradido/Transaction.h"
|
#include "controller/User.h"
|
||||||
|
#include "model/gradido/Transaction.h"
|
||||||
|
|
||||||
class UserUpdateGroupPage;
|
class UserUpdateGroupPage;
|
||||||
|
|
||||||
@ -24,6 +25,7 @@ class PendingTasksManager: protected UniLib::lib::MultithreadContainer
|
|||||||
friend UserUpdateGroupPage;
|
friend UserUpdateGroupPage;
|
||||||
public:
|
public:
|
||||||
typedef std::list<Poco::AutoPtr<controller::PendingTask>> PendingTaskList;
|
typedef std::list<Poco::AutoPtr<controller::PendingTask>> PendingTaskList;
|
||||||
|
typedef std::list<Poco::AutoPtr<model::gradido::Transaction>> PendingGradidoTaskList;
|
||||||
|
|
||||||
~PendingTasksManager();
|
~PendingTasksManager();
|
||||||
|
|
||||||
@ -34,8 +36,9 @@ public:
|
|||||||
|
|
||||||
//! \return -1 task is zero
|
//! \return -1 task is zero
|
||||||
//! \return 0 if added
|
//! \return 0 if added
|
||||||
int addTask(Poco::AutoPtr<controller::PendingTask> task);
|
int addTask(Poco::AutoPtr<model::gradido::Transaction> gradidoTransactionTask);
|
||||||
bool removeTask(Poco::AutoPtr<controller::PendingTask> task);
|
|
||||||
|
bool removeTask(Poco::AutoPtr<model::gradido::Transaction> gradidoTransactionTask);
|
||||||
|
|
||||||
//! check if tasks can be removed
|
//! check if tasks can be removed
|
||||||
void checkForFinishedTasks(Poco::Timer& timer);
|
void checkForFinishedTasks(Poco::Timer& timer);
|
||||||
@ -43,12 +46,12 @@ public:
|
|||||||
//! by calling this, important is to call lock to prevent vanishing the list while working with it,
|
//! by calling this, important is to call lock to prevent vanishing the list while working with it,
|
||||||
//! and unlock afterwards
|
//! and unlock afterwards
|
||||||
//! \return list or nullptr if no list for user exist
|
//! \return list or nullptr if no list for user exist
|
||||||
const PendingTaskList* getTaskListForUser(int userId) const;
|
const PendingGradidoTaskList* getGradidoTransactionsForUser(int userId) const;
|
||||||
bool hasPendingTask(Poco::AutoPtr<controller::User> user, model::table::TaskType type);
|
bool hasPendingGradidoTransaction(Poco::AutoPtr<controller::User> user, model::table::TaskType type);
|
||||||
std::vector<Poco::AutoPtr<controller::PendingTask>> getPendingTasks(Poco::AutoPtr<controller::User> user, model::table::TaskType type);
|
std::vector<Poco::AutoPtr<model::gradido::Transaction>> getPendingGradidoTransactions(Poco::AutoPtr<controller::User> user, model::table::TaskType type);
|
||||||
Poco::AutoPtr<controller::PendingTask> getPendingTask(int pendingTaskId);
|
Poco::AutoPtr<model::gradido::Transaction> getPendingGradidoTransaction(int pendingTaskId);
|
||||||
std::vector<Poco::AutoPtr<controller::PendingTask>> getTransactionsUserMustSign(Poco::AutoPtr<controller::User> user);
|
std::vector<Poco::AutoPtr<model::gradido::Transaction>> getTransactionsUserMustSign(Poco::AutoPtr<controller::User> user);
|
||||||
std::vector<Poco::AutoPtr<controller::PendingTask>> getTransactionSomeoneMustSign(Poco::AutoPtr<controller::User> user);
|
std::vector<Poco::AutoPtr<model::gradido::Transaction>> getTransactionSomeoneMustSign(Poco::AutoPtr<controller::User> user);
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -58,8 +61,10 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
std::map<int, PendingTaskList*> mPendingTasks;
|
std::map<int, PendingTaskList*> mPendingTasks;
|
||||||
|
std::map<int, PendingGradidoTaskList*> mPendingGradidoTransactions;
|
||||||
//! \return list for user, creating new list and map entry if not exist
|
//! \return list for user, creating new list and map entry if not exist
|
||||||
PendingTaskList* getTaskListForUser(int userId);
|
PendingTaskList* getTaskListForUser(int userId);
|
||||||
|
PendingGradidoTaskList* getGradidoTransactionsForUser(int userId);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -46,10 +46,7 @@ enum PageState {
|
|||||||
|
|
||||||
PageState state = PAGE_NO_TRANSACTIONS;
|
PageState state = PAGE_NO_TRANSACTIONS;
|
||||||
|
|
||||||
|
Poco::AutoPtr<model::gradido::Transaction> transaction;
|
||||||
|
|
||||||
Poco::AutoPtr<controller::PendingTask> pending_task;
|
|
||||||
model::gradido::Transaction* transaction = nullptr;
|
|
||||||
Poco::AutoPtr<model::gradido::TransactionBody> transaction_body;
|
Poco::AutoPtr<model::gradido::TransactionBody> transaction_body;
|
||||||
|
|
||||||
if(!form.empty())
|
if(!form.empty())
|
||||||
@ -64,10 +61,9 @@ enum PageState {
|
|||||||
if(DataTypeConverter::NUMBER_PARSE_OKAY == DataTypeConverter::strToInt(pending_task_id_string, pending_task_id))
|
if(DataTypeConverter::NUMBER_PARSE_OKAY == DataTypeConverter::strToInt(pending_task_id_string, pending_task_id))
|
||||||
{
|
{
|
||||||
// load transaction from pending task manager
|
// load transaction from pending task manager
|
||||||
pending_task = pt->getPendingTask(pending_task_id);
|
transaction = pt->getPendingGradidoTransaction(pending_task_id);
|
||||||
if(!pending_task.isNull() && pending_task->getModel()->isGradidoTransaction())
|
if(!transaction.isNull())
|
||||||
{
|
{
|
||||||
transaction = dynamic_cast<model::gradido::Transaction*>(pending_task.get());
|
|
||||||
if(transaction->hasSigned(account_user)) {
|
if(transaction->hasSigned(account_user)) {
|
||||||
transaction = nullptr;
|
transaction = nullptr;
|
||||||
} else {
|
} else {
|
||||||
@ -78,10 +74,11 @@ enum PageState {
|
|||||||
{
|
{
|
||||||
//mSession->finalizeTransaction(false, true);
|
//mSession->finalizeTransaction(false, true);
|
||||||
//
|
//
|
||||||
if(transaction && transaction->getModel()->getUserId() == user_model->getID())
|
if(!transaction.isNull() && transaction->getModel()->getUserId() == user_model->getID())
|
||||||
{
|
{
|
||||||
pt->removeTask(pending_task);
|
if(pt->removeTask(transaction)) {
|
||||||
transaction->deleteFromDB();
|
transaction->deleteFromDB();
|
||||||
|
}
|
||||||
transaction = nullptr;
|
transaction = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -110,7 +107,7 @@ enum PageState {
|
|||||||
}
|
}
|
||||||
if(!hasErrors) {
|
if(!hasErrors) {
|
||||||
//mSession->finalizeTransaction(true, false);
|
//mSession->finalizeTransaction(true, false);
|
||||||
if(transaction && transaction->sign(account_user)) {
|
if(!transaction.isNull() && transaction->sign(account_user)) {
|
||||||
transaction = nullptr;
|
transaction = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -129,15 +126,15 @@ enum PageState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto transactions_user_must_sign = pt->getTransactionsUserMustSign(account_user);
|
auto transactions_user_must_sign = pt->getTransactionsUserMustSign(account_user);
|
||||||
std::vector<Poco::AutoPtr<controller::PendingTask>> transactions_someone_must_sign;
|
std::vector<Poco::AutoPtr<model::gradido::Transaction>> transactions_someone_must_sign;
|
||||||
// TODO: work with community server roles
|
// TODO: work with community server roles
|
||||||
if(user_model->getRole() == model::table::ROLE_ADMIN) {
|
if(user_model->getRole() == model::table::ROLE_ADMIN) {
|
||||||
transactions_someone_must_sign = pt->getTransactionSomeoneMustSign(account_user);
|
transactions_someone_must_sign = pt->getTransactionSomeoneMustSign(account_user);
|
||||||
}
|
}
|
||||||
std::vector<Poco::AutoPtr<controller::PendingTask>> transactions_to_sign;
|
std::vector<Poco::AutoPtr<model::gradido::Transaction>> transactions_to_sign;
|
||||||
bool transaction_removeable = false;
|
bool transaction_removeable = false;
|
||||||
int transaction_to_sign_index = 0;
|
int transaction_to_sign_index = 0;
|
||||||
if(!transaction)
|
if(!transaction.isNull())
|
||||||
{
|
{
|
||||||
if(transactions_user_must_sign.size() > skip_count) {
|
if(transactions_user_must_sign.size() > skip_count) {
|
||||||
transactions_to_sign = transactions_user_must_sign;
|
transactions_to_sign = transactions_user_must_sign;
|
||||||
@ -149,7 +146,7 @@ enum PageState {
|
|||||||
|
|
||||||
if(transactions_to_sign.size() > transaction_to_sign_index)
|
if(transactions_to_sign.size() > transaction_to_sign_index)
|
||||||
{
|
{
|
||||||
transaction = dynamic_cast<model::gradido::Transaction*>(transactions_to_sign[transaction_to_sign_index].get());
|
transaction = transactions_to_sign[transaction_to_sign_index];
|
||||||
transaction_body = transaction->getTransactionBody();
|
transaction_body = transaction->getTransactionBody();
|
||||||
// user can only delete there own transactions
|
// user can only delete there own transactions
|
||||||
// TODO: Auto timeout for community transactions
|
// TODO: Auto timeout for community transactions
|
||||||
@ -181,7 +178,7 @@ enum PageState {
|
|||||||
{
|
{
|
||||||
enableLogout = false;
|
enableLogout = false;
|
||||||
}
|
}
|
||||||
if(PAGE_NO_TRANSACTIONS == state && transaction && !transaction_body.isNull())
|
if(PAGE_NO_TRANSACTIONS == state && !transaction.isNull() && !transaction_body.isNull())
|
||||||
{
|
{
|
||||||
auto transactionType = transaction_body->getType();
|
auto transactionType = transaction_body->getType();
|
||||||
memo = transaction_body->getMemo();
|
memo = transaction_body->getMemo();
|
||||||
@ -326,7 +323,7 @@ enum PageState {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<form>
|
<form>
|
||||||
<% if(transaction) { %>
|
<% if(!transaction.isNull()) { %>
|
||||||
<input type="hidden" name="pending-task-id" value="<%= transaction->getModel()->getID() %>">
|
<input type="hidden" name="pending-task-id" value="<%= transaction->getModel()->getID() %>">
|
||||||
<% } %>
|
<% } %>
|
||||||
<input type="hidden" name="skip-count" value="<%= skip_count %>">
|
<input type="hidden" name="skip-count" value="<%= skip_count %>">
|
||||||
|
|||||||
@ -73,15 +73,14 @@ enum PageState {
|
|||||||
|
|
||||||
|
|
||||||
pt->lock("userUpdateGroup Page");
|
pt->lock("userUpdateGroup Page");
|
||||||
auto has_pending_group_add_member_task = pt->hasPendingTask(user, model::table::TASK_TYPE_GROUP_ADD_MEMBER);
|
auto has_pending_group_add_member_task = pt->hasPendingGradidoTransaction(user, model::table::TASK_TYPE_GROUP_ADD_MEMBER);
|
||||||
auto referer_was_checkTransaction = refererString.find("checkTransactions") != std::string::npos;
|
auto referer_was_checkTransaction = refererString.find("checkTransactions") != std::string::npos;
|
||||||
if(has_pending_group_add_member_task) {
|
if(has_pending_group_add_member_task) {
|
||||||
state = PAGE_STATE_REQUEST_IS_RUNNING;
|
state = PAGE_STATE_REQUEST_IS_RUNNING;
|
||||||
std::vector<Poco::AutoPtr<controller::PendingTask>> tasks = pt->getPendingTasks(user, model::table::TASK_TYPE_GROUP_ADD_MEMBER);
|
auto tasks = pt->getPendingGradidoTransactions(user, model::table::TASK_TYPE_GROUP_ADD_MEMBER);
|
||||||
// should be only one
|
// should be only one
|
||||||
Poco::AutoPtr<model::gradido::Transaction> transaction = tasks[0].cast<model::gradido::Transaction>();
|
auto transaction = tasks[0];
|
||||||
if(transaction->getSignCount() == 0) {
|
if(transaction->getSignCount() == 0) {
|
||||||
|
|
||||||
pt->unlock();
|
pt->unlock();
|
||||||
response.redirect(getBaseUrl() + "/checkTransactions");
|
response.redirect(getBaseUrl() + "/checkTransactions");
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user