summaryrefslogtreecommitdiffstats
path: root/src/root.py
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2013-12-18 22:44:25 -0500
committerSimo Sorce <simo@redhat.com>2013-12-18 23:05:57 -0500
commitee0d1ce71d1f4883aecc426595ac86322a91260e (patch)
treed3f068d9bca5ef9ead0ca77ab3a5ae4c25c1cfbf /src/root.py
parent13a58ef5cb599d3e8e3a9484bd84fa6fae3f3390 (diff)
downloadipsilon-ee0d1ce71d1f4883aecc426595ac86322a91260e.zip
ipsilon-ee0d1ce71d1f4883aecc426595ac86322a91260e.tar.gz
ipsilon-ee0d1ce71d1f4883aecc426595ac86322a91260e.tar.xz
Move template and user retrieval to page class
Signed-off-by: Simo Sorce <simo@redhat.com>
Diffstat (limited to 'src/root.py')
-rwxr-xr-xsrc/root.py62
1 files changed, 1 insertions, 61 deletions
diff --git a/src/root.py b/src/root.py
index 50247f7..a352641 100755
--- a/src/root.py
+++ b/src/root.py
@@ -17,70 +17,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-from util import data
from util import page
import cherrypy
-class Site(object):
- def __init__(self, value):
- # implement lookup of sites id for link/name
- self.link = value
- self.name = value
-
-class User(object):
- def __init__(self, username):
- if username is None:
- self.name = None
- self._userdata = dict()
- else:
- self._userdata = self._get_user_data(username)
- self.name = username
-
- def _get_user_data(self, username):
- store = data.Store()
- return store._get_user_preferences(username)
-
- @property
- def is_admin(self):
- if 'is_admin' in self._userdata:
- if self._userdata['is_admin'] == '1':
- return True
- return False
-
- @is_admin.setter
- def is_admin(self, value):
- if value is True:
- self._userdata['is_admin'] = '1'
- else:
- self._userdata['is_admin'] = '0'
-
- @property
- def fullname(self):
- if 'fullname' in self._userdata:
- return self._userdata['fullname']
- else:
- return self.name
-
- @fullname.setter
- def fullname(self, value):
- self._userdata['fullname'] = value
-
- @property
- def sites(self):
- if 'sites' in self._userdata:
- d = []
- for site in self._userdata['sites']:
- d.append(Site(site))
- else:
- return []
-
- @sites.setter
- def sites(self):
- #TODO: implement setting sites via the user object ?
- raise AttributeError
-
class Root(page.Page):
def root(self):
- tmpl = self._env.get_template('index.html')
- return tmpl.render(title='Root', user=User(self.username))
+ return self._template('index.html', title='Root')