SLA plugin: fixed template shown in dialog
[myslice.git] / myslice / theme.py
1 import os
2 from myslice.configengine import ConfigEngine
3 from myslice.settings import TEMPLATE_DIRS
4
5 class ThemeView (object):
6     
7     @property
8     def theme(self):
9         self.config = ConfigEngine()
10         if self.config.myslice.theme :
11             return self.config.myslice.theme
12
13     @property
14     def label(self):
15         self.config = ConfigEngine()
16         if self.config.myslice.theme_label :
17             return self.config.myslice.theme_label
18
19     @property
20     def logo(self):
21         self.config = ConfigEngine()
22         if self.config.myslice.theme_logo :
23             return self.config.myslice.theme_logo
24   
25     @property
26     def template(self):
27         # Load a template from the theme directory if it exists
28         # else load it from the common templates dir
29         #print "THEME = ",self.theme
30         #print "TEMPLATE = ",self.template_name
31         #print "TEMPLATE_DIRS = ",TEMPLATE_DIRS
32         filename = self.theme + '_' + self.template_name
33         #print any(os.path.exists(os.path.join(d,filename)) for d in TEMPLATE_DIRS)
34         #print (os.path.exists(os.path.join(d,filename)) for d in TEMPLATE_DIRS)
35         if any(os.path.exists(os.path.join(d,filename)) for d in TEMPLATE_DIRS):
36             return filename
37         else:
38             return self.template_name