3
3
import json
4
4
import logging
5
5
import os
6
- from datetime import timedelta as td
6
+ import datetime
7
7
from viur .core import conf , db , utils , current , errors
8
8
from viur .core .decorators import exposed
9
9
from viur .core .bones import *
@@ -150,7 +150,6 @@ def read(cls, skel, *args, **kwargs):
150
150
151
151
@classmethod
152
152
def write (cls , skel , ** kwargs ):
153
-
154
153
# Create the key from the name on initial write!
155
154
if not skel ["key" ]:
156
155
skel ["key" ] = db .Key (KINDNAME , skel ["name" ].lower ())
@@ -208,6 +207,10 @@ def adminInfo(self):
208
207
}
209
208
210
209
def addSkel (self ):
210
+ """
211
+ Returns a custom TranslationSkel where the name is editable.
212
+ The name becomes part of the key.
213
+ """
211
214
skel = super ().addSkel ().ensure_is_cloned ()
212
215
skel .name .readOnly = False
213
216
skel .name .required = True
@@ -230,10 +233,11 @@ def onDeleted(self, *args, **kwargs):
230
233
def _reload_translations (self ):
231
234
if (
232
235
self ._last_reload is not None
233
- and self ._last_reload - utils .utcNow () < td (minutes = 10 )
236
+ and self ._last_reload - utils .utcNow () < datetime . timedelta (minutes = 10 )
234
237
):
235
238
# debounce: translations has been reload recently, skip this
236
239
return None
240
+
237
241
logging .info ("Reload translations" )
238
242
# TODO: this affects only the current instance
239
243
self ._last_reload = utils .utcNow ()
0 commit comments