2010-02-27 17:07:22 +05:30
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vi:si:et:sw=4:sts=4:ts=4
|
2011-02-22 15:54:38 +01:00
|
|
|
from __future__ import division, with_statement
|
2011-01-03 19:44:54 +05:30
|
|
|
import os
|
2009-10-05 00:00:08 +02:00
|
|
|
|
2011-01-03 19:44:54 +05:30
|
|
|
from django.db import models
|
|
|
|
from django.conf import settings
|
|
|
|
from ox.utils import json
|
2011-01-01 17:14:42 +05:30
|
|
|
|
2011-01-21 21:14:46 +05:30
|
|
|
|
2010-02-10 18:40:14 +05:30
|
|
|
class Page(models.Model):
|
|
|
|
created = models.DateTimeField(auto_now_add=True)
|
|
|
|
modified = models.DateTimeField(auto_now=True)
|
|
|
|
name = models.CharField(max_length=1024, unique=True)
|
|
|
|
body = models.TextField(blank=True)
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.name
|
2010-02-27 16:19:06 +05:30
|
|
|
|
2011-01-01 17:14:42 +05:30
|
|
|
|
2010-02-27 16:19:06 +05:30
|
|
|
class SiteSettings(models.Model):
|
|
|
|
key = models.CharField(max_length=1024, unique=True)
|
|
|
|
value = models.TextField(blank=True)
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.key
|
2011-01-03 19:44:54 +05:30
|
|
|
|
2011-01-14 14:32:48 +00:00
|
|
|
def site_config():
|
2011-01-24 15:08:46 +05:30
|
|
|
with open(settings.SITE_CONFIG) as f:
|
2011-01-14 14:32:48 +00:00
|
|
|
site_config = json.load(f)
|
2011-08-18 14:01:37 +02:00
|
|
|
|
|
|
|
site_config['site']['id'] = settings.SITEID
|
|
|
|
site_config['site']['name'] = settings.SITENAME
|
|
|
|
site_config['site']['sectionName'] = settings.SITENAME
|
|
|
|
site_config['site']['url'] = settings.URL
|
|
|
|
|
2011-01-14 14:32:48 +00:00
|
|
|
site_config['keys'] = {}
|
2011-01-24 15:08:46 +05:30
|
|
|
for key in site_config['itemKeys']:
|
2011-01-14 14:32:48 +00:00
|
|
|
site_config['keys'][key['id']] = key
|
|
|
|
return site_config
|