Added ability to store creator, updater, date of create and date of edit on entities- columns for this added to Voucher and CampData.
Removed permission check from Service::loadById- caused access violation when user had not have read permission.
This commit is contained in:
@@ -5,6 +5,11 @@ System::System()
|
||||
|
||||
}
|
||||
|
||||
System::~System()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int System::id() const
|
||||
{
|
||||
return m_id;
|
||||
|
||||
@@ -11,6 +11,7 @@ class CORESHARED_EXPORT System
|
||||
{
|
||||
public:
|
||||
System();
|
||||
virtual ~System();
|
||||
|
||||
int id() const;
|
||||
void setId(int id);
|
||||
|
||||
+28
-2
@@ -82,6 +82,8 @@ public:
|
||||
|
||||
Transaction tx;
|
||||
|
||||
addDateAndUser(entity, true);
|
||||
|
||||
try
|
||||
{
|
||||
db->persist(entity);
|
||||
@@ -108,6 +110,8 @@ public:
|
||||
|
||||
Transaction tx;
|
||||
|
||||
addDateAndUser(entity, false);
|
||||
|
||||
try
|
||||
{
|
||||
db->update(entity);
|
||||
@@ -126,9 +130,9 @@ public:
|
||||
QSharedPointer<T> loadById(int id) {
|
||||
QSharedPointer<T> entity;
|
||||
|
||||
if (!checkPermission(PERM_READ)) {
|
||||
/*if (!checkPermission(PERM_READ)) {
|
||||
return entity;
|
||||
}
|
||||
}*/
|
||||
|
||||
odb::database *db = Context::instance().db();
|
||||
|
||||
@@ -233,6 +237,28 @@ protected:
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void addDateAndUser(QSharedPointer<T> entity, bool creating) {
|
||||
|
||||
T *inner = entity.data();
|
||||
QObject *obj = dynamic_cast<QObject*>(inner);
|
||||
|
||||
if (obj == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (creating)
|
||||
{
|
||||
obj->setProperty("createdBy", Context::instance().currentUser()->login());
|
||||
obj->setProperty("created", QDateTime::currentDateTime());
|
||||
}
|
||||
else
|
||||
{
|
||||
obj->setProperty("updatedBy", Context::instance().currentUser()->login());
|
||||
obj->setProperty("updated", QDateTime::currentDateTime());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif // SERVICE_H
|
||||
|
||||
Reference in New Issue
Block a user