Added --no-template-caching
This commit is contained in:
parent
a30a30d72f
commit
aacdc29394
@ -118,6 +118,9 @@ Core:
|
||||
- Removed unnecessary OPTIONS request in config [#3541].
|
||||
- Added possibility to upload custom fonts for projector and pdf [#3568].
|
||||
- Use custom format cleanup plugin for CKEditor [#3576].
|
||||
- Added --debug-email flag to print all emails to stdout [#3530].
|
||||
- Added --no-template-caching flag to disable template caching for
|
||||
easier development [#3566].
|
||||
|
||||
Mediafiles:
|
||||
- Fixed reloading of PDF on page change [#3274].
|
||||
|
@ -9,6 +9,7 @@ import django
|
||||
from django.core.management import call_command, execute_from_command_line
|
||||
|
||||
import openslides
|
||||
from openslides.utils.arguments import arguments
|
||||
from openslides.utils.main import (
|
||||
ExceptionArgumentParser,
|
||||
UnknownCommand,
|
||||
@ -45,7 +46,7 @@ def main():
|
||||
parser.error('Unknown arguments {}'.format(' '.join(unknown_args)))
|
||||
|
||||
# Save arguments, if one wants to access them later.
|
||||
openslides.args = known_args
|
||||
arguments.set_arguments(known_args)
|
||||
|
||||
# Run a command that is defined here
|
||||
# These are commands that can not rely on an existing settings
|
||||
@ -115,6 +116,11 @@ def get_parser():
|
||||
'--debug-email',
|
||||
action='store_true',
|
||||
help='Change the email backend to console output.')
|
||||
subcommand_start.add_argument(
|
||||
'--no-template-caching',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='Disables caching of templates.')
|
||||
subcommand_start.add_argument(
|
||||
'--host',
|
||||
action='store',
|
||||
|
25
openslides/utils/arguments.py
Normal file
25
openslides/utils/arguments.py
Normal file
@ -0,0 +1,25 @@
|
||||
from argparse import Namespace
|
||||
from typing import Any, Union # noqa
|
||||
|
||||
|
||||
class OpenSlidesArguments():
|
||||
args = None # type: Union[None, Namespace]
|
||||
|
||||
def __getitem__(self, key: str) -> Any:
|
||||
if not self.args:
|
||||
raise KeyError("Arguments are not set.")
|
||||
if not hasattr(self.args, key):
|
||||
raise KeyError("Key '{}' is not in the OpenSlides arguments.".format(key))
|
||||
return getattr(self.args, key)
|
||||
|
||||
def get(self, key: str, default: Any) -> Any:
|
||||
if not self.args or not hasattr(self.args, key):
|
||||
return default
|
||||
else:
|
||||
return getattr(self.args, key)
|
||||
|
||||
def set_arguments(self, args: Namespace) -> None:
|
||||
self.args = args
|
||||
|
||||
|
||||
arguments = OpenSlidesArguments()
|
@ -9,6 +9,8 @@ from django.views.generic.base import View
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.views import APIView as _APIView
|
||||
|
||||
from .arguments import arguments
|
||||
|
||||
|
||||
class CSRFMixin:
|
||||
"""
|
||||
@ -67,7 +69,8 @@ class TemplateView(View):
|
||||
if self.template_name is None:
|
||||
raise ImproperlyConfigured("'template_name' is not provided.")
|
||||
|
||||
if self.template_name not in self.state:
|
||||
no_caching = arguments.get('no_template_caching', False)
|
||||
if self.template_name not in self.state or no_caching:
|
||||
self.state[self.template_name] = self.load_template()
|
||||
|
||||
def load_template(self) -> str:
|
||||
|
Loading…
Reference in New Issue
Block a user