Data classes and services for number series and seasons. Fixed release
build.
This commit is contained in:
+44
-1
@@ -15,6 +15,8 @@
|
||||
#include "users/users.h"
|
||||
#include "roles/roles.h"
|
||||
#include "permissionservice.h"
|
||||
#include "seasonservice.h"
|
||||
#include "numberseriesservice.h"
|
||||
|
||||
Context::~Context()
|
||||
{
|
||||
@@ -50,7 +52,7 @@ void Context::loadPlugins()
|
||||
m_plugins.append(new Users);
|
||||
m_plugins.append(new Roles);
|
||||
|
||||
QDir pluginsDir(qApp->applicationDirPath() + "/../plugins");
|
||||
QDir pluginsDir(qApp->applicationDirPath() + "/../../plugins");
|
||||
|
||||
foreach (QString fileName, pluginsDir.entryList(QStringList() << "*.so" << "*.dll")) {
|
||||
QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName));
|
||||
@@ -86,6 +88,8 @@ void Context::openDb(const QString &path)
|
||||
m_dbOpened = true;
|
||||
|
||||
checkPermissions();
|
||||
checkSeason();
|
||||
checkNumberSeries();
|
||||
}
|
||||
|
||||
void Context::destroy()
|
||||
@@ -253,3 +257,42 @@ void Context::checkPermissions()
|
||||
|
||||
permService.checkForAdmin();
|
||||
}
|
||||
|
||||
void Context::checkSeason()
|
||||
{
|
||||
SeasonService srv;
|
||||
QSharedPointer<Season> season = srv.active();
|
||||
|
||||
if (season.isNull())
|
||||
{
|
||||
season = QSharedPointer<Season>(new Season());
|
||||
season->setName("<<new season>>");
|
||||
season->setValidFrom(QDate::currentDate());
|
||||
season->setActive(true);
|
||||
srv.save(season);
|
||||
}
|
||||
}
|
||||
|
||||
void Context::checkNumberSeries()
|
||||
{
|
||||
NumberSeriesService srv;
|
||||
SeasonService sesSrv;
|
||||
QSharedPointer<Season> curSeason = sesSrv.active();
|
||||
|
||||
foreach (IPlugin *plugin, m_plugins) {
|
||||
if (plugin->hasNumberSeries())
|
||||
{
|
||||
QSharedPointer<NumberSeries> numSer = srv.forPlugin(plugin->pluginId());
|
||||
|
||||
if (numSer.isNull())
|
||||
{
|
||||
numSer = QSharedPointer<NumberSeries>(new NumberSeries());
|
||||
numSer->setPrefix(plugin->numberSeriesPrefix());
|
||||
numSer->setPluginId(plugin->pluginId());
|
||||
numSer->setSeason(curSeason);
|
||||
|
||||
srv.save(numSer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user