prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  System check to verify Parler sanity
  Shuup should check that the Parler configuration is sane before starting.
  
  @JsseL and @juhakujala puzzled over an unrelated exception (`'shuup.admin.modules.services.behavior_form_part.BehaviorFormSet object' has no attribute 'empty_form'`) for a while – turns out it was an `AttributeError` ([which, as we unfortunately know, are hidden within `@property`s](https://github.com/shuup/shuup/blob/5584ebf912bae415fe367ea0c00ad4c5cff49244/shuup/utils/form_group.py#L86-L100)) within `FormSet.empty_form` calls that happens due to `PARLER_DEFAULT_LANGUAGE_CODE` being undefined:
  
  ```
  Traceback (most recent call last):
    File "~/django/forms/formsets.py", line 187, in empty_form
      empty_permitted=True,
    File "~/shuup/admin/modules/services/behavior_form_part.py", line 49, in form
      kwargs.setdefault("default_language", settings.PARLER_DEFAULT_LANGUAGE_CODE)
    File "~/django/conf/__init__.py", line 49, in __getattr__
      return getattr(self._wrapped, name)
  AttributeError: 'Settings' object has no attribute 'PARLER_DEFAULT_LANGUAGE_CODE'
  ```
  
  My suggestion is to add a simple system check in [ShuupCoreAppConfig.ready()](https://github.com/shuup/shuup/blob/5584ebf912bae415fe367ea0c00ad4c5cff49244/shuup/core/__init__.py#L11) that throws an exception if some of the Parler settings (`PARLER_DEFAULT_LANGUAGE_CODE` and `PARLER_LANGUAGES`) are unset -- or perhaps it could automatically derive them based on the Django `LANGUAGES` setting, as "sane defaults" go?
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `shuup/core/__init__.py`
  Content:
  ```
  1 # -*- coding: utf-8 -*-
  2 # This file is part of Shuup.
  3 #
  4 # Copyright (c) 2012-2016, Shoop Ltd. All rights reserved.
  5 #
  6 # This source code is licensed under the AGPLv3 license found in the
  7 # LICENSE file in the root directory of this source tree.
  8 from shuup.apps import AppConfig
  9 
  10 
  11 class ShuupCoreAppConfig(AppConfig):
  12     name = "shuup.core"
  13     verbose_name = "Shuup Core"
  14     label = "shuup"  # Use "shuup" as app_label instead of "core"
  15     required_installed_apps = (
  16         "django.contrib.auth",
  17         "django.contrib.contenttypes",
  18         "easy_thumbnails",
  19         "filer",
  20     )
  21     provides = {
  22         "api_populator": [
  23             "shuup.core.api:populate_core_api"
  24         ],
  25         "pricing_module": [
  26             "shuup.core.pricing.default_pricing:DefaultPricingModule"
  27         ],
  28     }
  29 
  30 
  31 default_app_config = "shuup.core.ShuupCoreAppConfig"
  32
  ```
  
  Path: `shuup/core/excs.py`
  Content:
  ```
  1 # -*- coding: utf-8 -*-
  2 # This file is part of Shuup.
  3 #
  4 # Copyright (c) 2012-2016, Shoop Ltd. All rights reserved.
  5 #
  6 # This source code is licensed under the AGPLv3 license found in the
  7 # LICENSE file in the root directory of this source tree.
  8 from shuup.utils.excs import Problem
  9 
  10 
  11 class ImmutabilityError(ValueError):
  12     pass
  13 
  14 
  15 class NoProductsToShipException(Exception):
  16     pass
  17 
  18 
  19 class NoPaymentToCreateException(Exception):
  20     pass
  21 
  22 
  23 class NoRefundToCreateException(Exception):
  24     pass
  25 
  26 
  27 class RefundExceedsAmountException(Exception):
  28     pass
  29 
  30 
  31 class InvalidRefundAmountException(Exception):
  32     pass
  33 
  34 
  35 class ProductNotOrderableProblem(Problem):
  36     pass
  37 
  38 
  39 class ProductNotVisibleProblem(Problem):
  40     pass
  41 
  42 
  43 class ImpossibleProductModeException(ValueError):
  44     def __init__(self, message, code=None):
  45         super(ImpossibleProductModeException, self).__init__(message)
  46         self.code = code
  47
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/shuup/core/__init__.py b/shuup/core/__init__.py
  --- a/shuup/core/__init__.py
  +++ b/shuup/core/__init__.py
  @@ -6,6 +6,7 @@
   # This source code is licensed under the AGPLv3 license found in the
   # LICENSE file in the root directory of this source tree.
   from shuup.apps import AppConfig
  +from shuup.core.excs import MissingSettingException
   
   
   class ShuupCoreAppConfig(AppConfig):
  @@ -27,5 +28,12 @@
           ],
       }
   
  +    def ready(self):
  +        from django.conf import settings
  +        if not getattr(settings, "PARLER_DEFAULT_LANGUAGE_CODE", None):
  +            raise MissingSettingException("PARLER_DEFAULT_LANGUAGE_CODE must be set.")
  +        if not getattr(settings, "PARLER_LANGUAGES", None):
  +            raise MissingSettingException("PARLER_LANGUAGES must be set.")
  +
   
   default_app_config = "shuup.core.ShuupCoreAppConfig"
  diff --git a/shuup/core/excs.py b/shuup/core/excs.py
  --- a/shuup/core/excs.py
  +++ b/shuup/core/excs.py
  @@ -32,6 +32,10 @@
       pass
   
   
  +class MissingSettingException(Exception):
  +    pass
  +
  +
   class ProductNotOrderableProblem(Problem):
       pass
  
verification_info: {"golden_diff": "diff --git a/shuup/core/__init__.py b/shuup/core/__init__.py\n--- a/shuup/core/__init__.py\n+++ b/shuup/core/__init__.py\n@@ -6,6 +6,7 @@\n # This source code is licensed under the AGPLv3 license found in the\n # LICENSE file in the root directory of this source tree.\n from shuup.apps import AppConfig\n+from shuup.core.excs import MissingSettingException\n \n \n class ShuupCoreAppConfig(AppConfig):\n@@ -27,5 +28,12 @@\n         ],\n     }\n \n+    def ready(self):\n+        from django.conf import settings\n+        if not getattr(settings, \"PARLER_DEFAULT_LANGUAGE_CODE\", None):\n+            raise MissingSettingException(\"PARLER_DEFAULT_LANGUAGE_CODE must be set.\")\n+        if not getattr(settings, \"PARLER_LANGUAGES\", None):\n+            raise MissingSettingException(\"PARLER_LANGUAGES must be set.\")\n+\n \n default_app_config = \"shuup.core.ShuupCoreAppConfig\"\ndiff --git a/shuup/core/excs.py b/shuup/core/excs.py\n--- a/shuup/core/excs.py\n+++ b/shuup/core/excs.py\n@@ -32,6 +32,10 @@\n     pass\n \n \n+class MissingSettingException(Exception):\n+    pass\n+\n+\n class ProductNotOrderableProblem(Problem):\n     pass\n", "issue": "System check to verify Parler sanity\nShuup should check that the Parler configuration is sane before starting.\n\n@JsseL and @juhakujala puzzled over an unrelated exception (`'shuup.admin.modules.services.behavior_form_part.BehaviorFormSet object' has no attribute 'empty_form'`) for a while \u2013 turns out it was an `AttributeError` ([which, as we unfortunately know, are hidden within `@property`s](https://github.com/shuup/shuup/blob/5584ebf912bae415fe367ea0c00ad4c5cff49244/shuup/utils/form_group.py#L86-L100)) within `FormSet.empty_form` calls that happens due to `PARLER_DEFAULT_LANGUAGE_CODE` being undefined:\n\n```\nTraceback (most recent call last):\n  File \"~/django/forms/formsets.py\", line 187, in empty_form\n    empty_permitted=True,\n  File \"~/shuup/admin/modules/services/behavior_form_part.py\", line 49, in form\n    kwargs.setdefault(\"default_language\", settings.PARLER_DEFAULT_LANGUAGE_CODE)\n  File \"~/django/conf/__init__.py\", line 49, in __getattr__\n    return getattr(self._wrapped, name)\nAttributeError: 'Settings' object has no attribute 'PARLER_DEFAULT_LANGUAGE_CODE'\n```\n\nMy suggestion is to add a simple system check in [ShuupCoreAppConfig.ready()](https://github.com/shuup/shuup/blob/5584ebf912bae415fe367ea0c00ad4c5cff49244/shuup/core/__init__.py#L11) that throws an exception if some of the Parler settings (`PARLER_DEFAULT_LANGUAGE_CODE` and `PARLER_LANGUAGES`) are unset -- or perhaps it could automatically derive them based on the Django `LANGUAGES` setting, as \"sane defaults\" go?\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n# This file is part of Shuup.\n#\n# Copyright (c) 2012-2016, Shoop Ltd. All rights reserved.\n#\n# This source code is licensed under the AGPLv3 license found in the\n# LICENSE file in the root directory of this source tree.\nfrom shuup.apps import AppConfig\n\n\nclass ShuupCoreAppConfig(AppConfig):\n    name = \"shuup.core\"\n    verbose_name = \"Shuup Core\"\n    label = \"shuup\"  # Use \"shuup\" as app_label instead of \"core\"\n    required_installed_apps = (\n        \"django.contrib.auth\",\n        \"django.contrib.contenttypes\",\n        \"easy_thumbnails\",\n        \"filer\",\n    )\n    provides = {\n        \"api_populator\": [\n            \"shuup.core.api:populate_core_api\"\n        ],\n        \"pricing_module\": [\n            \"shuup.core.pricing.default_pricing:DefaultPricingModule\"\n        ],\n    }\n\n\ndefault_app_config = \"shuup.core.ShuupCoreAppConfig\"\n", "path": "shuup/core/__init__.py"}, {"content": "# -*- coding: utf-8 -*-\n# This file is part of Shuup.\n#\n# Copyright (c) 2012-2016, Shoop Ltd. All rights reserved.\n#\n# This source code is licensed under the AGPLv3 license found in the\n# LICENSE file in the root directory of this source tree.\nfrom shuup.utils.excs import Problem\n\n\nclass ImmutabilityError(ValueError):\n    pass\n\n\nclass NoProductsToShipException(Exception):\n    pass\n\n\nclass NoPaymentToCreateException(Exception):\n    pass\n\n\nclass NoRefundToCreateException(Exception):\n    pass\n\n\nclass RefundExceedsAmountException(Exception):\n    pass\n\n\nclass InvalidRefundAmountException(Exception):\n    pass\n\n\nclass ProductNotOrderableProblem(Problem):\n    pass\n\n\nclass ProductNotVisibleProblem(Problem):\n    pass\n\n\nclass ImpossibleProductModeException(ValueError):\n    def __init__(self, message, code=None):\n        super(ImpossibleProductModeException, self).__init__(message)\n        self.code = code\n", "path": "shuup/core/excs.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n# This file is part of Shuup.\n#\n# Copyright (c) 2012-2016, Shoop Ltd. All rights reserved.\n#\n# This source code is licensed under the AGPLv3 license found in the\n# LICENSE file in the root directory of this source tree.\nfrom shuup.apps import AppConfig\nfrom shuup.core.excs import MissingSettingException\n\n\nclass ShuupCoreAppConfig(AppConfig):\n    name = \"shuup.core\"\n    verbose_name = \"Shuup Core\"\n    label = \"shuup\"  # Use \"shuup\" as app_label instead of \"core\"\n    required_installed_apps = (\n        \"django.contrib.auth\",\n        \"django.contrib.contenttypes\",\n        \"easy_thumbnails\",\n        \"filer\",\n    )\n    provides = {\n        \"api_populator\": [\n            \"shuup.core.api:populate_core_api\"\n        ],\n        \"pricing_module\": [\n            \"shuup.core.pricing.default_pricing:DefaultPricingModule\"\n        ],\n    }\n\n    def ready(self):\n        from django.conf import settings\n        if not getattr(settings, \"PARLER_DEFAULT_LANGUAGE_CODE\", None):\n            raise MissingSettingException(\"PARLER_DEFAULT_LANGUAGE_CODE must be set.\")\n        if not getattr(settings, \"PARLER_LANGUAGES\", None):\n            raise MissingSettingException(\"PARLER_LANGUAGES must be set.\")\n\n\ndefault_app_config = \"shuup.core.ShuupCoreAppConfig\"\n", "path": "shuup/core/__init__.py"}, {"content": "# -*- coding: utf-8 -*-\n# This file is part of Shuup.\n#\n# Copyright (c) 2012-2016, Shoop Ltd. All rights reserved.\n#\n# This source code is licensed under the AGPLv3 license found in the\n# LICENSE file in the root directory of this source tree.\nfrom shuup.utils.excs import Problem\n\n\nclass ImmutabilityError(ValueError):\n    pass\n\n\nclass NoProductsToShipException(Exception):\n    pass\n\n\nclass NoPaymentToCreateException(Exception):\n    pass\n\n\nclass NoRefundToCreateException(Exception):\n    pass\n\n\nclass RefundExceedsAmountException(Exception):\n    pass\n\n\nclass InvalidRefundAmountException(Exception):\n    pass\n\n\nclass MissingSettingException(Exception):\n    pass\n\n\nclass ProductNotOrderableProblem(Problem):\n    pass\n\n\nclass ProductNotVisibleProblem(Problem):\n    pass\n\n\nclass ImpossibleProductModeException(ValueError):\n    def __init__(self, message, code=None):\n        super(ImpossibleProductModeException, self).__init__(message)\n        self.code = code\n", "path": "shuup/core/excs.py"}]}