Coverage for app/models/eventTemplate.py: 100%

16 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2024-07-24 12:19 +0000

1import json 

2 

3from app.models import * 

4 

5class EventTemplate(baseModel): 

6 name = CharField() 

7 tag = CharField() 

8 templateJSON = CharField() 

9 templateFile = CharField() 

10 isVisible = BooleanField(default=True) 

11 

12 def fetch(self, key, default=None): 

13 """ 

14 Get a key from the template data. Return the provided default value if the key is not found. 

15 """ 

16 return self.templateData.get(key, default) 

17 

18 @property 

19 def templateData(self): 

20 return json.loads(self.templateJSON) 

21 

22 @templateData.setter 

23 def templateData(self, value): 

24 self.templateJSON = json.dumps(value)