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:
@@ -301,6 +301,46 @@ void Voucher::setSeason(const SeasonPtr &season)
|
||||
m_season = season;
|
||||
}
|
||||
|
||||
QString Voucher::createdBy() const
|
||||
{
|
||||
return m_createdBy;
|
||||
}
|
||||
|
||||
void Voucher::setCreatedBy(const QString &createdBy)
|
||||
{
|
||||
m_createdBy = createdBy;
|
||||
}
|
||||
|
||||
QString Voucher::updatedBy() const
|
||||
{
|
||||
return m_updatedBy;
|
||||
}
|
||||
|
||||
void Voucher::setUpdatedBy(const QString &updatedBy)
|
||||
{
|
||||
m_updatedBy = updatedBy;
|
||||
}
|
||||
|
||||
QDateTime Voucher::created() const
|
||||
{
|
||||
return m_created;
|
||||
}
|
||||
|
||||
void Voucher::setCreated(const QDateTime &created)
|
||||
{
|
||||
m_created = created;
|
||||
}
|
||||
|
||||
QDateTime Voucher::updated() const
|
||||
{
|
||||
return m_updated;
|
||||
}
|
||||
|
||||
void Voucher::setUpdated(const QDateTime &updated)
|
||||
{
|
||||
m_updated = updated;
|
||||
}
|
||||
|
||||
int Voucher::id() const
|
||||
{
|
||||
return m_id;
|
||||
|
||||
@@ -46,6 +46,10 @@ class SHOPSHARED_EXPORT Voucher : public QObject
|
||||
Q_ENUMS(VoucherStatus)
|
||||
Q_ENUMS(EetStatus)
|
||||
Q_PROPERTY(VoucherStatus status READ status WRITE setStatus)
|
||||
Q_PROPERTY(QString createdBy READ createdBy WRITE setCreatedBy)
|
||||
Q_PROPERTY(QString updatedBy READ updatedBy WRITE setUpdatedBy)
|
||||
Q_PROPERTY(QDateTime created READ created WRITE setCreated)
|
||||
Q_PROPERTY(QDateTime updated READ updated WRITE setUpdated)
|
||||
|
||||
public:
|
||||
explicit Voucher(QObject *parent = 0);
|
||||
@@ -155,6 +159,18 @@ public:
|
||||
SeasonPtr season() const;
|
||||
void setSeason(const SeasonPtr &season);
|
||||
|
||||
QString createdBy() const;
|
||||
void setCreatedBy(const QString &createdBy);
|
||||
|
||||
QString updatedBy() const;
|
||||
void setUpdatedBy(const QString &updatedBy);
|
||||
|
||||
QDateTime created() const;
|
||||
void setCreated(const QDateTime &created);
|
||||
|
||||
QDateTime updated() const;
|
||||
void setUpdated(const QDateTime &updated);
|
||||
|
||||
private:
|
||||
friend class odb::access;
|
||||
#pragma db id auto
|
||||
@@ -186,6 +202,10 @@ private:
|
||||
QOdbList<QSharedPointer<VoucherItem> > m_items;
|
||||
VoucherStatus m_status;
|
||||
SeasonPtr m_season;
|
||||
QString m_createdBy;
|
||||
QString m_updatedBy;
|
||||
QDateTime m_created;
|
||||
QDateTime m_updated;
|
||||
};
|
||||
|
||||
typedef QSharedPointer<Voucher> VoucherPtr;
|
||||
|
||||
+7
-1
@@ -8,7 +8,7 @@
|
||||
"default" : "",
|
||||
"CZ" : ""
|
||||
},
|
||||
"schemaVersion" : 6,
|
||||
"schemaVersion" : 7,
|
||||
"sql" : [
|
||||
"CREATE TABLE \"VoucherItem\" (
|
||||
\"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
@@ -76,6 +76,12 @@ CREATE TABLE \"Voucher\" (
|
||||
|
||||
"ALTER TABLE \"Voucher\" ADD \"season\" INTEGER NULL;
|
||||
UPDATE \"Voucher\" SET season = (SELECT id FROM \"Season\" WHERE active = 1);
|
||||
",
|
||||
|
||||
"ALTER TABLE Voucher ADD \"createdBy\" TEXT NULL;
|
||||
ALTER TABLE Voucher ADD \"created\" TEXT NULL;
|
||||
ALTER TABLE Voucher ADD \"updatedBy\" TEXT NULL;
|
||||
ALTER TABLE Voucher ADD \"updated\" TEXT NULL;
|
||||
"
|
||||
],
|
||||
"dependencies" : [ "ADDRESSBOOK" ],
|
||||
|
||||
@@ -349,6 +349,8 @@ void ShopService::saveVoucher(VoucherPtr entity)
|
||||
Transaction tr;
|
||||
odb::database *db = Context::instance().db();
|
||||
|
||||
addDateAndUser(entity, true);
|
||||
|
||||
db->persist(entity);
|
||||
|
||||
foreach (QSharedPointer<VoucherItem> item, entity->items()) {
|
||||
@@ -371,6 +373,8 @@ void ShopService::updateVoucher(VoucherPtr entity)
|
||||
db->persist(item);
|
||||
}
|
||||
|
||||
addDateAndUser(entity, false);
|
||||
|
||||
db->update(entity);
|
||||
|
||||
tr.commit();
|
||||
|
||||
Reference in New Issue
Block a user