mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 09:39:57 +00:00
Added the possibility to skip demo data generation in dev/demo/prerelease mode
This commit is contained in:
parent
d006436d49
commit
1c35fecc85
@ -142,7 +142,7 @@ If you don't use certain feature sets of Grocy (for example if you don't need "C
|
||||
|
||||
### Demo mode
|
||||
|
||||
When the `MODE` setting is set to `dev`, `demo` or `prerelease`, the application will work in a demo mode which means authentication is disabled and some demo data will be generated during the database schema migration.
|
||||
When the `MODE` setting is set to `dev`, `demo` or `prerelease`, the application will work in a demo mode which means authentication is disabled and some demo data will be generated during the database schema migration (pass the query parameter `nodemodata`, e.g. `https://grocy.example.com/?nodemodata` to skip that).
|
||||
|
||||
### Embedded mode
|
||||
|
||||
|
@ -14,8 +14,9 @@
|
||||
// The settings defined here below
|
||||
|
||||
// Either "production", "dev", "demo" or "prerelease"
|
||||
// When not "production", authentication will be disabled and
|
||||
// demo data will be populated during database migrations
|
||||
// When not "production", the application will work in a demo mode which means
|
||||
// authentication is disabled and some demo data will be generated during the database schema migration
|
||||
// (pass the query parameter "nodemodata", e.g. https://grocy.example.com/?nodemodata to skip that)
|
||||
Setting('MODE', 'production');
|
||||
|
||||
// The directory name of one of the available localization folders
|
||||
|
@ -32,7 +32,7 @@ class SystemController extends BaseController
|
||||
if (GROCY_MODE === 'dev' || GROCY_MODE === 'demo' || GROCY_MODE === 'prerelease')
|
||||
{
|
||||
$demoDataGeneratorService = DemoDataGeneratorService::getInstance();
|
||||
$demoDataGeneratorService->PopulateDemoData();
|
||||
$demoDataGeneratorService->PopulateDemoData(isset($request->getQueryParams()['nodemodata']));
|
||||
}
|
||||
|
||||
return $response->withRedirect($this->AppContainer->get('UrlManager')->ConstructUrl($this->GetEntryPageRelative()));
|
||||
|
@ -12,11 +12,17 @@ class DemoDataGeneratorService extends BaseService
|
||||
protected $LocalizationService;
|
||||
private $LastSupermarketId = 1;
|
||||
|
||||
public function PopulateDemoData()
|
||||
public function PopulateDemoData($skip = false)
|
||||
{
|
||||
$rowCount = $this->getDatabaseService()->ExecuteDbQuery('SELECT COUNT(*) FROM migrations WHERE migration = -1')->fetchColumn();
|
||||
if ($rowCount == 0)
|
||||
{
|
||||
if ($skip)
|
||||
{
|
||||
$this->getDatabaseService()->ExecuteDbStatement('INSERT INTO migrations (migration) VALUES (-1);');
|
||||
return;
|
||||
}
|
||||
|
||||
$loremIpsum = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.';
|
||||
$loremIpsumWithHtmlFormattings = "<h1>Lorem ipsum</h1><p>Lorem ipsum <b>dolor sit</b> amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur <span style=\"background-color: rgb(255, 255, 0);\">sadipscing elitr</span>, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</p><ul><li>At vero eos et accusam et justo duo dolores et ea rebum.</li><li>Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</li></ul><h1>Lorem ipsum</h1><p>Lorem ipsum <b>dolor sit</b> amet, consetetur \r\nsadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et \r\ndolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et\r\n justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea \r\ntakimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit \r\namet, consetetur <span style=\"background-color: rgb(255, 255, 0);\">sadipscing elitr</span>,\r\n sed diam nonumy eirmod tempor invidunt ut labore et dolore magna \r\naliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo \r\ndolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus \r\nest Lorem ipsum dolor sit amet.</p>";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user