cablegates/pandora/app/models.py

44 lines
1.2 KiB
Python
Raw Normal View History

2010-02-27 11:37:22 +00:00
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
2011-02-22 14:54:38 +00:00
from __future__ import division, with_statement
import os
from django.db import models
from django.conf import settings
from ox.utils import json
2011-01-01 11:44:42 +00:00
2011-01-21 15:44:46 +00:00
2010-02-10 13:10:14 +00:00
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 10:49:06 +00:00
2011-01-01 11:44:42 +00:00
2010-02-27 10:49:06 +00:00
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-14 14:32:48 +00:00
def site_config():
with open(settings.SITE_CONFIG) as f:
2011-01-14 14:32:48 +00:00
site_config = json.load(f)
site_config['site']['id'] = settings.SITEID
site_config['site']['name'] = settings.SITENAME
site_config['site']['sectionName'] = settings.SITENAME
site_config['site']['url'] = settings.URL
site_config['formats'] = settings.VIDEO_FORMATS
site_config['resolutions'] = settings.VIDEO_RESOLUTIONS
2011-01-14 14:32:48 +00:00
site_config['keys'] = {}
for key in site_config['itemKeys']:
2011-01-14 14:32:48 +00:00
site_config['keys'][key['id']] = key
return site_config