mirror of https://github.com/tLDP/LDP
Add Topics, i18n support added also
This commit is contained in:
parent
cb9356c3aa
commit
43429f74fb
|
@ -116,6 +116,7 @@ class Lampadas:
|
|||
self.Docs.Load()
|
||||
self.Languages = Languages()
|
||||
self.Strings = Strings()
|
||||
self.Topics = Topics()
|
||||
self.Users = Users()
|
||||
|
||||
def User(self, UserID):
|
||||
|
@ -161,7 +162,6 @@ class Class:
|
|||
newClassI18n.Load(self.row)
|
||||
self.I18n[newClassI18n.Lang] = newClassI18n
|
||||
|
||||
# ClassI18n
|
||||
|
||||
class ClassI18n:
|
||||
|
||||
|
@ -553,6 +553,52 @@ class StringI18n:
|
|||
self.Lang = row[0]
|
||||
self.Text = trim(row[1])
|
||||
|
||||
|
||||
# Topics
|
||||
|
||||
class Topics(LampadasCollection):
|
||||
"""
|
||||
A collection object of all topics.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.data = {}
|
||||
self.sql = "SELECT topic_num FROM topic"
|
||||
self.cursor = DB.Select(self.sql)
|
||||
while (1):
|
||||
row = self.cursor.fetchone()
|
||||
if row == None: break
|
||||
newTopic = Topic()
|
||||
newTopic.Load(row)
|
||||
self.data[newTopic.Num] = newTopic
|
||||
|
||||
|
||||
class Topic:
|
||||
|
||||
def __init__(self, TopicNum=None):
|
||||
self.I18n = {}
|
||||
if TopicNum==None: return
|
||||
self.Num = TopicNum
|
||||
|
||||
def Load(self, row):
|
||||
self.Num = trim(row[0])
|
||||
self.sql = "SELECT lang, topic_name, topic_description FROM topic_i18n string_i18n WHERE topic_num=" + wsq(self.Num)
|
||||
self.cursor = DB.Select(self.sql)
|
||||
while (1):
|
||||
self.row = self.cursor.fetchone()
|
||||
if self.row == None: break
|
||||
newTopicI18n = TopicI18n()
|
||||
newTopicI18n.Load(self.row)
|
||||
self.I18n[newTopicI18n.Lang] = newTopicI18n
|
||||
|
||||
|
||||
class TopicI18n:
|
||||
|
||||
def Load(self, row):
|
||||
self.Lang = row[0]
|
||||
self.Name = trim(row[1])
|
||||
self.Description = trim(row[2])
|
||||
|
||||
|
||||
# Users
|
||||
|
||||
|
|
|
@ -193,6 +193,13 @@ class testDocVersions(unittest.TestCase):
|
|||
assert found == 1
|
||||
|
||||
|
||||
class testLanguages(unittest.TestCase):
|
||||
|
||||
def testLanguages(self):
|
||||
assert L.Languages['EN'].Name == 'English'
|
||||
assert L.Languages['FR'].Name == 'French'
|
||||
assert L.Languages.Count() == 136
|
||||
|
||||
class testStrings(unittest.TestCase):
|
||||
|
||||
def testStrings(self):
|
||||
|
@ -200,13 +207,17 @@ class testStrings(unittest.TestCase):
|
|||
assert L.Strings.Count() > 0
|
||||
assert not L.Strings['header'] == None
|
||||
assert L.Strings['test'].I18n['EN'].Text == 'Test Text'
|
||||
|
||||
class testLanguages(unittest.TestCase):
|
||||
|
||||
def testLanguages(self):
|
||||
assert L.Languages['EN'].Name == 'English'
|
||||
assert L.Languages['FR'].Name == 'French'
|
||||
assert L.Languages.Count() == 136
|
||||
class testTopics(unittest.TestCase):
|
||||
|
||||
def testTopics(self):
|
||||
assert not L.Topics == None
|
||||
assert L.Topics.Count() > 0
|
||||
keys = L.Topics.keys()
|
||||
for key in keys:
|
||||
Topic = L.Topics[key]
|
||||
assert Topic.Num > 0
|
||||
assert Topic.I18n['EN'].Name > ''
|
||||
|
||||
class testUsers(unittest.TestCase):
|
||||
|
||||
|
|
Loading…
Reference in New Issue