mirror of https://github.com/tLDP/LDP
Added PubStatus, PubStatuses
I18n support for Languages I18n support for PubStatuses
This commit is contained in:
parent
b1fee4802c
commit
d0e4d1aa4f
|
@ -17,9 +17,11 @@ psql lampadas -qf dtd.sql
|
||||||
psql lampadas -qf format.sql
|
psql lampadas -qf format.sql
|
||||||
psql lampadas -qf format_i18n.sql
|
psql lampadas -qf format_i18n.sql
|
||||||
psql lampadas -qf language.sql
|
psql lampadas -qf language.sql
|
||||||
|
psql lampadas -qf language_i18n.sql
|
||||||
psql lampadas -qf license.sql
|
psql lampadas -qf license.sql
|
||||||
psql lampadas -qf notes.sql
|
psql lampadas -qf notes.sql
|
||||||
psql lampadas -qf pub_status.sql
|
psql lampadas -qf pub_status.sql
|
||||||
|
psql lampadas -qf pub_status_i18n.sql
|
||||||
psql lampadas -qf review_status.sql
|
psql lampadas -qf review_status.sql
|
||||||
psql lampadas -qf role.sql
|
psql lampadas -qf role.sql
|
||||||
psql lampadas -qf stats.sql
|
psql lampadas -qf stats.sql
|
||||||
|
|
|
@ -1,33 +1,39 @@
|
||||||
ALTER TABLE class_i18n ADD CONSTRAINT class_id_fk FOREIGN KEY (class_id) REFERENCES class(class_id);
|
ALTER TABLE class_i18n ADD CONSTRAINT class_id_fk FOREIGN KEY (class_id) REFERENCES class(class_id);
|
||||||
ALTER TABLE class_i18n ADD CONSTRAINT class_lang_fk FOREIGN KEY (lang) REFERENCES language(isocode);
|
ALTER TABLE class_i18n ADD CONSTRAINT class_lang_fk FOREIGN KEY (lang) REFERENCES language(isocode);
|
||||||
ALTER TABLE document ADD CONSTRAINT class_id_fk FOREIGN KEY (class_id) REFERENCES class(class_id);
|
ALTER TABLE document ADD CONSTRAINT class_id_fk FOREIGN KEY (class_id) REFERENCES class(class_id);
|
||||||
ALTER TABLE document ADD CONSTRAINT format_fk FOREIGN KEY (format) REFERENCES format(format);
|
ALTER TABLE document ADD CONSTRAINT format_fk FOREIGN KEY (format) REFERENCES format(format);
|
||||||
ALTER TABLE document ADD CONSTRAINT dtd_fk FOREIGN KEY (dtd) REFERENCES dtd(dtd);
|
ALTER TABLE document ADD CONSTRAINT dtd_fk FOREIGN KEY (dtd) REFERENCES dtd(dtd);
|
||||||
ALTER TABLE document ADD CONSTRAINT pub_status_fk FOREIGN KEY (pub_status) REFERENCES pub_status(pub_status);
|
ALTER TABLE document ADD CONSTRAINT pub_status_fk FOREIGN KEY (pub_status) REFERENCES pub_status(pub_status);
|
||||||
ALTER TABLE document ADD CONSTRAINT review_status_fk FOREIGN KEY (review_status) REFERENCES review_status(review_status);
|
ALTER TABLE document ADD CONSTRAINT review_status_fk FOREIGN KEY (review_status) REFERENCES review_status(review_status);
|
||||||
ALTER TABLE document ADD CONSTRAINT tech_status_fk FOREIGN KEY (tech_review_status) REFERENCES review_status(review_status);
|
ALTER TABLE document ADD CONSTRAINT tech_status_fk FOREIGN KEY (tech_review_status) REFERENCES review_status(review_status);
|
||||||
ALTER TABLE document ADD CONSTRAINT license_fk FOREIGN KEY (license) REFERENCES license(license);
|
ALTER TABLE document ADD CONSTRAINT license_fk FOREIGN KEY (license) REFERENCES license(license);
|
||||||
ALTER TABLE document ADD CONSTRAINT language_fk FOREIGN KEY (lang) REFERENCES language(isocode);
|
ALTER TABLE document ADD CONSTRAINT language_fk FOREIGN KEY (lang) REFERENCES language(isocode);
|
||||||
ALTER TABLE document_error ADD CONSTRAINT doc_id_fk FOREIGN KEY (doc_id) REFERENCES document(doc_id);
|
ALTER TABLE document_error ADD CONSTRAINT doc_id_fk FOREIGN KEY (doc_id) REFERENCES document(doc_id);
|
||||||
ALTER TABLE document_file ADD CONSTRAINT doc_id_fk FOREIGN KEY (doc_id) REFERENCES document(doc_id);
|
ALTER TABLE document_file ADD CONSTRAINT doc_id_fk FOREIGN KEY (doc_id) REFERENCES document(doc_id);
|
||||||
ALTER TABLE document_file ADD CONSTRAINT format_fk FOREIGN KEY (format) REFERENCES format(format);
|
ALTER TABLE document_file ADD CONSTRAINT format_fk FOREIGN KEY (format) REFERENCES format(format);
|
||||||
ALTER TABLE document_rev ADD CONSTRAINT doc_id_fk FOREIGN KEY (doc_id) REFERENCES document(doc_id);
|
ALTER TABLE document_rev ADD CONSTRAINT doc_id_fk FOREIGN KEY (doc_id) REFERENCES document(doc_id);
|
||||||
ALTER TABLE document_topic ADD CONSTRAINT doc_id_fk FOREIGN KEY (doc_id) REFERENCES document(doc_id);
|
ALTER TABLE document_topic ADD CONSTRAINT doc_id_fk FOREIGN KEY (doc_id) REFERENCES document(doc_id);
|
||||||
ALTER TABLE document_topic ADD CONSTRAINT topic_num_fk FOREIGN KEY (topic_num) REFERENCES topic(topic_num);
|
ALTER TABLE document_topic ADD CONSTRAINT topic_num_fk FOREIGN KEY (topic_num) REFERENCES topic(topic_num);
|
||||||
ALTER TABLE document_user ADD CONSTRAINT doc_id_fk FOREIGN KEY (doc_id) REFERENCES document(doc_id);
|
ALTER TABLE document_user ADD CONSTRAINT doc_id_fk FOREIGN KEY (doc_id) REFERENCES document(doc_id);
|
||||||
ALTER TABLE document_user ADD CONSTRAINT user_id_fk FOREIGN KEY (user_id) REFERENCES username(user_id);
|
ALTER TABLE document_user ADD CONSTRAINT user_id_fk FOREIGN KEY (user_id) REFERENCES username(user_id);
|
||||||
ALTER TABLE document_user ADD CONSTRAINT role_fk FOREIGN KEY (role) REFERENCES role(role);
|
ALTER TABLE document_user ADD CONSTRAINT role_fk FOREIGN KEY (role) REFERENCES role(role);
|
||||||
ALTER TABLE document_wiki ADD CONSTRAINT doc_id_fk FOREIGN KEY (doc_id) REFERENCES document(doc_id);
|
ALTER TABLE document_wiki ADD CONSTRAINT doc_id_fk FOREIGN KEY (doc_id) REFERENCES document(doc_id);
|
||||||
ALTER TABLE document_wiki ADD CONSTRAINT user_id_fk FOREIGN KEY (user_id) REFERENCES username(user_id);
|
ALTER TABLE document_wiki ADD CONSTRAINT user_id_fk FOREIGN KEY (user_id) REFERENCES username(user_id);
|
||||||
ALTER TABLE doc_vote ADD CONSTRAINT doc_id_fk FOREIGN KEY (doc_id) REFERENCES document(doc_id);
|
ALTER TABLE doc_vote ADD CONSTRAINT doc_id_fk FOREIGN KEY (doc_id) REFERENCES document(doc_id);
|
||||||
ALTER TABLE doc_vote ADD CONSTRAINT user_id_fk FOREIGN KEY (user_id) REFERENCES username(user_id);
|
ALTER TABLE doc_vote ADD CONSTRAINT user_id_fk FOREIGN KEY (user_id) REFERENCES username(user_id);
|
||||||
ALTER TABLE notes ADD CONSTRAINT doc_id_fk FOREIGN KEY (doc_id) REFERENCES document(doc_id);
|
ALTER TABLE format_i18n ADD CONSTRAINT format_fk FOREIGN KEY (format) REFERENCES format(format);
|
||||||
ALTER TABLE notes ADD CONSTRAINT creator_id_fk FOREIGN KEY (creator_id) REFERENCES username(user_id);
|
ALTER TABLE format_i18n ADD CONSTRAINT format_lang_fk FOREIGN KEY (lang) REFERENCES language(isocode);
|
||||||
ALTER TABLE string_i18n ADD CONSTRAINT string_code_fk FOREIGN KEY (string_code) REFERENCES string(string_code);
|
ALTER TABLE language_i18n ADD CONSTRAINT language_fk FOREIGN KEY (language) REFERENCES language(isocode);
|
||||||
ALTER TABLE string_i18n ADD CONSTRAINT string_lang_fk FOREIGN KEY (lang) REFERENCES language(isocode);
|
ALTER TABLE language_i18n ADD CONSTRAINT language_lang_fk FOREIGN KEY (lang) REFERENCES language(isocode);
|
||||||
ALTER TABLE subtopic ADD CONSTRAINT topic_num_fk FOREIGN KEY (topic_num) REFERENCES topic(topic_num);
|
ALTER TABLE notes ADD CONSTRAINT doc_id_fk FOREIGN KEY (doc_id) REFERENCES document(doc_id);
|
||||||
ALTER TABLE topic_i18n ADD CONSTRAINT topic_num_fk FOREIGN KEY (topic_num) REFERENCES topic(topic_num);
|
ALTER TABLE notes ADD CONSTRAINT creator_id_fk FOREIGN KEY (creator_id) REFERENCES username(user_id);
|
||||||
ALTER TABLE topic_i18n ADD CONSTRAINT lang_fk FOREIGN KEY (lang) REFERENCES language(isocode);
|
ALTER TABLE pub_status_i18n ADD CONSTRAINT pub_status_fk FOREIGN KEY (pub_status) REFERENCES pub_status(pub_status);
|
||||||
ALTER TABLE username_notes ADD CONSTRAINT user_id_fk FOREIGN KEY (user_id) REFERENCES username(user_id);
|
ALTER TABLE pub_status_i18n ADD CONSTRAINT pub_status_lang_fk FOREIGN KEY (lang) REFERENCES language(isocode);
|
||||||
ALTER TABLE username_notes ADD CONSTRAINT creator_id_fk FOREIGN KEY (creator_id) REFERENCES username(user_id);
|
ALTER TABLE string_i18n ADD CONSTRAINT string_code_fk FOREIGN KEY (string_code) REFERENCES string(string_code);
|
||||||
|
ALTER TABLE string_i18n ADD CONSTRAINT string_lang_fk FOREIGN KEY (lang) REFERENCES language(isocode);
|
||||||
|
ALTER TABLE subtopic ADD CONSTRAINT topic_num_fk FOREIGN KEY (topic_num) REFERENCES topic(topic_num);
|
||||||
|
ALTER TABLE topic_i18n ADD CONSTRAINT topic_num_fk FOREIGN KEY (topic_num) REFERENCES topic(topic_num);
|
||||||
|
ALTER TABLE topic_i18n ADD CONSTRAINT lang_fk FOREIGN KEY (lang) REFERENCES language(isocode);
|
||||||
|
ALTER TABLE username_notes ADD CONSTRAINT user_id_fk FOREIGN KEY (user_id) REFERENCES username(user_id);
|
||||||
|
ALTER TABLE username_notes ADD CONSTRAINT creator_id_fk FOREIGN KEY (creator_id) REFERENCES username(user_id);
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ DROP TABLE language;
|
||||||
CREATE TABLE language
|
CREATE TABLE language
|
||||||
(
|
(
|
||||||
isocode CHAR(2),
|
isocode CHAR(2),
|
||||||
language_name CHAR(60),
|
|
||||||
|
|
||||||
PRIMARY KEY (isocode)
|
PRIMARY KEY (isocode)
|
||||||
);
|
);
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
DROP TABLE language_i18n;
|
||||||
|
|
||||||
|
CREATE TABLE language_i18n
|
||||||
|
(
|
||||||
|
isocode CHAR(2),
|
||||||
|
lang CHAR(2),
|
||||||
|
language_name CHAR(60),
|
||||||
|
|
||||||
|
PRIMARY KEY (isocode, lang)
|
||||||
|
);
|
||||||
|
|
|
@ -15,9 +15,11 @@ copy dtd from '/tmp/lampadas_dtd.txt';
|
||||||
copy format from '/tmp/lampadas_format.txt';
|
copy format from '/tmp/lampadas_format.txt';
|
||||||
copy format_i18n from '/tmp/lampadas_format_i18n.txt';
|
copy format_i18n from '/tmp/lampadas_format_i18n.txt';
|
||||||
copy language from '/tmp/lampadas_language.txt';
|
copy language from '/tmp/lampadas_language.txt';
|
||||||
|
copy language_i18n from '/tmp/lampadas_language_i18n.txt';
|
||||||
copy license from '/tmp/lampadas_license.txt';
|
copy license from '/tmp/lampadas_license.txt';
|
||||||
copy notes from '/tmp/lampadas_notes.txt';
|
copy notes from '/tmp/lampadas_notes.txt';
|
||||||
copy pub_status from '/tmp/lampadas_pub_status.txt';
|
copy pub_status from '/tmp/lampadas_pub_status.txt';
|
||||||
|
copy pub_status_i18n from '/tmp/lampadas_pub_status_i18n.txt';
|
||||||
copy review_status from '/tmp/lampadas_review_status.txt';
|
copy review_status from '/tmp/lampadas_review_status.txt';
|
||||||
copy role from '/tmp/lampadas_role.txt';
|
copy role from '/tmp/lampadas_role.txt';
|
||||||
copy stats from '/tmp/lampadas_stats.txt';
|
copy stats from '/tmp/lampadas_stats.txt';
|
||||||
|
|
|
@ -13,10 +13,13 @@ GRANT ALL ON document_user TO "www-data";
|
||||||
GRANT ALL ON document_wiki TO "www-data";
|
GRANT ALL ON document_wiki TO "www-data";
|
||||||
GRANT ALL ON dtd TO "www-data";
|
GRANT ALL ON dtd TO "www-data";
|
||||||
GRANT ALL ON format TO "www-data";
|
GRANT ALL ON format TO "www-data";
|
||||||
|
GRANT ALL ON format_i18n TO "www-data";
|
||||||
GRANT ALL ON language TO "www-data";
|
GRANT ALL ON language TO "www-data";
|
||||||
|
GRANT ALL ON language_i18n TO "www-data";
|
||||||
GRANT ALL ON license TO "www-data";
|
GRANT ALL ON license TO "www-data";
|
||||||
GRANT ALL ON notes TO "www-data";
|
GRANT ALL ON notes TO "www-data";
|
||||||
GRANT ALL ON pub_status TO "www-data";
|
GRANT ALL ON pub_status TO "www-data";
|
||||||
|
GRANT ALL ON pub_status_i18n TO "www-data";
|
||||||
GRANT ALL ON review_status TO "www-data";
|
GRANT ALL ON review_status TO "www-data";
|
||||||
GRANT ALL ON role TO "www-data";
|
GRANT ALL ON role TO "www-data";
|
||||||
GRANT ALL ON stats TO "www-data";
|
GRANT ALL ON stats TO "www-data";
|
||||||
|
|
|
@ -3,8 +3,6 @@ DROP TABLE pub_status;
|
||||||
CREATE TABLE pub_status
|
CREATE TABLE pub_status
|
||||||
(
|
(
|
||||||
pub_status CHAR NOT NULL,
|
pub_status CHAR NOT NULL,
|
||||||
pub_status_name TEXT,
|
|
||||||
pub_status_desc TEXT,
|
|
||||||
|
|
||||||
PRIMARY KEY (pub_status)
|
PRIMARY KEY (pub_status)
|
||||||
);
|
);
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
DROP TABLE pub_status_i18n;
|
||||||
|
|
||||||
|
CREATE TABLE pub_status_i18n
|
||||||
|
(
|
||||||
|
pub_status CHAR NOT NULL,
|
||||||
|
lang CHAR(2) NOT NULL,
|
||||||
|
pub_status_name TEXT,
|
||||||
|
pub_status_desc TEXT,
|
||||||
|
|
||||||
|
PRIMARY KEY (pub_status, lang)
|
||||||
|
);
|
|
@ -15,9 +15,11 @@ copy dtd to '/tmp/lampadas_dtd.txt';
|
||||||
copy format to '/tmp/lampadas_format.txt';
|
copy format to '/tmp/lampadas_format.txt';
|
||||||
copy format_i18n to '/tmp/lampadas_format_i18n.txt';
|
copy format_i18n to '/tmp/lampadas_format_i18n.txt';
|
||||||
copy language to '/tmp/lampadas_language.txt';
|
copy language to '/tmp/lampadas_language.txt';
|
||||||
|
copy language_i18n to '/tmp/lampadas_language_i18n.txt';
|
||||||
copy license to '/tmp/lampadas_license.txt';
|
copy license to '/tmp/lampadas_license.txt';
|
||||||
copy notes to '/tmp/lampadas_notes.txt';
|
copy notes to '/tmp/lampadas_notes.txt';
|
||||||
copy pub_status to '/tmp/lampadas_pub_status.txt';
|
copy pub_status to '/tmp/lampadas_pub_status.txt';
|
||||||
|
copy pub_status_i18n to '/tmp/lampadas_pub_status_i18n.txt';
|
||||||
copy review_status to '/tmp/lampadas_review_status.txt';
|
copy review_status to '/tmp/lampadas_review_status.txt';
|
||||||
copy role to '/tmp/lampadas_role.txt';
|
copy role to '/tmp/lampadas_role.txt';
|
||||||
copy stats to '/tmp/lampadas_stats.txt';
|
copy stats to '/tmp/lampadas_stats.txt';
|
||||||
|
|
|
@ -283,10 +283,8 @@ while (@row = $result->fetchrow) {
|
||||||
#
|
#
|
||||||
# NOTE: must come before document_new table is generated
|
# NOTE: must come before document_new table is generated
|
||||||
#
|
#
|
||||||
$sql = "CREATE TABLE class_new (class_id INT4 NOT NULL, PRIMARY KEY (class_id))";
|
$conn->exec("CREATE TABLE class_new (class_id INT4 NOT NULL, PRIMARY KEY (class_id))");
|
||||||
$conn->exec($sql);
|
$conn->exec("CREATE TABLE class_i18n (class_id INT4 NOT NULL, lang CHAR(2) NOT NULL, class_name CHAR(20) NOT NULL, class_description TEXT NOT NULL, PRIMARY KEY (class_id, lang))");
|
||||||
$sql = "CREATE TABLE class_i18n (class_id INT4 NOT NULL, lang CHAR(2) NOT NULL, class_name CHAR(20) NOT NULL, class_description TEXT NOT NULL, PRIMARY KEY (class_id, lang))";
|
|
||||||
$conn->exec($sql);
|
|
||||||
|
|
||||||
$sql = "SELECT class, class_name FROM class";
|
$sql = "SELECT class, class_name FROM class";
|
||||||
$result = $conn->exec("$sql");
|
$result = $conn->exec("$sql");
|
||||||
|
@ -302,6 +300,20 @@ while (@row = $result->fetchrow) {
|
||||||
$conn->exec($sql);
|
$conn->exec($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# i18n support in format table
|
||||||
|
#
|
||||||
|
$conn->exec("CREATE TABLE format_new (format CHAR(12) NOT NULL, PRIMARY KEY (format))");
|
||||||
|
$conn->exec("CREATE TABLE format_i18n (format CHAR(12) NOT NULL, lang CHAR(2) NOT NULL, format_name CHAR(20) NOT NULL, PRIMARY KEY (format, lang))");
|
||||||
|
$conn->exec("INSERT INTO format_i18n SELECT format, 'EN' as lang, format_name FROM format");
|
||||||
|
$conn->exec("INSERT INTO format_new SELECT format FROM format");
|
||||||
|
|
||||||
|
# i18n support in pub_status table
|
||||||
|
#
|
||||||
|
$conn->exec("CREATE TABLE pub_status_new (pub_status CHAR(1) NOT NULL, PRIMARY KEY (pub_status))");
|
||||||
|
$conn->exec("CREATE TABLE pub_status_i18n (pub_status CHAR(1) NOT NULL, lang CHAR(2) NOT NULL, pub_status_name TEXT NOT NULL, pub_status_description TEXT NOT NULL, PRIMARY KEY (pub_status, lang))");
|
||||||
|
$conn->exec("INSERT INTO pub_status_i18n SELECT pub_status, 'EN' as lang, pub_status_name, pub_status_description FROM pub_status");
|
||||||
|
$conn->exec("INSERT INTO pub_status_new SELECT pub_status FROM pub_status");
|
||||||
|
|
||||||
# i18n support in topic table
|
# i18n support in topic table
|
||||||
#
|
#
|
||||||
$conn->exec("CREATE TABLE topic_new (topic_num INT4 NOT NULL, PRIMARY KEY (topic_num)");
|
$conn->exec("CREATE TABLE topic_new (topic_num INT4 NOT NULL, PRIMARY KEY (topic_num)");
|
||||||
|
@ -412,6 +424,7 @@ $conn->exec("DROP TABLE document_wiki");
|
||||||
$conn->exec("DROP TABLE doc_vote");
|
$conn->exec("DROP TABLE doc_vote");
|
||||||
$conn->exec("DROP TABLE editor");
|
$conn->exec("DROP TABLE editor");
|
||||||
$conn->exec("DROP TABLE editor_role");
|
$conn->exec("DROP TABLE editor_role");
|
||||||
|
$conn->exec("DROP TABLE format");
|
||||||
$conn->exec("DROP TABLE maintainer");
|
$conn->exec("DROP TABLE maintainer");
|
||||||
$conn->exec("DROP TABLE maintainer_notes");
|
$conn->exec("DROP TABLE maintainer_notes");
|
||||||
$conn->exec("DROP TABLE notes");
|
$conn->exec("DROP TABLE notes");
|
||||||
|
@ -423,6 +436,7 @@ $conn->exec("ALTER TABLE class_new RENAME TO class");
|
||||||
$conn->exec("ALTER TABLE document_new RENAME TO document");
|
$conn->exec("ALTER TABLE document_new RENAME TO document");
|
||||||
$conn->exec("ALTER TABLE document_wiki_new RENAME TO document_wiki");
|
$conn->exec("ALTER TABLE document_wiki_new RENAME TO document_wiki");
|
||||||
$conn->exec("ALTER TABLE doc_vote_new RENAME TO doc_vote");
|
$conn->exec("ALTER TABLE doc_vote_new RENAME TO doc_vote");
|
||||||
|
$conn->exec("ALTER TABLE format_new RENAME TO format");
|
||||||
$conn->exec("ALTER TABLE notes_new RENAME TO notes");
|
$conn->exec("ALTER TABLE notes_new RENAME TO notes");
|
||||||
$conn->exec("ALTER TABLE role_new RENAME TO role");
|
$conn->exec("ALTER TABLE role_new RENAME TO role");
|
||||||
$conn->exec("ALTER TABLE topic_new RENAME TO topic");
|
$conn->exec("ALTER TABLE topic_new RENAME TO topic");
|
||||||
|
|
|
@ -108,18 +108,19 @@ class Lampadas:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.Classes = Classes()
|
self.Classes = Classes()
|
||||||
self.Classes.Load()
|
self.Classes.Load()
|
||||||
self.Config = Config()
|
self.Config = Config()
|
||||||
self.Config.Load()
|
self.Config.Load()
|
||||||
self.Docs = Docs()
|
self.Docs = Docs()
|
||||||
self.Docs.Load()
|
self.Docs.Load()
|
||||||
self.DTDs = DTDs()
|
self.DTDs = DTDs()
|
||||||
self.Formats = Formats()
|
self.Formats = Formats()
|
||||||
self.Languages = Languages()
|
self.Languages = Languages()
|
||||||
self.Strings = Strings()
|
self.PubStatuses = PubStatuses()
|
||||||
self.Topics = Topics()
|
self.Strings = Strings()
|
||||||
self.Users = Users()
|
self.Topics = Topics()
|
||||||
|
self.Users = Users()
|
||||||
|
|
||||||
def User(self, UserID):
|
def User(self, UserID):
|
||||||
return User(UserID)
|
return User(UserID)
|
||||||
|
@ -564,15 +565,77 @@ class Languages(LampadasCollection):
|
||||||
class Language:
|
class Language:
|
||||||
|
|
||||||
def __init__(self, LanguageCode=None):
|
def __init__(self, LanguageCode=None):
|
||||||
|
self.I18n = {}
|
||||||
if LanguageCode == None: return
|
if LanguageCode == None: return
|
||||||
self.Code = LanguageCode
|
self.Code = LanguageCode
|
||||||
self.sql = "SELECT isocode, language_name FROM language WHERE isocode= " + wsq(LanguageCode)
|
self.sql = "SELECT isocode FROM language WHERE isocode= " + wsq(LanguageCode)
|
||||||
self.cursor = DB.Select(self.sql)
|
self.cursor = DB.Select(self.sql)
|
||||||
self.Load(self.sql)
|
self.Load(self.sql)
|
||||||
|
|
||||||
def Load(self, row):
|
def Load(self, row):
|
||||||
self.Code = trim(row[0])
|
self.Code = trim(row[0])
|
||||||
self.Name = trim(row[1])
|
self.sql = "SELECT lang, language_name FROM language_i18n WHERE isocode=" + wsq(self.Code)
|
||||||
|
self.cursor = DB.Select(self.sql)
|
||||||
|
while (1):
|
||||||
|
self.row = self.cursor.fetchone()
|
||||||
|
if self.row == None: break
|
||||||
|
newLanguageI18n = LanguageI18n()
|
||||||
|
newLanguageI18n.Load(self.row)
|
||||||
|
self.I18n[newLanguageI18n.Lang] = newLanguageI18n
|
||||||
|
|
||||||
|
# LanguageI18n
|
||||||
|
|
||||||
|
class LanguageI18n:
|
||||||
|
|
||||||
|
def Load(self, row):
|
||||||
|
self.Lang = row[0]
|
||||||
|
self.Name = trim(row[1])
|
||||||
|
|
||||||
|
|
||||||
|
# PubStatuses
|
||||||
|
|
||||||
|
class PubStatuses(LampadasCollection):
|
||||||
|
"""
|
||||||
|
A collection object of all publication statuses.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.data = {}
|
||||||
|
self.sql = "SELECT pub_status FROM pub_status"
|
||||||
|
self.cursor = DB.Select(self.sql)
|
||||||
|
while (1):
|
||||||
|
row = self.cursor.fetchone()
|
||||||
|
if row == None: break
|
||||||
|
newPubStatus = PubStatus()
|
||||||
|
newPubStatus.Load(row)
|
||||||
|
self.data[newPubStatus.PubStatus] = newPubStatus
|
||||||
|
|
||||||
|
class PubStatus:
|
||||||
|
|
||||||
|
def __init__(self, PubStatus=None):
|
||||||
|
self.I18n = {}
|
||||||
|
if PubStatus==None: return
|
||||||
|
self.PubStatus = PubStatus
|
||||||
|
|
||||||
|
def Load(self, row):
|
||||||
|
self.PubStatus = trim(row[0])
|
||||||
|
self.sql = "SELECT lang, pub_status_name, pub_status_desc FROM pub_status_i18n WHERE pub_status=" + wsq(self.PubStatus)
|
||||||
|
self.cursor = DB.Select(self.sql)
|
||||||
|
while (1):
|
||||||
|
self.row = self.cursor.fetchone()
|
||||||
|
if self.row == None: break
|
||||||
|
newPubStatusI18n = PubStatusI18n()
|
||||||
|
newPubStatusI18n.Load(self.row)
|
||||||
|
self.I18n[newPubStatusI18n.Lang] = newPubStatusI18n
|
||||||
|
|
||||||
|
# PubStatusI18n
|
||||||
|
|
||||||
|
class PubStatusI18n:
|
||||||
|
|
||||||
|
def Load(self, row):
|
||||||
|
self.Lang = row[0]
|
||||||
|
self.Name = trim(row[1])
|
||||||
|
self.Description = trim(row[2])
|
||||||
|
|
||||||
|
|
||||||
# Strings
|
# Strings
|
||||||
|
|
|
@ -203,10 +203,21 @@ class testFormats(unittest.TestCase):
|
||||||
class testLanguages(unittest.TestCase):
|
class testLanguages(unittest.TestCase):
|
||||||
|
|
||||||
def testLanguages(self):
|
def testLanguages(self):
|
||||||
assert L.Languages['EN'].Name == 'English'
|
assert L.Languages['EN'].I18n['EN'].Name == 'English'
|
||||||
assert L.Languages['FR'].Name == 'French'
|
assert L.Languages['FR'].I18n['EN'].Name == 'French'
|
||||||
assert L.Languages.Count() == 136
|
assert L.Languages.Count() == 136
|
||||||
|
|
||||||
|
class testPubStatuses(unittest.TestCase):
|
||||||
|
|
||||||
|
def testPubStatuses(self):
|
||||||
|
assert not L.PubStatuses == None
|
||||||
|
assert L.PubStatuses.Count() > 0
|
||||||
|
assert not L.PubStatuses['A'] == None
|
||||||
|
assert not L.PubStatuses['A'].I18n == None
|
||||||
|
assert not L.PubStatuses['A'].I18n['EN'] == None
|
||||||
|
assert L.PubStatuses['A'].I18n['EN'].Name > ''
|
||||||
|
assert L.PubStatuses['A'].I18n['EN'].Description > ''
|
||||||
|
|
||||||
class testStrings(unittest.TestCase):
|
class testStrings(unittest.TestCase):
|
||||||
|
|
||||||
def testStrings(self):
|
def testStrings(self):
|
||||||
|
@ -266,6 +277,5 @@ class testUserDocs(unittest.TestCase):
|
||||||
assert UserDoc.Active == 1 or UserDoc.Active == 0
|
assert UserDoc.Active == 1 or UserDoc.Active == 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in New Issue