repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
bukun/TorCMS
torcms/handlers/post_ajax_handler.py
PostAjaxHandler.p_recent
def p_recent(self, kind, cur_p='', with_catalog=True, with_date=True): ''' List posts that recent edited, partially. ''' if cur_p == '': current_page_number = 1 else: current_page_number = int(cur_p) current_page_number = 1 if current_page_number ...
python
def p_recent(self, kind, cur_p='', with_catalog=True, with_date=True): ''' List posts that recent edited, partially. ''' if cur_p == '': current_page_number = 1 else: current_page_number = int(cur_p) current_page_number = 1 if current_page_number ...
[ "def", "p_recent", "(", "self", ",", "kind", ",", "cur_p", "=", "''", ",", "with_catalog", "=", "True", ",", "with_date", "=", "True", ")", ":", "if", "cur_p", "==", "''", ":", "current_page_number", "=", "1", "else", ":", "current_page_number", "=", "...
List posts that recent edited, partially.
[ "List", "posts", "that", "recent", "edited", "partially", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_ajax_handler.py#L68-L99
bukun/TorCMS
torcms/handlers/post_ajax_handler.py
PostAjaxHandler.j_delete
def j_delete(self, *args): ''' Delete the post, but return the JSON. ''' uid = args[0] current_infor = MPost.get_by_uid(uid) tslug = MCategory.get_by_uid(current_infor.extinfo['def_cat_uid']) is_deleted = MPost.delete(uid) MCategory.update_count(current_...
python
def j_delete(self, *args): ''' Delete the post, but return the JSON. ''' uid = args[0] current_infor = MPost.get_by_uid(uid) tslug = MCategory.get_by_uid(current_infor.extinfo['def_cat_uid']) is_deleted = MPost.delete(uid) MCategory.update_count(current_...
[ "def", "j_delete", "(", "self", ",", "*", "args", ")", ":", "uid", "=", "args", "[", "0", "]", "current_infor", "=", "MPost", ".", "get_by_uid", "(", "uid", ")", "tslug", "=", "MCategory", ".", "get_by_uid", "(", "current_infor", ".", "extinfo", "[", ...
Delete the post, but return the JSON.
[ "Delete", "the", "post", "but", "return", "the", "JSON", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_ajax_handler.py#L103-L126
bukun/TorCMS
torcms/script/script_init_tabels.py
run_init_tables
def run_init_tables(*args): ''' Run to init tables. ''' print('--') create_table(TabPost) create_table(TabTag) create_table(TabMember) create_table(TabWiki) create_table(TabLink) create_table(TabEntity) create_table(TabPostHist) create_table(TabWikiHist) create_table...
python
def run_init_tables(*args): ''' Run to init tables. ''' print('--') create_table(TabPost) create_table(TabTag) create_table(TabMember) create_table(TabWiki) create_table(TabLink) create_table(TabEntity) create_table(TabPostHist) create_table(TabWikiHist) create_table...
[ "def", "run_init_tables", "(", "*", "args", ")", ":", "print", "(", "'--'", ")", "create_table", "(", "TabPost", ")", "create_table", "(", "TabTag", ")", "create_table", "(", "TabMember", ")", "create_table", "(", "TabWiki", ")", "create_table", "(", "TabLin...
Run to init tables.
[ "Run", "to", "init", "tables", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/script/script_init_tabels.py#L22-L45
bukun/TorCMS
torcms/handlers/entity2user_handler.py
Entity2UserHandler.all_list
def all_list(self, cur_p=''): ''' List the entities of the user. ''' # ToDo: 代码与 entity_handler 中 list 方法有重复 current_page_number = int(cur_p) if cur_p else 1 current_page_number = 1 if current_page_number < 1 else current_page_number kwd = { 'current_...
python
def all_list(self, cur_p=''): ''' List the entities of the user. ''' # ToDo: 代码与 entity_handler 中 list 方法有重复 current_page_number = int(cur_p) if cur_p else 1 current_page_number = 1 if current_page_number < 1 else current_page_number kwd = { 'current_...
[ "def", "all_list", "(", "self", ",", "cur_p", "=", "''", ")", ":", "# ToDo: 代码与 entity_handler 中 list 方法有重复", "current_page_number", "=", "int", "(", "cur_p", ")", "if", "cur_p", "else", "1", "current_page_number", "=", "1", "if", "current_page_number", "<", "1"...
List the entities of the user.
[ "List", "the", "entities", "of", "the", "user", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/entity2user_handler.py#L32-L49
bukun/TorCMS
torcms/handlers/entity2user_handler.py
Entity2UserHandler.user_list
def user_list(self, userid, cur_p=''): ''' List the entities of the user. ''' current_page_number = int(cur_p) if cur_p else 1 current_page_number = 1 if current_page_number < 1 else current_page_number kwd = { 'current_page': current_page_number } ...
python
def user_list(self, userid, cur_p=''): ''' List the entities of the user. ''' current_page_number = int(cur_p) if cur_p else 1 current_page_number = 1 if current_page_number < 1 else current_page_number kwd = { 'current_page': current_page_number } ...
[ "def", "user_list", "(", "self", ",", "userid", ",", "cur_p", "=", "''", ")", ":", "current_page_number", "=", "int", "(", "cur_p", ")", "if", "cur_p", "else", "1", "current_page_number", "=", "1", "if", "current_page_number", "<", "1", "else", "current_pa...
List the entities of the user.
[ "List", "the", "entities", "of", "the", "user", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/entity2user_handler.py#L52-L69
bukun/TorCMS
torcms/core/tool/run_whoosh.py
gen_whoosh_database
def gen_whoosh_database(kind_arr, post_type): ''' kind_arr, define the `type` except Post, Page, Wiki post_type, define the templates for different kind. ''' SITE_CFG['LANG'] = SITE_CFG.get('LANG', 'zh') # Using jieba lib for Chinese. if SITE_CFG['LANG'] == 'zh' and ChineseAnalyzer: ...
python
def gen_whoosh_database(kind_arr, post_type): ''' kind_arr, define the `type` except Post, Page, Wiki post_type, define the templates for different kind. ''' SITE_CFG['LANG'] = SITE_CFG.get('LANG', 'zh') # Using jieba lib for Chinese. if SITE_CFG['LANG'] == 'zh' and ChineseAnalyzer: ...
[ "def", "gen_whoosh_database", "(", "kind_arr", ",", "post_type", ")", ":", "SITE_CFG", "[", "'LANG'", "]", "=", "SITE_CFG", ".", "get", "(", "'LANG'", ",", "'zh'", ")", "# Using jieba lib for Chinese.", "if", "SITE_CFG", "[", "'LANG'", "]", "==", "'zh'", "an...
kind_arr, define the `type` except Post, Page, Wiki post_type, define the templates for different kind.
[ "kind_arr", "define", "the", "type", "except", "Post", "Page", "Wiki", "post_type", "define", "the", "templates", "for", "different", "kind", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/core/tool/run_whoosh.py#L132-L167
bukun/TorCMS
torcms/handlers/publish_handler.py
PublishHandler.echo_class2
def echo_class2(self, catstr=''): ''' 弹出的二级发布菜单 ''' fatherid = catstr[1:] self.write(self.format_class2(fatherid))
python
def echo_class2(self, catstr=''): ''' 弹出的二级发布菜单 ''' fatherid = catstr[1:] self.write(self.format_class2(fatherid))
[ "def", "echo_class2", "(", "self", ",", "catstr", "=", "''", ")", ":", "fatherid", "=", "catstr", "[", "1", ":", "]", "self", ".", "write", "(", "self", ".", "format_class2", "(", "fatherid", ")", ")" ]
弹出的二级发布菜单
[ "弹出的二级发布菜单" ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/publish_handler.py#L47-L52
bukun/TorCMS
torcms/handlers/publish_handler.py
PublishHandler.view_class1
def view_class1(self, kind_sig): ''' Publishing from 1st range category. ''' dbdata = MCategory.get_parent_list(kind=kind_sig) class1str = '' for rec in dbdata: class1str += ''' <a onclick="select_sub_tag('/publish/2{0}');" class="btn btn-primary"...
python
def view_class1(self, kind_sig): ''' Publishing from 1st range category. ''' dbdata = MCategory.get_parent_list(kind=kind_sig) class1str = '' for rec in dbdata: class1str += ''' <a onclick="select_sub_tag('/publish/2{0}');" class="btn btn-primary"...
[ "def", "view_class1", "(", "self", ",", "kind_sig", ")", ":", "dbdata", "=", "MCategory", ".", "get_parent_list", "(", "kind", "=", "kind_sig", ")", "class1str", "=", "''", "for", "rec", "in", "dbdata", ":", "class1str", "+=", "'''\n <a onclick=\"s...
Publishing from 1st range category.
[ "Publishing", "from", "1st", "range", "category", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/publish_handler.py#L68-L85
bukun/TorCMS
torcms/handlers/publish_handler.py
PublishHandler.view_class2
def view_class2(self, fatherid=''): ''' Publishing from 2ed range category. ''' if self.is_admin(): pass else: return False kwd = {'class1str': self.format_class2(fatherid), 'parentid': '0', 'parentlist': MCategory.g...
python
def view_class2(self, fatherid=''): ''' Publishing from 2ed range category. ''' if self.is_admin(): pass else: return False kwd = {'class1str': self.format_class2(fatherid), 'parentid': '0', 'parentlist': MCategory.g...
[ "def", "view_class2", "(", "self", ",", "fatherid", "=", "''", ")", ":", "if", "self", ".", "is_admin", "(", ")", ":", "pass", "else", ":", "return", "False", "kwd", "=", "{", "'class1str'", ":", "self", ".", "format_class2", "(", "fatherid", ")", ",...
Publishing from 2ed range category.
[ "Publishing", "from", "2ed", "range", "category", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/publish_handler.py#L88-L108
bukun/TorCMS
torcms/model/evaluation_model.py
MEvaluation.app_evaluation_count
def app_evaluation_count(app_id, value=1): ''' Get the Evalution sum. ''' return TabEvaluation.select().where( (TabEvaluation.post_id == app_id) & (TabEvaluation.value == value) ).count()
python
def app_evaluation_count(app_id, value=1): ''' Get the Evalution sum. ''' return TabEvaluation.select().where( (TabEvaluation.post_id == app_id) & (TabEvaluation.value == value) ).count()
[ "def", "app_evaluation_count", "(", "app_id", ",", "value", "=", "1", ")", ":", "return", "TabEvaluation", ".", "select", "(", ")", ".", "where", "(", "(", "TabEvaluation", ".", "post_id", "==", "app_id", ")", "&", "(", "TabEvaluation", ".", "value", "==...
Get the Evalution sum.
[ "Get", "the", "Evalution", "sum", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/evaluation_model.py#L17-L23
bukun/TorCMS
torcms/model/evaluation_model.py
MEvaluation.get_by_signature
def get_by_signature(user_id, app_id): ''' get by user ID, and app ID. ''' try: return TabEvaluation.get( (TabEvaluation.user_id == user_id) & (TabEvaluation.post_id == app_id) ) except: return None
python
def get_by_signature(user_id, app_id): ''' get by user ID, and app ID. ''' try: return TabEvaluation.get( (TabEvaluation.user_id == user_id) & (TabEvaluation.post_id == app_id) ) except: return None
[ "def", "get_by_signature", "(", "user_id", ",", "app_id", ")", ":", "try", ":", "return", "TabEvaluation", ".", "get", "(", "(", "TabEvaluation", ".", "user_id", "==", "user_id", ")", "&", "(", "TabEvaluation", ".", "post_id", "==", "app_id", ")", ")", "...
get by user ID, and app ID.
[ "get", "by", "user", "ID", "and", "app", "ID", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/evaluation_model.py#L26-L35
bukun/TorCMS
torcms/model/evaluation_model.py
MEvaluation.add_or_update
def add_or_update(user_id, app_id, value): ''' Editing evaluation. ''' rec = MEvaluation.get_by_signature(user_id, app_id) if rec: entry = TabEvaluation.update( value=value, ).where(TabEvaluation.uid == rec.uid) entry.execute() ...
python
def add_or_update(user_id, app_id, value): ''' Editing evaluation. ''' rec = MEvaluation.get_by_signature(user_id, app_id) if rec: entry = TabEvaluation.update( value=value, ).where(TabEvaluation.uid == rec.uid) entry.execute() ...
[ "def", "add_or_update", "(", "user_id", ",", "app_id", ",", "value", ")", ":", "rec", "=", "MEvaluation", ".", "get_by_signature", "(", "user_id", ",", "app_id", ")", "if", "rec", ":", "entry", "=", "TabEvaluation", ".", "update", "(", "value", "=", "val...
Editing evaluation.
[ "Editing", "evaluation", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/evaluation_model.py#L38-L54
bukun/TorCMS
ext/handler/ext_excel.py
ExtExcelHandler.index
def index(self): ''' Index funtion. ''' self.render('ext_excel/index.html', userinfo=self.userinfo, cfg=CMS_CFG, kwd={}, )
python
def index(self): ''' Index funtion. ''' self.render('ext_excel/index.html', userinfo=self.userinfo, cfg=CMS_CFG, kwd={}, )
[ "def", "index", "(", "self", ")", ":", "self", ".", "render", "(", "'ext_excel/index.html'", ",", "userinfo", "=", "self", ".", "userinfo", ",", "cfg", "=", "CMS_CFG", ",", "kwd", "=", "{", "}", ",", ")" ]
Index funtion.
[ "Index", "funtion", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/ext/handler/ext_excel.py#L31-L40
bukun/TorCMS
torcms/handlers/page_ajax_handler.py
PageAjaxHandler.view
def view(self, rec): ''' view the post. ''' out_json = { 'uid': rec.uid, 'time_update': rec.time_update, 'title': rec.title, 'cnt_html': tornado.escape.xhtml_unescape(rec.cnt_html), } self.write(json.dumps(out_json))
python
def view(self, rec): ''' view the post. ''' out_json = { 'uid': rec.uid, 'time_update': rec.time_update, 'title': rec.title, 'cnt_html': tornado.escape.xhtml_unescape(rec.cnt_html), } self.write(json.dumps(out_json))
[ "def", "view", "(", "self", ",", "rec", ")", ":", "out_json", "=", "{", "'uid'", ":", "rec", ".", "uid", ",", "'time_update'", ":", "rec", ".", "time_update", ",", "'title'", ":", "rec", ".", "title", ",", "'cnt_html'", ":", "tornado", ".", "escape",...
view the post.
[ "view", "the", "post", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/page_ajax_handler.py#L44-L55
bukun/TorCMS
torcms/handlers/page_ajax_handler.py
PageAjaxHandler.j_count_plus
def j_count_plus(self, slug): ''' plus count via ajax. ''' output = {'status': 1 if MWiki.view_count_plus(slug) else 0} return json.dump(output, self)
python
def j_count_plus(self, slug): ''' plus count via ajax. ''' output = {'status': 1 if MWiki.view_count_plus(slug) else 0} return json.dump(output, self)
[ "def", "j_count_plus", "(", "self", ",", "slug", ")", ":", "output", "=", "{", "'status'", ":", "1", "if", "MWiki", ".", "view_count_plus", "(", "slug", ")", "else", "0", "}", "return", "json", ".", "dump", "(", "output", ",", "self", ")" ]
plus count via ajax.
[ "plus", "count", "via", "ajax", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/page_ajax_handler.py#L61-L66
bukun/TorCMS
torcms/handlers/page_ajax_handler.py
PageAjaxHandler.p_list
def p_list(self, kind, cur_p='', ): ''' List the post . ''' if cur_p == '': current_page_number = 1 else: current_page_number = int(cur_p) current_page_number = 1 if current_page_number < 1 else current_page_number pager_num = int(MWiki.t...
python
def p_list(self, kind, cur_p='', ): ''' List the post . ''' if cur_p == '': current_page_number = 1 else: current_page_number = int(cur_p) current_page_number = 1 if current_page_number < 1 else current_page_number pager_num = int(MWiki.t...
[ "def", "p_list", "(", "self", ",", "kind", ",", "cur_p", "=", "''", ",", ")", ":", "if", "cur_p", "==", "''", ":", "current_page_number", "=", "1", "else", ":", "current_page_number", "=", "int", "(", "cur_p", ")", "current_page_number", "=", "1", "if"...
List the post .
[ "List", "the", "post", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/page_ajax_handler.py#L68-L92
bukun/TorCMS
torcms/model/user_model.py
MUser.set_sendemail_time
def set_sendemail_time(uid): ''' Set the time that send E-mail to user. ''' entry = TabMember.update( time_email=tools.timestamp(), ).where(TabMember.uid == uid) entry.execute()
python
def set_sendemail_time(uid): ''' Set the time that send E-mail to user. ''' entry = TabMember.update( time_email=tools.timestamp(), ).where(TabMember.uid == uid) entry.execute()
[ "def", "set_sendemail_time", "(", "uid", ")", ":", "entry", "=", "TabMember", ".", "update", "(", "time_email", "=", "tools", ".", "timestamp", "(", ")", ",", ")", ".", "where", "(", "TabMember", ".", "uid", "==", "uid", ")", "entry", ".", "execute", ...
Set the time that send E-mail to user.
[ "Set", "the", "time", "that", "send", "E", "-", "mail", "to", "user", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/user_model.py#L46-L53
bukun/TorCMS
torcms/model/user_model.py
MUser.check_user
def check_user(user_id, u_pass): ''' Checking the password by user's ID. ''' user_count = TabMember.select().where(TabMember.uid == user_id).count() if user_count == 0: return -1 the_user = TabMember.get(uid=user_id) if the_user.user_pass == tools.md5(...
python
def check_user(user_id, u_pass): ''' Checking the password by user's ID. ''' user_count = TabMember.select().where(TabMember.uid == user_id).count() if user_count == 0: return -1 the_user = TabMember.get(uid=user_id) if the_user.user_pass == tools.md5(...
[ "def", "check_user", "(", "user_id", ",", "u_pass", ")", ":", "user_count", "=", "TabMember", ".", "select", "(", ")", ".", "where", "(", "TabMember", ".", "uid", "==", "user_id", ")", ".", "count", "(", ")", "if", "user_count", "==", "0", ":", "retu...
Checking the password by user's ID.
[ "Checking", "the", "password", "by", "user", "s", "ID", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/user_model.py#L66-L76
bukun/TorCMS
torcms/model/user_model.py
MUser.check_user_by_name
def check_user_by_name(user_name, u_pass): ''' Checking the password by user's name. ''' the_query = TabMember.select().where(TabMember.user_name == user_name) if the_query.count() == 0: return -1 the_user = the_query.get() if the_user.user_pass == to...
python
def check_user_by_name(user_name, u_pass): ''' Checking the password by user's name. ''' the_query = TabMember.select().where(TabMember.user_name == user_name) if the_query.count() == 0: return -1 the_user = the_query.get() if the_user.user_pass == to...
[ "def", "check_user_by_name", "(", "user_name", ",", "u_pass", ")", ":", "the_query", "=", "TabMember", ".", "select", "(", ")", ".", "where", "(", "TabMember", ".", "user_name", "==", "user_name", ")", "if", "the_query", ".", "count", "(", ")", "==", "0"...
Checking the password by user's name.
[ "Checking", "the", "password", "by", "user", "s", "name", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/user_model.py#L79-L90
bukun/TorCMS
torcms/model/user_model.py
MUser.update_pass
def update_pass(user_id, newpass): ''' Update the password of a user. ''' out_dic = {'success': False, 'code': '00'} entry = TabMember.update(user_pass=tools.md5(newpass)).where(TabMember.uid == user_id) entry.execute() out_dic['success'] = True return...
python
def update_pass(user_id, newpass): ''' Update the password of a user. ''' out_dic = {'success': False, 'code': '00'} entry = TabMember.update(user_pass=tools.md5(newpass)).where(TabMember.uid == user_id) entry.execute() out_dic['success'] = True return...
[ "def", "update_pass", "(", "user_id", ",", "newpass", ")", ":", "out_dic", "=", "{", "'success'", ":", "False", ",", "'code'", ":", "'00'", "}", "entry", "=", "TabMember", ".", "update", "(", "user_pass", "=", "tools", ".", "md5", "(", "newpass", ")", ...
Update the password of a user.
[ "Update", "the", "password", "of", "a", "user", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/user_model.py#L93-L105
bukun/TorCMS
torcms/model/user_model.py
MUser.query_nologin
def query_nologin(): ''' Query the users who do not login recently (90 days). and not send email (120 days). time_model: num * month * hours * minite * second time_login: 3 * 30 * 24 * 60 * 60 time_email: 4 * 30 * 24 * 60 * 60 ''' time_now = tools.timestam...
python
def query_nologin(): ''' Query the users who do not login recently (90 days). and not send email (120 days). time_model: num * month * hours * minite * second time_login: 3 * 30 * 24 * 60 * 60 time_email: 4 * 30 * 24 * 60 * 60 ''' time_now = tools.timestam...
[ "def", "query_nologin", "(", ")", ":", "time_now", "=", "tools", ".", "timestamp", "(", ")", "return", "TabMember", ".", "select", "(", ")", ".", "where", "(", "(", "(", "time_now", "-", "TabMember", ".", "time_login", ")", ">", "7776000", ")", "&", ...
Query the users who do not login recently (90 days). and not send email (120 days). time_model: num * month * hours * minite * second time_login: 3 * 30 * 24 * 60 * 60 time_email: 4 * 30 * 24 * 60 * 60
[ "Query", "the", "users", "who", "do", "not", "login", "recently", "(", "90", "days", ")", ".", "and", "not", "send", "email", "(", "120", "days", ")", ".", "time_model", ":", "num", "*", "month", "*", "hours", "*", "minite", "*", "second", "time_logi...
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/user_model.py#L108-L120
bukun/TorCMS
torcms/model/user_model.py
MUser.update_info
def update_info(user_id, newemail, extinfo=None): ''' Update the user info by user_id. 21: standsfor invalide E-mail. 91: standsfor unkown reson. ''' if extinfo is None: extinfo = {} out_dic = {'success': False, 'code': '00'} if not tools.che...
python
def update_info(user_id, newemail, extinfo=None): ''' Update the user info by user_id. 21: standsfor invalide E-mail. 91: standsfor unkown reson. ''' if extinfo is None: extinfo = {} out_dic = {'success': False, 'code': '00'} if not tools.che...
[ "def", "update_info", "(", "user_id", ",", "newemail", ",", "extinfo", "=", "None", ")", ":", "if", "extinfo", "is", "None", ":", "extinfo", "=", "{", "}", "out_dic", "=", "{", "'success'", ":", "False", ",", "'code'", ":", "'00'", "}", "if", "not", ...
Update the user info by user_id. 21: standsfor invalide E-mail. 91: standsfor unkown reson.
[ "Update", "the", "user", "info", "by", "user_id", ".", "21", ":", "standsfor", "invalide", "E", "-", "mail", ".", "91", ":", "standsfor", "unkown", "reson", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/user_model.py#L123-L155
bukun/TorCMS
torcms/model/user_model.py
MUser.update_time_reset_passwd
def update_time_reset_passwd(user_name, the_time): ''' Update the time when user reset passwd. ''' entry = TabMember.update( time_reset_passwd=the_time, ).where(TabMember.user_name == user_name) try: entry.execute() return True ...
python
def update_time_reset_passwd(user_name, the_time): ''' Update the time when user reset passwd. ''' entry = TabMember.update( time_reset_passwd=the_time, ).where(TabMember.user_name == user_name) try: entry.execute() return True ...
[ "def", "update_time_reset_passwd", "(", "user_name", ",", "the_time", ")", ":", "entry", "=", "TabMember", ".", "update", "(", "time_reset_passwd", "=", "the_time", ",", ")", ".", "where", "(", "TabMember", ".", "user_name", "==", "user_name", ")", "try", ":...
Update the time when user reset passwd.
[ "Update", "the", "time", "when", "user", "reset", "passwd", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/user_model.py#L158-L169
bukun/TorCMS
torcms/model/user_model.py
MUser.update_role
def update_role(u_name, newprivilege): ''' Update the role of the usr. ''' entry = TabMember.update( role=newprivilege ).where(TabMember.user_name == u_name) try: entry.execute() return True except: return False
python
def update_role(u_name, newprivilege): ''' Update the role of the usr. ''' entry = TabMember.update( role=newprivilege ).where(TabMember.user_name == u_name) try: entry.execute() return True except: return False
[ "def", "update_role", "(", "u_name", ",", "newprivilege", ")", ":", "entry", "=", "TabMember", ".", "update", "(", "role", "=", "newprivilege", ")", ".", "where", "(", "TabMember", ".", "user_name", "==", "u_name", ")", "try", ":", "entry", ".", "execute...
Update the role of the usr.
[ "Update", "the", "role", "of", "the", "usr", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/user_model.py#L172-L183
bukun/TorCMS
torcms/model/user_model.py
MUser.update_time_login
def update_time_login(u_name): ''' Update the login time for user. ''' entry = TabMember.update( time_login=tools.timestamp() ).where( TabMember.user_name == u_name ) entry.execute()
python
def update_time_login(u_name): ''' Update the login time for user. ''' entry = TabMember.update( time_login=tools.timestamp() ).where( TabMember.user_name == u_name ) entry.execute()
[ "def", "update_time_login", "(", "u_name", ")", ":", "entry", "=", "TabMember", ".", "update", "(", "time_login", "=", "tools", ".", "timestamp", "(", ")", ")", ".", "where", "(", "TabMember", ".", "user_name", "==", "u_name", ")", "entry", ".", "execute...
Update the login time for user.
[ "Update", "the", "login", "time", "for", "user", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/user_model.py#L186-L195
bukun/TorCMS
torcms/model/user_model.py
MUser.create_user
def create_user(post_data): ''' Create the user. The code used if `False`. 11: standsfor invalid username. 21: standsfor invalide E-mail. 91: standsfor unkown reson. ''' out_dic = {'success': False, 'code': '00'} if not tools.check_username_valid(...
python
def create_user(post_data): ''' Create the user. The code used if `False`. 11: standsfor invalid username. 21: standsfor invalide E-mail. 91: standsfor unkown reson. ''' out_dic = {'success': False, 'code': '00'} if not tools.check_username_valid(...
[ "def", "create_user", "(", "post_data", ")", ":", "out_dic", "=", "{", "'success'", ":", "False", ",", "'code'", ":", "'00'", "}", "if", "not", "tools", ".", "check_username_valid", "(", "post_data", "[", "'user_name'", "]", ")", ":", "out_dic", "[", "'c...
Create the user. The code used if `False`. 11: standsfor invalid username. 21: standsfor invalide E-mail. 91: standsfor unkown reson.
[ "Create", "the", "user", ".", "The", "code", "used", "if", "False", ".", "11", ":", "standsfor", "invalid", "username", ".", "21", ":", "standsfor", "invalide", "E", "-", "mail", ".", "91", ":", "standsfor", "unkown", "reson", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/user_model.py#L198-L231
bukun/TorCMS
torcms/model/user_model.py
MUser.delete_by_user_name
def delete_by_user_name(user_name): ''' Delete user in the database by `user_name`. ''' try: del_count = TabMember.delete().where(TabMember.user_name == user_name) del_count.execute() return True except: return False
python
def delete_by_user_name(user_name): ''' Delete user in the database by `user_name`. ''' try: del_count = TabMember.delete().where(TabMember.user_name == user_name) del_count.execute() return True except: return False
[ "def", "delete_by_user_name", "(", "user_name", ")", ":", "try", ":", "del_count", "=", "TabMember", ".", "delete", "(", ")", ".", "where", "(", "TabMember", ".", "user_name", "==", "user_name", ")", "del_count", ".", "execute", "(", ")", "return", "True",...
Delete user in the database by `user_name`.
[ "Delete", "user", "in", "the", "database", "by", "user_name", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/user_model.py#L241-L250
bukun/TorCMS
torcms/model/user_model.py
MUser.delete
def delete(user_id): ''' Delele the user in the database by `user_id`. ''' try: del_count = TabMember.delete().where(TabMember.uid == user_id) del_count.execute() return True except: return False
python
def delete(user_id): ''' Delele the user in the database by `user_id`. ''' try: del_count = TabMember.delete().where(TabMember.uid == user_id) del_count.execute() return True except: return False
[ "def", "delete", "(", "user_id", ")", ":", "try", ":", "del_count", "=", "TabMember", ".", "delete", "(", ")", ".", "where", "(", "TabMember", ".", "uid", "==", "user_id", ")", "del_count", ".", "execute", "(", ")", "return", "True", "except", ":", "...
Delele the user in the database by `user_id`.
[ "Delele", "the", "user", "in", "the", "database", "by", "user_id", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/user_model.py#L253-L262
bukun/TorCMS
torcms/script/script_sitemap.py
gen_post_map
def gen_post_map(file_name, ext_url=''): ''' Generate the urls for posts. :return: None ''' with open(file_name, 'a') as fout: for kind_key in router_post: recent_posts = MPost.query_all(kind=kind_key, limit=1000000) for recent_post in recent_posts: ur...
python
def gen_post_map(file_name, ext_url=''): ''' Generate the urls for posts. :return: None ''' with open(file_name, 'a') as fout: for kind_key in router_post: recent_posts = MPost.query_all(kind=kind_key, limit=1000000) for recent_post in recent_posts: ur...
[ "def", "gen_post_map", "(", "file_name", ",", "ext_url", "=", "''", ")", ":", "with", "open", "(", "file_name", ",", "'a'", ")", "as", "fout", ":", "for", "kind_key", "in", "router_post", ":", "recent_posts", "=", "MPost", ".", "query_all", "(", "kind", ...
Generate the urls for posts. :return: None
[ "Generate", "the", "urls", "for", "posts", ".", ":", "return", ":", "None" ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/script/script_sitemap.py#L12-L25
bukun/TorCMS
torcms/script/script_sitemap.py
gen_wiki_map
def gen_wiki_map(file_name, ext_url=''): ''' Generate the urls for wiki. :return: None ''' # wiki wiki_recs = MWiki.query_all(limit=10000, kind='1') with open(file_name, 'a') as fileout: for rec in wiki_recs: url = os.path.join(SITE_CFG['site_url'], ...
python
def gen_wiki_map(file_name, ext_url=''): ''' Generate the urls for wiki. :return: None ''' # wiki wiki_recs = MWiki.query_all(limit=10000, kind='1') with open(file_name, 'a') as fileout: for rec in wiki_recs: url = os.path.join(SITE_CFG['site_url'], ...
[ "def", "gen_wiki_map", "(", "file_name", ",", "ext_url", "=", "''", ")", ":", "# wiki", "wiki_recs", "=", "MWiki", ".", "query_all", "(", "limit", "=", "10000", ",", "kind", "=", "'1'", ")", "with", "open", "(", "file_name", ",", "'a'", ")", "as", "f...
Generate the urls for wiki. :return: None
[ "Generate", "the", "urls", "for", "wiki", ".", ":", "return", ":", "None" ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/script/script_sitemap.py#L28-L53
bukun/TorCMS
torcms/script/script_sitemap.py
run_sitemap
def run_sitemap(_): ''' Generate the sitemap file. :param args: args :return: None ''' site_map_file = 'xx_sitemap.txt' if os.path.exists(site_map_file): os.remove(site_map_file) gen_wiki_map(site_map_file) gen_post_map(site_map_file)
python
def run_sitemap(_): ''' Generate the sitemap file. :param args: args :return: None ''' site_map_file = 'xx_sitemap.txt' if os.path.exists(site_map_file): os.remove(site_map_file) gen_wiki_map(site_map_file) gen_post_map(site_map_file)
[ "def", "run_sitemap", "(", "_", ")", ":", "site_map_file", "=", "'xx_sitemap.txt'", "if", "os", ".", "path", ".", "exists", "(", "site_map_file", ")", ":", "os", ".", "remove", "(", "site_map_file", ")", "gen_wiki_map", "(", "site_map_file", ")", "gen_post_m...
Generate the sitemap file. :param args: args :return: None
[ "Generate", "the", "sitemap", "file", ".", ":", "param", "args", ":", "args", ":", "return", ":", "None" ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/script/script_sitemap.py#L56-L67
bukun/TorCMS
torcms/script/script_sitemap.py
run_editmap
def run_editmap(_): ''' Generate the urls file for editing. :param args: args :return: None ''' edit_map_file = 'xx_editmap.txt' if os.path.exists(edit_map_file): os.remove(edit_map_file) gen_wiki_map(edit_map_file, ext_url='_edit') gen_post_map(edit_map_file, ext_url='_edit...
python
def run_editmap(_): ''' Generate the urls file for editing. :param args: args :return: None ''' edit_map_file = 'xx_editmap.txt' if os.path.exists(edit_map_file): os.remove(edit_map_file) gen_wiki_map(edit_map_file, ext_url='_edit') gen_post_map(edit_map_file, ext_url='_edit...
[ "def", "run_editmap", "(", "_", ")", ":", "edit_map_file", "=", "'xx_editmap.txt'", "if", "os", ".", "path", ".", "exists", "(", "edit_map_file", ")", ":", "os", ".", "remove", "(", "edit_map_file", ")", "gen_wiki_map", "(", "edit_map_file", ",", "ext_url", ...
Generate the urls file for editing. :param args: args :return: None
[ "Generate", "the", "urls", "file", "for", "editing", ".", ":", "param", "args", ":", "args", ":", "return", ":", "None" ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/script/script_sitemap.py#L70-L81
bukun/TorCMS
helper_scripts/script_meta_xlsx_import_v2.py
get_meta
def get_meta(catid, sig): ''' Get metadata of dataset via ID. ''' meta_base = './static/dataset_list' if os.path.exists(meta_base): pass else: return False pp_data = {'logo': '', 'kind': '9'} for wroot, wdirs, wfiles in os.walk(meta_base): for wdir in wdirs: ...
python
def get_meta(catid, sig): ''' Get metadata of dataset via ID. ''' meta_base = './static/dataset_list' if os.path.exists(meta_base): pass else: return False pp_data = {'logo': '', 'kind': '9'} for wroot, wdirs, wfiles in os.walk(meta_base): for wdir in wdirs: ...
[ "def", "get_meta", "(", "catid", ",", "sig", ")", ":", "meta_base", "=", "'./static/dataset_list'", "if", "os", ".", "path", ".", "exists", "(", "meta_base", ")", ":", "pass", "else", ":", "return", "False", "pp_data", "=", "{", "'logo'", ":", "''", ",...
Get metadata of dataset via ID.
[ "Get", "metadata", "of", "dataset", "via", "ID", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/helper_scripts/script_meta_xlsx_import_v2.py#L29-L59
bukun/TorCMS
torcms/handlers/post_handler.py
update_category
def update_category(uid, post_data): ''' Update the category of the post. :param uid: The ID of the post. Extra info would get by requests. ''' # deprecated # catid = kwargs['catid'] if MCategory.get_by_uid(kwargs.get('catid')) else None # post_data = self.get_post_data() if 'gcat0' in...
python
def update_category(uid, post_data): ''' Update the category of the post. :param uid: The ID of the post. Extra info would get by requests. ''' # deprecated # catid = kwargs['catid'] if MCategory.get_by_uid(kwargs.get('catid')) else None # post_data = self.get_post_data() if 'gcat0' in...
[ "def", "update_category", "(", "uid", ",", "post_data", ")", ":", "# deprecated", "# catid = kwargs['catid'] if MCategory.get_by_uid(kwargs.get('catid')) else None", "# post_data = self.get_post_data()", "if", "'gcat0'", "in", "post_data", ":", "pass", "else", ":", "return", ...
Update the category of the post. :param uid: The ID of the post. Extra info would get by requests.
[ "Update", "the", "category", "of", "the", "post", ".", ":", "param", "uid", ":", "The", "ID", "of", "the", "post", ".", "Extra", "info", "would", "get", "by", "requests", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_handler.py#L30-L90
bukun/TorCMS
torcms/handlers/post_handler.py
update_label
def update_label(signature, post_data): ''' Update the label when updating. ''' current_tag_infos = MPost2Label.get_by_uid(signature).objects() if 'tags' in post_data: pass else: return False tags_arr = [x.strip() for x in post_data['tags'].split(',')] for tag_name in ta...
python
def update_label(signature, post_data): ''' Update the label when updating. ''' current_tag_infos = MPost2Label.get_by_uid(signature).objects() if 'tags' in post_data: pass else: return False tags_arr = [x.strip() for x in post_data['tags'].split(',')] for tag_name in ta...
[ "def", "update_label", "(", "signature", ",", "post_data", ")", ":", "current_tag_infos", "=", "MPost2Label", ".", "get_by_uid", "(", "signature", ")", ".", "objects", "(", ")", "if", "'tags'", "in", "post_data", ":", "pass", "else", ":", "return", "False", ...
Update the label when updating.
[ "Update", "the", "label", "when", "updating", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_handler.py#L93-L114
bukun/TorCMS
torcms/handlers/post_handler.py
PostHandler.index
def index(self): ''' The default page of POST. ''' self.render('post_{0}/post_index.html'.format(self.kind), userinfo=self.userinfo, kwd={'uid': '', })
python
def index(self): ''' The default page of POST. ''' self.render('post_{0}/post_index.html'.format(self.kind), userinfo=self.userinfo, kwd={'uid': '', })
[ "def", "index", "(", "self", ")", ":", "self", ".", "render", "(", "'post_{0}/post_index.html'", ".", "format", "(", "self", ".", "kind", ")", ",", "userinfo", "=", "self", ".", "userinfo", ",", "kwd", "=", "{", "'uid'", ":", "''", ",", "}", ")" ]
The default page of POST.
[ "The", "default", "page", "of", "POST", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_handler.py#L182-L188
bukun/TorCMS
torcms/handlers/post_handler.py
PostHandler._gen_uid
def _gen_uid(self): ''' Generate the ID for post. :return: the new ID. ''' cur_uid = self.kind + tools.get_uu4d() while MPost.get_by_uid(cur_uid): cur_uid = self.kind + tools.get_uu4d() return cur_uid
python
def _gen_uid(self): ''' Generate the ID for post. :return: the new ID. ''' cur_uid = self.kind + tools.get_uu4d() while MPost.get_by_uid(cur_uid): cur_uid = self.kind + tools.get_uu4d() return cur_uid
[ "def", "_gen_uid", "(", "self", ")", ":", "cur_uid", "=", "self", ".", "kind", "+", "tools", ".", "get_uu4d", "(", ")", "while", "MPost", ".", "get_by_uid", "(", "cur_uid", ")", ":", "cur_uid", "=", "self", ".", "kind", "+", "tools", ".", "get_uu4d",...
Generate the ID for post. :return: the new ID.
[ "Generate", "the", "ID", "for", "post", ".", ":", "return", ":", "the", "new", "ID", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_handler.py#L190-L198
bukun/TorCMS
torcms/handlers/post_handler.py
PostHandler._get_tmpl_view
def _get_tmpl_view(self, rec): ''' According to the application, each info of it's classification could has different temaplate. :param rec: the App record. :return: the temaplte path. ''' if 'def_cat_uid' in rec.extinfo and rec.extinfo['def_cat_uid'] != '': ...
python
def _get_tmpl_view(self, rec): ''' According to the application, each info of it's classification could has different temaplate. :param rec: the App record. :return: the temaplte path. ''' if 'def_cat_uid' in rec.extinfo and rec.extinfo['def_cat_uid'] != '': ...
[ "def", "_get_tmpl_view", "(", "self", ",", "rec", ")", ":", "if", "'def_cat_uid'", "in", "rec", ".", "extinfo", "and", "rec", ".", "extinfo", "[", "'def_cat_uid'", "]", "!=", "''", ":", "cat_id", "=", "rec", ".", "extinfo", "[", "'def_cat_uid'", "]", "...
According to the application, each info of it's classification could has different temaplate. :param rec: the App record. :return: the temaplte path.
[ "According", "to", "the", "application", "each", "info", "of", "it", "s", "classification", "could", "has", "different", "temaplate", ".", ":", "param", "rec", ":", "the", "App", "record", ".", ":", "return", ":", "the", "temaplte", "path", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_handler.py#L200-L221
bukun/TorCMS
torcms/handlers/post_handler.py
PostHandler._to_add_with_category
def _to_add_with_category(self, catid): ''' Used for info2. :param catid: the uid of category ''' catinfo = MCategory.get_by_uid(catid) kwd = { 'uid': self._gen_uid(), 'userid': self.userinfo.user_name if self.userinfo else '', 'gcat0'...
python
def _to_add_with_category(self, catid): ''' Used for info2. :param catid: the uid of category ''' catinfo = MCategory.get_by_uid(catid) kwd = { 'uid': self._gen_uid(), 'userid': self.userinfo.user_name if self.userinfo else '', 'gcat0'...
[ "def", "_to_add_with_category", "(", "self", ",", "catid", ")", ":", "catinfo", "=", "MCategory", ".", "get_by_uid", "(", "catid", ")", "kwd", "=", "{", "'uid'", ":", "self", ".", "_gen_uid", "(", ")", ",", "'userid'", ":", "self", ".", "userinfo", "."...
Used for info2. :param catid: the uid of category
[ "Used", "for", "info2", ".", ":", "param", "catid", ":", "the", "uid", "of", "category" ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_handler.py#L225-L242
bukun/TorCMS
torcms/handlers/post_handler.py
PostHandler._view_or_add
def _view_or_add(self, uid): ''' Try to get the post. If not, to add the wiki. ''' postinfo = MPost.get_by_uid(uid) if postinfo: self.viewinfo(postinfo) elif self.userinfo: self._to_add(uid=uid) else: self.show404()
python
def _view_or_add(self, uid): ''' Try to get the post. If not, to add the wiki. ''' postinfo = MPost.get_by_uid(uid) if postinfo: self.viewinfo(postinfo) elif self.userinfo: self._to_add(uid=uid) else: self.show404()
[ "def", "_view_or_add", "(", "self", ",", "uid", ")", ":", "postinfo", "=", "MPost", ".", "get_by_uid", "(", "uid", ")", "if", "postinfo", ":", "self", ".", "viewinfo", "(", "postinfo", ")", "elif", "self", ".", "userinfo", ":", "self", ".", "_to_add", ...
Try to get the post. If not, to add the wiki.
[ "Try", "to", "get", "the", "post", ".", "If", "not", "to", "add", "the", "wiki", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_handler.py#L244-L254
bukun/TorCMS
torcms/handlers/post_handler.py
PostHandler._to_add
def _to_add(self, **kwargs): ''' Used for info1. ''' if 'catid' in kwargs: catid = kwargs['catid'] return self._to_add_with_category(catid) else: if 'uid' in kwargs and MPost.get_by_uid(kwargs['uid']): # todo: ...
python
def _to_add(self, **kwargs): ''' Used for info1. ''' if 'catid' in kwargs: catid = kwargs['catid'] return self._to_add_with_category(catid) else: if 'uid' in kwargs and MPost.get_by_uid(kwargs['uid']): # todo: ...
[ "def", "_to_add", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "'catid'", "in", "kwargs", ":", "catid", "=", "kwargs", "[", "'catid'", "]", "return", "self", ".", "_to_add_with_category", "(", "catid", ")", "else", ":", "if", "'uid'", "in", ...
Used for info1.
[ "Used", "for", "info1", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_handler.py#L258-L277
bukun/TorCMS
torcms/handlers/post_handler.py
PostHandler._to_edit
def _to_edit(self, infoid): ''' render the HTML page for post editing. ''' postinfo = MPost.get_by_uid(infoid) if postinfo: pass else: return self.show404() if 'def_cat_uid' in postinfo.extinfo: catid = postinfo.extinfo['def_...
python
def _to_edit(self, infoid): ''' render the HTML page for post editing. ''' postinfo = MPost.get_by_uid(infoid) if postinfo: pass else: return self.show404() if 'def_cat_uid' in postinfo.extinfo: catid = postinfo.extinfo['def_...
[ "def", "_to_edit", "(", "self", ",", "infoid", ")", ":", "postinfo", "=", "MPost", ".", "get_by_uid", "(", "infoid", ")", "if", "postinfo", ":", "pass", "else", ":", "return", "self", ".", "show404", "(", ")", "if", "'def_cat_uid'", "in", "postinfo", "...
render the HTML page for post editing.
[ "render", "the", "HTML", "page", "for", "post", "editing", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_handler.py#L281-L343
bukun/TorCMS
torcms/handlers/post_handler.py
PostHandler._gen_last_current_relation
def _gen_last_current_relation(self, post_id): ''' Generate the relation for the post and last post viewed. ''' last_post_id = self.get_secure_cookie('last_post_uid') if last_post_id: last_post_id = last_post_id.decode('utf-8') self.set_secure_cookie('last_pos...
python
def _gen_last_current_relation(self, post_id): ''' Generate the relation for the post and last post viewed. ''' last_post_id = self.get_secure_cookie('last_post_uid') if last_post_id: last_post_id = last_post_id.decode('utf-8') self.set_secure_cookie('last_pos...
[ "def", "_gen_last_current_relation", "(", "self", ",", "post_id", ")", ":", "last_post_id", "=", "self", ".", "get_secure_cookie", "(", "'last_post_uid'", ")", "if", "last_post_id", ":", "last_post_id", "=", "last_post_id", ".", "decode", "(", "'utf-8'", ")", "s...
Generate the relation for the post and last post viewed.
[ "Generate", "the", "relation", "for", "the", "post", "and", "last", "post", "viewed", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_handler.py#L345-L355
bukun/TorCMS
torcms/handlers/post_handler.py
PostHandler.redirect_kind
def redirect_kind(self, postinfo): ''' Redirect according the kind of the post. :param postinfo: the postinfo :return: None ''' logger.warning('info kind:{0} '.format(postinfo.kind)) # If not, there must be something wrong. if postinfo.kind == self.kind: ...
python
def redirect_kind(self, postinfo): ''' Redirect according the kind of the post. :param postinfo: the postinfo :return: None ''' logger.warning('info kind:{0} '.format(postinfo.kind)) # If not, there must be something wrong. if postinfo.kind == self.kind: ...
[ "def", "redirect_kind", "(", "self", ",", "postinfo", ")", ":", "logger", ".", "warning", "(", "'info kind:{0} '", ".", "format", "(", "postinfo", ".", "kind", ")", ")", "# If not, there must be something wrong.", "if", "postinfo", ".", "kind", "==", "self", "...
Redirect according the kind of the post. :param postinfo: the postinfo :return: None
[ "Redirect", "according", "the", "kind", "of", "the", "post", ".", ":", "param", "postinfo", ":", "the", "postinfo", ":", "return", ":", "None" ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_handler.py#L357-L370
bukun/TorCMS
torcms/handlers/post_handler.py
PostHandler.viewinfo
def viewinfo(self, postinfo): ''' In infor. ''' self.redirect_kind(postinfo) # ToDo: 原为下面代码。 # ext_catid = postinfo.extinfo['def_cat_uid'] if 'def_cat_uid' in postinfo.extinfo else '' # ext_catid2 = postinfo.extinfo['def_cat_uid'] if 'def_cat_uid' in postinfo.ext...
python
def viewinfo(self, postinfo): ''' In infor. ''' self.redirect_kind(postinfo) # ToDo: 原为下面代码。 # ext_catid = postinfo.extinfo['def_cat_uid'] if 'def_cat_uid' in postinfo.extinfo else '' # ext_catid2 = postinfo.extinfo['def_cat_uid'] if 'def_cat_uid' in postinfo.ext...
[ "def", "viewinfo", "(", "self", ",", "postinfo", ")", ":", "self", ".", "redirect_kind", "(", "postinfo", ")", "# ToDo: 原为下面代码。", "# ext_catid = postinfo.extinfo['def_cat_uid'] if 'def_cat_uid' in postinfo.extinfo else ''", "# ext_catid2 = postinfo.extinfo['def_cat_uid'] if 'def_cat_...
In infor.
[ "In", "infor", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_handler.py#L373-L429
bukun/TorCMS
torcms/handlers/post_handler.py
PostHandler._the_view_kwd
def _the_view_kwd(self, postinfo): ''' Generate the kwd dict for view. :param postinfo: the postinfo :return: dict ''' kwd = { 'pager': '', 'url': self.request.uri, 'cookie_str': tools.get_uuid(), 'daohangstr': '', ...
python
def _the_view_kwd(self, postinfo): ''' Generate the kwd dict for view. :param postinfo: the postinfo :return: dict ''' kwd = { 'pager': '', 'url': self.request.uri, 'cookie_str': tools.get_uuid(), 'daohangstr': '', ...
[ "def", "_the_view_kwd", "(", "self", ",", "postinfo", ")", ":", "kwd", "=", "{", "'pager'", ":", "''", ",", "'url'", ":", "self", ".", "request", ".", "uri", ",", "'cookie_str'", ":", "tools", ".", "get_uuid", "(", ")", ",", "'daohangstr'", ":", "''"...
Generate the kwd dict for view. :param postinfo: the postinfo :return: dict
[ "Generate", "the", "kwd", "dict", "for", "view", ".", ":", "param", "postinfo", ":", "the", "postinfo", ":", "return", ":", "dict" ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_handler.py#L431-L453
bukun/TorCMS
torcms/handlers/post_handler.py
PostHandler.fetch_additional_posts
def fetch_additional_posts(self, uid): ''' fetch the rel_recs, and random recs when view the post. ''' cats = MPost2Catalog.query_by_entity_uid(uid, kind=self.kind) cat_uid_arr = [] for cat_rec in cats: cat_uid = cat_rec.tag_id cat_uid_arr.append(c...
python
def fetch_additional_posts(self, uid): ''' fetch the rel_recs, and random recs when view the post. ''' cats = MPost2Catalog.query_by_entity_uid(uid, kind=self.kind) cat_uid_arr = [] for cat_rec in cats: cat_uid = cat_rec.tag_id cat_uid_arr.append(c...
[ "def", "fetch_additional_posts", "(", "self", ",", "uid", ")", ":", "cats", "=", "MPost2Catalog", ".", "query_by_entity_uid", "(", "uid", ",", "kind", "=", "self", ".", "kind", ")", "cat_uid_arr", "=", "[", "]", "for", "cat_rec", "in", "cats", ":", "cat_...
fetch the rel_recs, and random recs when view the post.
[ "fetch", "the", "rel_recs", "and", "random", "recs", "when", "view", "the", "post", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_handler.py#L455-L472
bukun/TorCMS
torcms/handlers/post_handler.py
PostHandler._add_relation
def _add_relation(self, f_uid, t_uid): ''' Add the relation. And the from and to, should have different weight. :param f_uid: the uid of `from` post. :param t_uid: the uid of `to` post. :return: return True if the relation has been succesfully added. ''' if not MP...
python
def _add_relation(self, f_uid, t_uid): ''' Add the relation. And the from and to, should have different weight. :param f_uid: the uid of `from` post. :param t_uid: the uid of `to` post. :return: return True if the relation has been succesfully added. ''' if not MP...
[ "def", "_add_relation", "(", "self", ",", "f_uid", ",", "t_uid", ")", ":", "if", "not", "MPost", ".", "get_by_uid", "(", "t_uid", ")", ":", "return", "False", "if", "f_uid", "==", "t_uid", ":", "return", "False", "# 针对分类进行处理。只有落入相同分类的,才加1", "f_cats", "=", ...
Add the relation. And the from and to, should have different weight. :param f_uid: the uid of `from` post. :param t_uid: the uid of `to` post. :return: return True if the relation has been succesfully added.
[ "Add", "the", "relation", ".", "And", "the", "from", "and", "to", "should", "have", "different", "weight", ".", ":", "param", "f_uid", ":", "the", "uid", "of", "from", "post", ".", ":", "param", "t_uid", ":", "the", "uid", "of", "to", "post", ".", ...
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_handler.py#L474-L501
bukun/TorCMS
torcms/handlers/post_handler.py
PostHandler.fetch_post_data
def fetch_post_data(self): ''' fetch post accessed data. post_data, and ext_dic. ''' post_data = {} ext_dic = {} for key in self.request.arguments: if key.startswith('ext_') or key.startswith('tag_'): ext_dic[key] = self.get_argument(key) ...
python
def fetch_post_data(self): ''' fetch post accessed data. post_data, and ext_dic. ''' post_data = {} ext_dic = {} for key in self.request.arguments: if key.startswith('ext_') or key.startswith('tag_'): ext_dic[key] = self.get_argument(key) ...
[ "def", "fetch_post_data", "(", "self", ")", ":", "post_data", "=", "{", "}", "ext_dic", "=", "{", "}", "for", "key", "in", "self", ".", "request", ".", "arguments", ":", "if", "key", ".", "startswith", "(", "'ext_'", ")", "or", "key", ".", "startswit...
fetch post accessed data. post_data, and ext_dic.
[ "fetch", "post", "accessed", "data", ".", "post_data", "and", "ext_dic", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_handler.py#L503-L525
bukun/TorCMS
torcms/handlers/post_handler.py
PostHandler.add
def add(self, **kwargs): ''' in infor. ''' if 'uid' in kwargs: uid = kwargs['uid'] else: uid = self._gen_uid() post_data, ext_dic = self.fetch_post_data() if 'gcat0' in post_data: pass else: return False ...
python
def add(self, **kwargs): ''' in infor. ''' if 'uid' in kwargs: uid = kwargs['uid'] else: uid = self._gen_uid() post_data, ext_dic = self.fetch_post_data() if 'gcat0' in post_data: pass else: return False ...
[ "def", "add", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "'uid'", "in", "kwargs", ":", "uid", "=", "kwargs", "[", "'uid'", "]", "else", ":", "uid", "=", "self", ".", "_gen_uid", "(", ")", "post_data", ",", "ext_dic", "=", "self", ".", ...
in infor.
[ "in", "infor", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_handler.py#L531-L570
bukun/TorCMS
torcms/handlers/post_handler.py
PostHandler.update
def update(self, uid): ''' in infor. ''' postinfo = MPost.get_by_uid(uid) if postinfo.kind == self.kind: pass else: return False post_data, ext_dic = self.fetch_post_data() if 'gcat0' in post_data: pass else: ...
python
def update(self, uid): ''' in infor. ''' postinfo = MPost.get_by_uid(uid) if postinfo.kind == self.kind: pass else: return False post_data, ext_dic = self.fetch_post_data() if 'gcat0' in post_data: pass else: ...
[ "def", "update", "(", "self", ",", "uid", ")", ":", "postinfo", "=", "MPost", ".", "get_by_uid", "(", "uid", ")", "if", "postinfo", ".", "kind", "==", "self", ".", "kind", ":", "pass", "else", ":", "return", "False", "post_data", ",", "ext_dic", "=",...
in infor.
[ "in", "infor", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_handler.py#L575-L618
bukun/TorCMS
torcms/handlers/post_handler.py
PostHandler._delete
def _delete(self, *args, **kwargs): ''' delete the post. ''' _ = kwargs uid = args[0] current_infor = MPost.get_by_uid(uid) if MPost.delete(uid): tslug = MCategory.get_by_uid(current_infor.extinfo['def_cat_uid']) MCategory.update_count(c...
python
def _delete(self, *args, **kwargs): ''' delete the post. ''' _ = kwargs uid = args[0] current_infor = MPost.get_by_uid(uid) if MPost.delete(uid): tslug = MCategory.get_by_uid(current_infor.extinfo['def_cat_uid']) MCategory.update_count(c...
[ "def", "_delete", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "_", "=", "kwargs", "uid", "=", "args", "[", "0", "]", "current_infor", "=", "MPost", ".", "get_by_uid", "(", "uid", ")", "if", "MPost", ".", "delete", "(", "uid"...
delete the post.
[ "delete", "the", "post", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_handler.py#L622-L647
bukun/TorCMS
torcms/handlers/post_handler.py
PostHandler._chuli_cookie_relation
def _chuli_cookie_relation(self, app_id): ''' The current Info and the Info viewed last should have some relation. And the last viewed Info could be found from cookie. ''' last_app_uid = self.get_secure_cookie('use_app_uid') if last_app_uid: last_app_uid = las...
python
def _chuli_cookie_relation(self, app_id): ''' The current Info and the Info viewed last should have some relation. And the last viewed Info could be found from cookie. ''' last_app_uid = self.get_secure_cookie('use_app_uid') if last_app_uid: last_app_uid = las...
[ "def", "_chuli_cookie_relation", "(", "self", ",", "app_id", ")", ":", "last_app_uid", "=", "self", ".", "get_secure_cookie", "(", "'use_app_uid'", ")", "if", "last_app_uid", ":", "last_app_uid", "=", "last_app_uid", ".", "decode", "(", "'utf-8'", ")", "self", ...
The current Info and the Info viewed last should have some relation. And the last viewed Info could be found from cookie.
[ "The", "current", "Info", "and", "the", "Info", "viewed", "last", "should", "have", "some", "relation", ".", "And", "the", "last", "viewed", "Info", "could", "be", "found", "from", "cookie", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_handler.py#L649-L659
bukun/TorCMS
torcms/handlers/post_handler.py
PostHandler._to_edit_kind
def _to_edit_kind(self, post_uid): ''' Show the page for changing the category. ''' if self.userinfo and self.userinfo.role[1] >= '3': pass else: self.redirect('/') postinfo = MPost.get_by_uid(post_uid, ) json_cnt = json.dumps(postinfo.exti...
python
def _to_edit_kind(self, post_uid): ''' Show the page for changing the category. ''' if self.userinfo and self.userinfo.role[1] >= '3': pass else: self.redirect('/') postinfo = MPost.get_by_uid(post_uid, ) json_cnt = json.dumps(postinfo.exti...
[ "def", "_to_edit_kind", "(", "self", ",", "post_uid", ")", ":", "if", "self", ".", "userinfo", "and", "self", ".", "userinfo", ".", "role", "[", "1", "]", ">=", "'3'", ":", "pass", "else", ":", "self", ".", "redirect", "(", "'/'", ")", "postinfo", ...
Show the page for changing the category.
[ "Show", "the", "page", "for", "changing", "the", "category", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_handler.py#L691-L707
bukun/TorCMS
torcms/handlers/post_handler.py
PostHandler._change_kind
def _change_kind(self, post_uid): ''' To modify the category of the post, and kind. ''' post_data = self.get_post_data() logger.info('admin post update: {0}'.format(post_data)) MPost.update_misc(post_uid, kind=post_data['kcat']) # self.update_category(post_uid)...
python
def _change_kind(self, post_uid): ''' To modify the category of the post, and kind. ''' post_data = self.get_post_data() logger.info('admin post update: {0}'.format(post_data)) MPost.update_misc(post_uid, kind=post_data['kcat']) # self.update_category(post_uid)...
[ "def", "_change_kind", "(", "self", ",", "post_uid", ")", ":", "post_data", "=", "self", ".", "get_post_data", "(", ")", "logger", ".", "info", "(", "'admin post update: {0}'", ".", "format", "(", "post_data", ")", ")", "MPost", ".", "update_misc", "(", "p...
To modify the category of the post, and kind.
[ "To", "modify", "the", "category", "of", "the", "post", "and", "kind", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/post_handler.py#L711-L724
bukun/TorCMS
torcms/handlers/entity_handler.py
EntityHandler.list
def list(self, cur_p=''): ''' Lists of the entities. ''' current_page_number = int(cur_p) if cur_p else 1 current_page_number = 1 if current_page_number < 1 else current_page_number kwd = { 'current_page': current_page_number } recs = MEntity....
python
def list(self, cur_p=''): ''' Lists of the entities. ''' current_page_number = int(cur_p) if cur_p else 1 current_page_number = 1 if current_page_number < 1 else current_page_number kwd = { 'current_page': current_page_number } recs = MEntity....
[ "def", "list", "(", "self", ",", "cur_p", "=", "''", ")", ":", "current_page_number", "=", "int", "(", "cur_p", ")", "if", "cur_p", "else", "1", "current_page_number", "=", "1", "if", "current_page_number", "<", "1", "else", "current_page_number", "kwd", "...
Lists of the entities.
[ "Lists", "of", "the", "entities", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/entity_handler.py#L71-L86
bukun/TorCMS
torcms/handlers/entity_handler.py
EntityHandler.down
def down(self, down_uid): ''' Download the entity by UID. ''' down_url = MPost.get_by_uid(down_uid).extinfo.get('tag__file_download', '') print('=' * 40) print(down_url) str_down_url = str(down_url)[15:] if down_url: ment_id = MEntity.get_id_...
python
def down(self, down_uid): ''' Download the entity by UID. ''' down_url = MPost.get_by_uid(down_uid).extinfo.get('tag__file_download', '') print('=' * 40) print(down_url) str_down_url = str(down_url)[15:] if down_url: ment_id = MEntity.get_id_...
[ "def", "down", "(", "self", ",", "down_uid", ")", ":", "down_url", "=", "MPost", ".", "get_by_uid", "(", "down_uid", ")", ".", "extinfo", ".", "get", "(", "'tag__file_download'", ",", "''", ")", "print", "(", "'='", "*", "40", ")", "print", "(", "dow...
Download the entity by UID.
[ "Download", "the", "entity", "by", "UID", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/entity_handler.py#L89-L105
bukun/TorCMS
torcms/handlers/entity_handler.py
EntityHandler.to_add
def to_add(self): ''' To add the entity. ''' kwd = { 'pager': '', } self.render('misc/entity/entity_add.html', cfg=config.CMS_CFG, kwd=kwd, userinfo=self.userinfo)
python
def to_add(self): ''' To add the entity. ''' kwd = { 'pager': '', } self.render('misc/entity/entity_add.html', cfg=config.CMS_CFG, kwd=kwd, userinfo=self.userinfo)
[ "def", "to_add", "(", "self", ")", ":", "kwd", "=", "{", "'pager'", ":", "''", ",", "}", "self", ".", "render", "(", "'misc/entity/entity_add.html'", ",", "cfg", "=", "config", ".", "CMS_CFG", ",", "kwd", "=", "kwd", ",", "userinfo", "=", "self", "."...
To add the entity.
[ "To", "add", "the", "entity", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/entity_handler.py#L108-L118
bukun/TorCMS
torcms/handlers/entity_handler.py
EntityHandler.add_entity
def add_entity(self): ''' Add the entity. All the information got from the post data. ''' post_data = self.get_post_data() if 'kind' in post_data: if post_data['kind'] == '1': self.add_pic(post_data) elif post_data['kind'] == '2': ...
python
def add_entity(self): ''' Add the entity. All the information got from the post data. ''' post_data = self.get_post_data() if 'kind' in post_data: if post_data['kind'] == '1': self.add_pic(post_data) elif post_data['kind'] == '2': ...
[ "def", "add_entity", "(", "self", ")", ":", "post_data", "=", "self", ".", "get_post_data", "(", ")", "if", "'kind'", "in", "post_data", ":", "if", "post_data", "[", "'kind'", "]", "==", "'1'", ":", "self", ".", "add_pic", "(", "post_data", ")", "elif"...
Add the entity. All the information got from the post data.
[ "Add", "the", "entity", ".", "All", "the", "information", "got", "from", "the", "post", "data", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/entity_handler.py#L121-L137
bukun/TorCMS
torcms/handlers/entity_handler.py
EntityHandler.add_pic
def add_pic(self, post_data): ''' Adding the picture. ''' img_entity = self.request.files['file'][0] filename = img_entity["filename"] if filename and allowed_file(filename): pass else: return False _, hou = os.path.splitext(filen...
python
def add_pic(self, post_data): ''' Adding the picture. ''' img_entity = self.request.files['file'][0] filename = img_entity["filename"] if filename and allowed_file(filename): pass else: return False _, hou = os.path.splitext(filen...
[ "def", "add_pic", "(", "self", ",", "post_data", ")", ":", "img_entity", "=", "self", ".", "request", ".", "files", "[", "'file'", "]", "[", "0", "]", "filename", "=", "img_entity", "[", "\"filename\"", "]", "if", "filename", "and", "allowed_file", "(", ...
Adding the picture.
[ "Adding", "the", "picture", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/entity_handler.py#L140-L193
bukun/TorCMS
torcms/handlers/entity_handler.py
EntityHandler.add_pdf
def add_pdf(self, post_data): ''' Adding the pdf file. ''' img_entity = self.request.files['file'][0] img_desc = post_data['desc'] filename = img_entity["filename"] if filename and allowed_file_pdf(filename): pass else: return Fal...
python
def add_pdf(self, post_data): ''' Adding the pdf file. ''' img_entity = self.request.files['file'][0] img_desc = post_data['desc'] filename = img_entity["filename"] if filename and allowed_file_pdf(filename): pass else: return Fal...
[ "def", "add_pdf", "(", "self", ",", "post_data", ")", ":", "img_entity", "=", "self", ".", "request", ".", "files", "[", "'file'", "]", "[", "0", "]", "img_desc", "=", "post_data", "[", "'desc'", "]", "filename", "=", "img_entity", "[", "\"filename\"", ...
Adding the pdf file.
[ "Adding", "the", "pdf", "file", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/entity_handler.py#L196-L232
bukun/TorCMS
torcms/handlers/entity_handler.py
EntityHandler.add_url
def add_url(self, post_data): ''' Adding the URL as entity. ''' img_desc = post_data['desc'] img_path = post_data['file1'] cur_uid = tools.get_uudd(4) while MEntity.get_by_uid(cur_uid): cur_uid = tools.get_uudd(4) MEntity.create_entity(cur_uid,...
python
def add_url(self, post_data): ''' Adding the URL as entity. ''' img_desc = post_data['desc'] img_path = post_data['file1'] cur_uid = tools.get_uudd(4) while MEntity.get_by_uid(cur_uid): cur_uid = tools.get_uudd(4) MEntity.create_entity(cur_uid,...
[ "def", "add_url", "(", "self", ",", "post_data", ")", ":", "img_desc", "=", "post_data", "[", "'desc'", "]", "img_path", "=", "post_data", "[", "'file1'", "]", "cur_uid", "=", "tools", ".", "get_uudd", "(", "4", ")", "while", "MEntity", ".", "get_by_uid"...
Adding the URL as entity.
[ "Adding", "the", "URL", "as", "entity", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/entity_handler.py#L235-L253
bukun/TorCMS
torcms/handlers/user_handler.py
UserHandler.p_changepassword
def p_changepassword(self): ''' Changing password. ''' post_data = self.get_post_data() usercheck = MUser.check_user(self.userinfo.uid, post_data['rawpass']) if usercheck == 1: MUser.update_pass(self.userinfo.uid, post_data['user_pass']) output =...
python
def p_changepassword(self): ''' Changing password. ''' post_data = self.get_post_data() usercheck = MUser.check_user(self.userinfo.uid, post_data['rawpass']) if usercheck == 1: MUser.update_pass(self.userinfo.uid, post_data['user_pass']) output =...
[ "def", "p_changepassword", "(", "self", ")", ":", "post_data", "=", "self", ".", "get_post_data", "(", ")", "usercheck", "=", "MUser", ".", "check_user", "(", "self", ".", "userinfo", ".", "uid", ",", "post_data", "[", "'rawpass'", "]", ")", "if", "userc...
Changing password.
[ "Changing", "password", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/user_handler.py#L120-L133
bukun/TorCMS
torcms/handlers/user_handler.py
UserHandler.p_changeinfo
def p_changeinfo(self): ''' Change Infor via Ajax. ''' post_data, def_dic = self.fetch_post_data() usercheck = MUser.check_user(self.userinfo.uid, post_data['rawpass']) if usercheck == 1: MUser.update_info(self.userinfo.uid, post_data['user_email'], extinfo=...
python
def p_changeinfo(self): ''' Change Infor via Ajax. ''' post_data, def_dic = self.fetch_post_data() usercheck = MUser.check_user(self.userinfo.uid, post_data['rawpass']) if usercheck == 1: MUser.update_info(self.userinfo.uid, post_data['user_email'], extinfo=...
[ "def", "p_changeinfo", "(", "self", ")", ":", "post_data", ",", "def_dic", "=", "self", ".", "fetch_post_data", "(", ")", "usercheck", "=", "MUser", ".", "check_user", "(", "self", ".", "userinfo", ".", "uid", ",", "post_data", "[", "'rawpass'", "]", ")"...
Change Infor via Ajax.
[ "Change", "Infor", "via", "Ajax", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/user_handler.py#L136-L149
bukun/TorCMS
torcms/handlers/user_handler.py
UserHandler.fetch_post_data
def fetch_post_data(self): ''' fetch post accessed data. post_data, and ext_dic. ''' post_data = {} ext_dic = {} for key in self.request.arguments: if key.startswith('def_'): ext_dic[key] = self.get_argument(key) else: ...
python
def fetch_post_data(self): ''' fetch post accessed data. post_data, and ext_dic. ''' post_data = {} ext_dic = {} for key in self.request.arguments: if key.startswith('def_'): ext_dic[key] = self.get_argument(key) else: ...
[ "def", "fetch_post_data", "(", "self", ")", ":", "post_data", "=", "{", "}", "ext_dic", "=", "{", "}", "for", "key", "in", "self", ".", "request", ".", "arguments", ":", "if", "key", ".", "startswith", "(", "'def_'", ")", ":", "ext_dic", "[", "key", ...
fetch post accessed data. post_data, and ext_dic.
[ "fetch", "post", "accessed", "data", ".", "post_data", "and", "ext_dic", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/user_handler.py#L151-L167
bukun/TorCMS
torcms/handlers/user_handler.py
UserHandler.__check_valid
def __check_valid(self, post_data): ''' To check if the user is succesfully created. Return the status code dict. ''' user_create_status = {'success': False, 'code': '00'} if not tools.check_username_valid(post_data['user_name']): user_create_status['code'] =...
python
def __check_valid(self, post_data): ''' To check if the user is succesfully created. Return the status code dict. ''' user_create_status = {'success': False, 'code': '00'} if not tools.check_username_valid(post_data['user_name']): user_create_status['code'] =...
[ "def", "__check_valid", "(", "self", ",", "post_data", ")", ":", "user_create_status", "=", "{", "'success'", ":", "False", ",", "'code'", ":", "'00'", "}", "if", "not", "tools", ".", "check_username_valid", "(", "post_data", "[", "'user_name'", "]", ")", ...
To check if the user is succesfully created. Return the status code dict.
[ "To", "check", "if", "the", "user", "is", "succesfully", "created", ".", "Return", "the", "status", "code", "dict", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/user_handler.py#L333-L354
bukun/TorCMS
torcms/handlers/user_handler.py
UserHandler.json_register
def json_register(self): ''' The first char of 'code' stands for the different field. '1' for user_name '2' for user_email '3' for user_pass '4' for user_role The seconde char of 'code' stands for different status. '1' for invalide '2' for already ...
python
def json_register(self): ''' The first char of 'code' stands for the different field. '1' for user_name '2' for user_email '3' for user_pass '4' for user_role The seconde char of 'code' stands for different status. '1' for invalide '2' for already ...
[ "def", "json_register", "(", "self", ")", ":", "# user_create_status = {'success': False, 'code': '00'}", "post_data", "=", "self", ".", "get_post_data", "(", ")", "user_create_status", "=", "self", ".", "__check_valid", "(", "post_data", ")", "if", "not", "user_creat...
The first char of 'code' stands for the different field. '1' for user_name '2' for user_email '3' for user_pass '4' for user_role The seconde char of 'code' stands for different status. '1' for invalide '2' for already exists.
[ "The", "first", "char", "of", "code", "stands", "for", "the", "different", "field", ".", "1", "for", "user_name", "2", "for", "user_email", "3", "for", "user_pass", "4", "for", "user_role", "The", "seconde", "char", "of", "code", "stands", "for", "differen...
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/user_handler.py#L439-L462
bukun/TorCMS
torcms/handlers/user_handler.py
UserHandler.json_changeinfo
def json_changeinfo(self): ''' The first char of 'code' stands for the different field. '1' for user_name '2' for user_email '3' for user_pass '4' for user_role The seconde char of 'code' stands for different status. '1' for invalide '2' for alread...
python
def json_changeinfo(self): ''' The first char of 'code' stands for the different field. '1' for user_name '2' for user_email '3' for user_pass '4' for user_role The seconde char of 'code' stands for different status. '1' for invalide '2' for alread...
[ "def", "json_changeinfo", "(", "self", ")", ":", "# user_create_status = {'success': False, 'code': '00'}", "post_data", "=", "self", ".", "get_post_data", "(", ")", "is_user_passed", "=", "MUser", ".", "check_user", "(", "self", ".", "userinfo", ".", "uid", ",", ...
The first char of 'code' stands for the different field. '1' for user_name '2' for user_email '3' for user_pass '4' for user_role The seconde char of 'code' stands for different status. '1' for invalide '2' for already exists.
[ "The", "first", "char", "of", "code", "stands", "for", "the", "different", "field", ".", "1", "for", "user_name", "2", "for", "user_email", "3", "for", "user_pass", "4", "for", "user_role", "The", "seconde", "char", "of", "code", "stands", "for", "differen...
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/user_handler.py#L464-L493
bukun/TorCMS
torcms/handlers/user_handler.py
UserHandler.json_changepass
def json_changepass(self): ''' The first char of 'code' stands for the different field. '1' for user_name '2' for user_email '3' for user_pass '4' for user_role The seconde char of 'code' stands for different status. '1' for invalide '2' for alread...
python
def json_changepass(self): ''' The first char of 'code' stands for the different field. '1' for user_name '2' for user_email '3' for user_pass '4' for user_role The seconde char of 'code' stands for different status. '1' for invalide '2' for alread...
[ "def", "json_changepass", "(", "self", ")", ":", "# user_create_status = {'success': False, 'code': '00'} # Not used currently.", "post_data", "=", "self", ".", "get_post_data", "(", ")", "check_usr_status", "=", "MUser", ".", "check_user", "(", "self", ".", "userinfo", ...
The first char of 'code' stands for the different field. '1' for user_name '2' for user_email '3' for user_pass '4' for user_role The seconde char of 'code' stands for different status. '1' for invalide '2' for already exists.
[ "The", "first", "char", "of", "code", "stands", "for", "the", "different", "field", ".", "1", "for", "user_name", "2", "for", "user_email", "3", "for", "user_pass", "4", "for", "user_role", "The", "seconde", "char", "of", "code", "stands", "for", "differen...
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/user_handler.py#L495-L526
bukun/TorCMS
torcms/handlers/user_handler.py
UserHandler.login
def login(self): ''' user login. ''' post_data = self.get_post_data() if 'next' in post_data: next_url = post_data['next'] else: next_url = '/' u_name = post_data['user_name'] u_pass = post_data['user_pass'] result = MUse...
python
def login(self): ''' user login. ''' post_data = self.get_post_data() if 'next' in post_data: next_url = post_data['next'] else: next_url = '/' u_name = post_data['user_name'] u_pass = post_data['user_pass'] result = MUse...
[ "def", "login", "(", "self", ")", ":", "post_data", "=", "self", ".", "get_post_data", "(", ")", "if", "'next'", "in", "post_data", ":", "next_url", "=", "post_data", "[", "'next'", "]", "else", ":", "next_url", "=", "'/'", "u_name", "=", "post_data", ...
user login.
[ "user", "login", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/user_handler.py#L540-L582
bukun/TorCMS
torcms/handlers/user_handler.py
UserHandler.p_to_find
def p_to_find(self, ): ''' To find, pager. ''' kwd = { 'pager': '', } self.render('user/user_find_list.html', kwd=kwd, view=MUser.get_by_keyword(""), cfg=config.CMS_CFG, userinfo=...
python
def p_to_find(self, ): ''' To find, pager. ''' kwd = { 'pager': '', } self.render('user/user_find_list.html', kwd=kwd, view=MUser.get_by_keyword(""), cfg=config.CMS_CFG, userinfo=...
[ "def", "p_to_find", "(", "self", ",", ")", ":", "kwd", "=", "{", "'pager'", ":", "''", ",", "}", "self", ".", "render", "(", "'user/user_find_list.html'", ",", "kwd", "=", "kwd", ",", "view", "=", "MUser", ".", "get_by_keyword", "(", "\"\"", ")", ","...
To find, pager.
[ "To", "find", "pager", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/user_handler.py#L584-L596
bukun/TorCMS
torcms/handlers/user_handler.py
UserHandler.find
def find(self, keyword=None, cur_p=''): ''' find by keyword. ''' if not keyword: self.__to_find__(cur_p) kwd = { 'pager': '', 'title': '查找结果', } self.render(self.wrap_tmpl('user/{sig}user_find_list.html'), ...
python
def find(self, keyword=None, cur_p=''): ''' find by keyword. ''' if not keyword: self.__to_find__(cur_p) kwd = { 'pager': '', 'title': '查找结果', } self.render(self.wrap_tmpl('user/{sig}user_find_list.html'), ...
[ "def", "find", "(", "self", ",", "keyword", "=", "None", ",", "cur_p", "=", "''", ")", ":", "if", "not", "keyword", ":", "self", ".", "__to_find__", "(", "cur_p", ")", "kwd", "=", "{", "'pager'", ":", "''", ",", "'title'", ":", "'查找结果',", "", "}"...
find by keyword.
[ "find", "by", "keyword", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/user_handler.py#L598-L616
bukun/TorCMS
torcms/handlers/user_handler.py
UserHandler.reset_password
def reset_password(self): ''' Do reset password :return: ''' post_data = self.get_post_data() if 'email' in post_data: userinfo = MUser.get_by_email(post_data['email']) if tools.timestamp() - userinfo.time_reset_passwd < 70: self....
python
def reset_password(self): ''' Do reset password :return: ''' post_data = self.get_post_data() if 'email' in post_data: userinfo = MUser.get_by_email(post_data['email']) if tools.timestamp() - userinfo.time_reset_passwd < 70: self....
[ "def", "reset_password", "(", "self", ")", ":", "post_data", "=", "self", ".", "get_post_data", "(", ")", "if", "'email'", "in", "post_data", ":", "userinfo", "=", "MUser", ".", "get_by_email", "(", "post_data", "[", "'email'", "]", ")", "if", "tools", "...
Do reset password :return:
[ "Do", "reset", "password", ":", "return", ":" ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/user_handler.py#L647-L695
bukun/TorCMS
torcms/handlers/user_handler.py
UserHandler.gen_passwd
def gen_passwd(self): ''' reseting password ''' post_data = self.get_post_data() userinfo = MUser.get_by_name(post_data['u']) sub_timestamp = int(post_data['t']) cur_timestamp = tools.timestamp() if cur_timestamp - sub_timestamp < 600 and cur_timestamp >...
python
def gen_passwd(self): ''' reseting password ''' post_data = self.get_post_data() userinfo = MUser.get_by_name(post_data['u']) sub_timestamp = int(post_data['t']) cur_timestamp = tools.timestamp() if cur_timestamp - sub_timestamp < 600 and cur_timestamp >...
[ "def", "gen_passwd", "(", "self", ")", ":", "post_data", "=", "self", ".", "get_post_data", "(", ")", "userinfo", "=", "MUser", ".", "get_by_name", "(", "post_data", "[", "'u'", "]", ")", "sub_timestamp", "=", "int", "(", "post_data", "[", "'t'", "]", ...
reseting password
[ "reseting", "password" ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/user_handler.py#L697-L741
bukun/TorCMS
torcms/handlers/sys_handler.py
SysHandler.set_language
def set_language(self, language): ''' Set the cookie for locale. ''' if language == 'ZH': self.set_cookie('ulocale', 'zh_CN') self.set_cookie('blocale', 'zh_CN') else: self.set_cookie('ulocale', 'en_US') self.set_cookie('blocale', '...
python
def set_language(self, language): ''' Set the cookie for locale. ''' if language == 'ZH': self.set_cookie('ulocale', 'zh_CN') self.set_cookie('blocale', 'zh_CN') else: self.set_cookie('ulocale', 'en_US') self.set_cookie('blocale', '...
[ "def", "set_language", "(", "self", ",", "language", ")", ":", "if", "language", "==", "'ZH'", ":", "self", ".", "set_cookie", "(", "'ulocale'", ",", "'zh_CN'", ")", "self", ".", "set_cookie", "(", "'blocale'", ",", "'zh_CN'", ")", "else", ":", "self", ...
Set the cookie for locale.
[ "Set", "the", "cookie", "for", "locale", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/sys_handler.py#L54-L63
bukun/TorCMS
ext_script/autocrud/func_gen_html.py
gen_radio_view
def gen_radio_view(sig_dic): ''' for checkbox ''' view_zuoxiang = ''' <div class="col-sm-4"><span class="des">{0}</span></div> <div class="col-sm-8"> '''.format(sig_dic['zh']) dic_tmp = sig_dic['dic'] for key in dic_tmp.keys(): tmp_str = '''<span class="input_text"> ...
python
def gen_radio_view(sig_dic): ''' for checkbox ''' view_zuoxiang = ''' <div class="col-sm-4"><span class="des">{0}</span></div> <div class="col-sm-8"> '''.format(sig_dic['zh']) dic_tmp = sig_dic['dic'] for key in dic_tmp.keys(): tmp_str = '''<span class="input_text"> ...
[ "def", "gen_radio_view", "(", "sig_dic", ")", ":", "view_zuoxiang", "=", "'''\n <div class=\"col-sm-4\"><span class=\"des\">{0}</span></div>\n <div class=\"col-sm-8\">\n '''", ".", "format", "(", "sig_dic", "[", "'zh'", "]", ")", "dic_tmp", "=", "sig_dic", "[", "'d...
for checkbox
[ "for", "checkbox" ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/ext_script/autocrud/func_gen_html.py#L23-L42
bukun/TorCMS
ext_script/autocrud/func_gen_html.py
gen_checkbox_view
def gen_checkbox_view(sig_dic): ''' for checkbox ''' view_zuoxiang = ''' <div class="col-sm-4"><span class="des">{0}</span></div> <div class="col-sm-8"> '''.format(sig_dic['zh']) dic_tmp = sig_dic['dic'] for key in dic_tmp.keys(): tmp_str = ''' <span> {{% i...
python
def gen_checkbox_view(sig_dic): ''' for checkbox ''' view_zuoxiang = ''' <div class="col-sm-4"><span class="des">{0}</span></div> <div class="col-sm-8"> '''.format(sig_dic['zh']) dic_tmp = sig_dic['dic'] for key in dic_tmp.keys(): tmp_str = ''' <span> {{% i...
[ "def", "gen_checkbox_view", "(", "sig_dic", ")", ":", "view_zuoxiang", "=", "'''\n <div class=\"col-sm-4\"><span class=\"des\">{0}</span></div>\n <div class=\"col-sm-8\">\n '''", ".", "format", "(", "sig_dic", "[", "'zh'", "]", ")", "dic_tmp", "=", "sig_dic", "[", ...
for checkbox
[ "for", "checkbox" ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/ext_script/autocrud/func_gen_html.py#L45-L66
bukun/TorCMS
ext_script/autocrud/func_gen_html.py
gen_select_view
def gen_select_view(sig_dic): ''' HTML view, for selection. ''' option_str = '' dic_tmp = sig_dic['dic'] for key, val in dic_tmp.items(): tmp_str = ''' {{% if '{sig_en}' in postinfo.extinfo %}} {{% set tmp_var = postinfo.extinfo["{sig_en}"] %}} {{% if tmp_var...
python
def gen_select_view(sig_dic): ''' HTML view, for selection. ''' option_str = '' dic_tmp = sig_dic['dic'] for key, val in dic_tmp.items(): tmp_str = ''' {{% if '{sig_en}' in postinfo.extinfo %}} {{% set tmp_var = postinfo.extinfo["{sig_en}"] %}} {{% if tmp_var...
[ "def", "gen_select_view", "(", "sig_dic", ")", ":", "option_str", "=", "''", "dic_tmp", "=", "sig_dic", "[", "'dic'", "]", "for", "key", ",", "val", "in", "dic_tmp", ".", "items", "(", ")", ":", "tmp_str", "=", "'''\n {{% if '{sig_en}' in postinfo.exti...
HTML view, for selection.
[ "HTML", "view", "for", "selection", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/ext_script/autocrud/func_gen_html.py#L69-L92
bukun/TorCMS
ext_script/autocrud/func_gen_html.py
gen_radio_list
def gen_radio_list(sig_dic): ''' For generating List view HTML file for RADIO. for each item. ''' view_zuoxiang = '''<span class="iga_pd_val">''' dic_tmp = sig_dic['dic'] for key in dic_tmp.keys(): tmp_str = '''{{% if postinfo.extinfo['{0}'][0] == "{1}" %}} {2} {{% end %}} '...
python
def gen_radio_list(sig_dic): ''' For generating List view HTML file for RADIO. for each item. ''' view_zuoxiang = '''<span class="iga_pd_val">''' dic_tmp = sig_dic['dic'] for key in dic_tmp.keys(): tmp_str = '''{{% if postinfo.extinfo['{0}'][0] == "{1}" %}} {2} {{% end %}} '...
[ "def", "gen_radio_list", "(", "sig_dic", ")", ":", "view_zuoxiang", "=", "'''<span class=\"iga_pd_val\">'''", "dic_tmp", "=", "sig_dic", "[", "'dic'", "]", "for", "key", "in", "dic_tmp", ".", "keys", "(", ")", ":", "tmp_str", "=", "'''{{% if postinfo.extinfo['{0}'...
For generating List view HTML file for RADIO. for each item.
[ "For", "generating", "List", "view", "HTML", "file", "for", "RADIO", ".", "for", "each", "item", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/ext_script/autocrud/func_gen_html.py#L118-L132
bukun/TorCMS
ext_script/autocrud/func_gen_html.py
gen_checkbox_list
def gen_checkbox_list(sig_dic): ''' For generating List view HTML file for CHECKBOX. for each item. ''' view_zuoxiang = '''<span class="iga_pd_val">''' dic_tmp = sig_dic['dic'] for key in dic_tmp.keys(): tmp_str = '''{{% if "{0}" in postinfo.extinfo["{1}"] %}} {2} {{% end %}} ...
python
def gen_checkbox_list(sig_dic): ''' For generating List view HTML file for CHECKBOX. for each item. ''' view_zuoxiang = '''<span class="iga_pd_val">''' dic_tmp = sig_dic['dic'] for key in dic_tmp.keys(): tmp_str = '''{{% if "{0}" in postinfo.extinfo["{1}"] %}} {2} {{% end %}} ...
[ "def", "gen_checkbox_list", "(", "sig_dic", ")", ":", "view_zuoxiang", "=", "'''<span class=\"iga_pd_val\">'''", "dic_tmp", "=", "sig_dic", "[", "'dic'", "]", "for", "key", "in", "dic_tmp", ".", "keys", "(", ")", ":", "tmp_str", "=", "'''{{% if \"{0}\" in postinfo...
For generating List view HTML file for CHECKBOX. for each item.
[ "For", "generating", "List", "view", "HTML", "file", "for", "CHECKBOX", ".", "for", "each", "item", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/ext_script/autocrud/func_gen_html.py#L135-L149
bukun/TorCMS
ext_script/autocrud/func_gen_html.py
gen_select_list
def gen_select_list(sig_dic): ''' For generating List view HTML file for SELECT. for each item. ''' view_jushi = '''<span class="label label-primary" style="margin-right:10px">''' dic_tmp = sig_dic['dic'] for key in dic_tmp.keys(): tmp_str = '''{{% if '{0}' in postinfo.extinfo and p...
python
def gen_select_list(sig_dic): ''' For generating List view HTML file for SELECT. for each item. ''' view_jushi = '''<span class="label label-primary" style="margin-right:10px">''' dic_tmp = sig_dic['dic'] for key in dic_tmp.keys(): tmp_str = '''{{% if '{0}' in postinfo.extinfo and p...
[ "def", "gen_select_list", "(", "sig_dic", ")", ":", "view_jushi", "=", "'''<span class=\"label label-primary\" style=\"margin-right:10px\">'''", "dic_tmp", "=", "sig_dic", "[", "'dic'", "]", "for", "key", "in", "dic_tmp", ".", "keys", "(", ")", ":", "tmp_str", "=", ...
For generating List view HTML file for SELECT. for each item.
[ "For", "generating", "List", "view", "HTML", "file", "for", "SELECT", ".", "for", "each", "item", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/ext_script/autocrud/func_gen_html.py#L152-L166
bukun/TorCMS
torcms/script/autocrud/func_gen_html.py
gen_input_add
def gen_input_add(sig_dic): ''' Adding for HTML Input control. ''' if sig_dic['en'] == 'tag_file_download': html_str = HTML_TPL_DICT['input_add_download'].format( sig_en=sig_dic['en'], sig_zh=sig_dic['zh'], sig_dic=sig_dic['dic'][1], sig_type=sig_d...
python
def gen_input_add(sig_dic): ''' Adding for HTML Input control. ''' if sig_dic['en'] == 'tag_file_download': html_str = HTML_TPL_DICT['input_add_download'].format( sig_en=sig_dic['en'], sig_zh=sig_dic['zh'], sig_dic=sig_dic['dic'][1], sig_type=sig_d...
[ "def", "gen_input_add", "(", "sig_dic", ")", ":", "if", "sig_dic", "[", "'en'", "]", "==", "'tag_file_download'", ":", "html_str", "=", "HTML_TPL_DICT", "[", "'input_add_download'", "]", ".", "format", "(", "sig_en", "=", "sig_dic", "[", "'en'", "]", ",", ...
Adding for HTML Input control.
[ "Adding", "for", "HTML", "Input", "control", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/script/autocrud/func_gen_html.py#L10-L28
bukun/TorCMS
torcms/script/autocrud/func_gen_html.py
gen_input_edit
def gen_input_edit(sig_dic): ''' Editing for HTML input control. ''' if sig_dic['en'] == 'tag_file_download': html_str = HTML_TPL_DICT['input_edit_download'].format( sig_en=sig_dic['en'], sig_zh=sig_dic['zh'], sig_dic=sig_dic['dic'][1], sig_type=si...
python
def gen_input_edit(sig_dic): ''' Editing for HTML input control. ''' if sig_dic['en'] == 'tag_file_download': html_str = HTML_TPL_DICT['input_edit_download'].format( sig_en=sig_dic['en'], sig_zh=sig_dic['zh'], sig_dic=sig_dic['dic'][1], sig_type=si...
[ "def", "gen_input_edit", "(", "sig_dic", ")", ":", "if", "sig_dic", "[", "'en'", "]", "==", "'tag_file_download'", ":", "html_str", "=", "HTML_TPL_DICT", "[", "'input_edit_download'", "]", ".", "format", "(", "sig_en", "=", "sig_dic", "[", "'en'", "]", ",", ...
Editing for HTML input control.
[ "Editing", "for", "HTML", "input", "control", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/script/autocrud/func_gen_html.py#L31-L49
bukun/TorCMS
torcms/script/autocrud/func_gen_html.py
gen_input_view
def gen_input_view(sig_dic): ''' Viewing the HTML text. ''' if sig_dic['en'] == 'tag_file_download': html_str = HTML_TPL_DICT['input_view_download'].format( sig_zh=sig_dic['zh'], sig_unit=sig_dic['dic'][1] ) elif sig_dic['en'] in ['tag_access_link', 'tag_dmoz_...
python
def gen_input_view(sig_dic): ''' Viewing the HTML text. ''' if sig_dic['en'] == 'tag_file_download': html_str = HTML_TPL_DICT['input_view_download'].format( sig_zh=sig_dic['zh'], sig_unit=sig_dic['dic'][1] ) elif sig_dic['en'] in ['tag_access_link', 'tag_dmoz_...
[ "def", "gen_input_view", "(", "sig_dic", ")", ":", "if", "sig_dic", "[", "'en'", "]", "==", "'tag_file_download'", ":", "html_str", "=", "HTML_TPL_DICT", "[", "'input_view_download'", "]", ".", "format", "(", "sig_zh", "=", "sig_dic", "[", "'zh'", "]", ",", ...
Viewing the HTML text.
[ "Viewing", "the", "HTML", "text", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/script/autocrud/func_gen_html.py#L52-L76
bukun/TorCMS
torcms/script/autocrud/func_gen_html.py
gen_radio_add
def gen_radio_add(sig_dic): ''' Adding for HTML radio control. ''' # html_zuoxiang = ''' # <label for="{0}"><span> # <a class="glyphicon glyphicon-star" style="color: red;font-size: xx-small;"></a> {1}</span> # '''.format(sig['en'], sig['zh']) # each item for radio. radio_control_st...
python
def gen_radio_add(sig_dic): ''' Adding for HTML radio control. ''' # html_zuoxiang = ''' # <label for="{0}"><span> # <a class="glyphicon glyphicon-star" style="color: red;font-size: xx-small;"></a> {1}</span> # '''.format(sig['en'], sig['zh']) # each item for radio. radio_control_st...
[ "def", "gen_radio_add", "(", "sig_dic", ")", ":", "# html_zuoxiang = '''", "# <label for=\"{0}\"><span>", "# <a class=\"glyphicon glyphicon-star\" style=\"color: red;font-size: xx-small;\"></a> {1}</span>", "# '''.format(sig['en'], sig['zh'])", "# each item for radio.", "radio_control_str", ...
Adding for HTML radio control.
[ "Adding", "for", "HTML", "radio", "control", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/script/autocrud/func_gen_html.py#L79-L107
bukun/TorCMS
torcms/script/autocrud/func_gen_html.py
gen_radio_edit
def gen_radio_edit(sig_dic): ''' editing for HTML radio control. ''' edit_zuoxiang = '''7 <label for="{0}"><span> <a class="glyphicon glyphicon-star" style="color: red;font-size: xx-small;"> </a>{1}</span> '''.format(sig_dic['en'], sig_dic['zh']) dic_tmp = sig_dic['dic'] for ke...
python
def gen_radio_edit(sig_dic): ''' editing for HTML radio control. ''' edit_zuoxiang = '''7 <label for="{0}"><span> <a class="glyphicon glyphicon-star" style="color: red;font-size: xx-small;"> </a>{1}</span> '''.format(sig_dic['en'], sig_dic['zh']) dic_tmp = sig_dic['dic'] for ke...
[ "def", "gen_radio_edit", "(", "sig_dic", ")", ":", "edit_zuoxiang", "=", "'''7\n <label for=\"{0}\"><span>\n <a class=\"glyphicon glyphicon-star\" style=\"color: red;font-size: xx-small;\">\n </a>{1}</span>\n '''", ".", "format", "(", "sig_dic", "[", "'en'", "]", ",", ...
editing for HTML radio control.
[ "editing", "for", "HTML", "radio", "control", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/script/autocrud/func_gen_html.py#L110-L132
bukun/TorCMS
torcms/script/autocrud/func_gen_html.py
gen_checkbox_add
def gen_checkbox_add(sig_dic): ''' for checkbox ''' html_wuneisheshi = '''<label for="{0}"><span> <a class="glyphicon glyphicon-star" style="color: red;font-size: xx-small;"> </a>{1}</span>'''.format(sig_dic['en'], sig_dic['zh']) dic_tmp = sig_dic['dic'] for key in dic_tmp.keys(): ...
python
def gen_checkbox_add(sig_dic): ''' for checkbox ''' html_wuneisheshi = '''<label for="{0}"><span> <a class="glyphicon glyphicon-star" style="color: red;font-size: xx-small;"> </a>{1}</span>'''.format(sig_dic['en'], sig_dic['zh']) dic_tmp = sig_dic['dic'] for key in dic_tmp.keys(): ...
[ "def", "gen_checkbox_add", "(", "sig_dic", ")", ":", "html_wuneisheshi", "=", "'''<label for=\"{0}\"><span>\n <a class=\"glyphicon glyphicon-star\" style=\"color: red;font-size: xx-small;\">\n </a>{1}</span>'''", ".", "format", "(", "sig_dic", "[", "'en'", "]", ",", "sig_dic...
for checkbox
[ "for", "checkbox" ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/script/autocrud/func_gen_html.py#L157-L173
bukun/TorCMS
torcms/script/autocrud/func_gen_html.py
gen_checkbox_edit
def gen_checkbox_edit(sig_dic): ''' for checkbox ''' edit_wuneisheshi = '''<label for="{0}"><span> <a class="glyphicon glyphicon-star" style="color: red;font-size: xx-small;"> </a>{1}</span> '''.format(sig_dic['en'], sig_dic['zh']) dic_tmp = sig_dic['dic'] for key in dic_tmp.keys...
python
def gen_checkbox_edit(sig_dic): ''' for checkbox ''' edit_wuneisheshi = '''<label for="{0}"><span> <a class="glyphicon glyphicon-star" style="color: red;font-size: xx-small;"> </a>{1}</span> '''.format(sig_dic['en'], sig_dic['zh']) dic_tmp = sig_dic['dic'] for key in dic_tmp.keys...
[ "def", "gen_checkbox_edit", "(", "sig_dic", ")", ":", "edit_wuneisheshi", "=", "'''<label for=\"{0}\"><span>\n <a class=\"glyphicon glyphicon-star\" style=\"color: red;font-size: xx-small;\">\n </a>{1}</span>\n '''", ".", "format", "(", "sig_dic", "[", "'en'", "]", ",", ...
for checkbox
[ "for", "checkbox" ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/script/autocrud/func_gen_html.py#L176-L196
bukun/TorCMS
torcms/script/autocrud/func_gen_html.py
gen_select_add
def gen_select_add(sig_dic): ''' Adding for select control. :param sig_dic: html_media_type = { 'en': 'tag_media_type', 'zh': 'Media_type', 'dic': {1: 'Document', 2: 'Data', 3: 'Program'}, 'type': 'select', } ''' option_str = '' for key, val in s...
python
def gen_select_add(sig_dic): ''' Adding for select control. :param sig_dic: html_media_type = { 'en': 'tag_media_type', 'zh': 'Media_type', 'dic': {1: 'Document', 2: 'Data', 3: 'Program'}, 'type': 'select', } ''' option_str = '' for key, val in s...
[ "def", "gen_select_add", "(", "sig_dic", ")", ":", "option_str", "=", "''", "for", "key", ",", "val", "in", "sig_dic", "[", "'dic'", "]", ".", "items", "(", ")", ":", "tmp_str", "=", "'''<option value=\"{0}\">{1}</option>'''", ".", "format", "(", "key", ",...
Adding for select control. :param sig_dic: html_media_type = { 'en': 'tag_media_type', 'zh': 'Media_type', 'dic': {1: 'Document', 2: 'Data', 3: 'Program'}, 'type': 'select', }
[ "Adding", "for", "select", "control", ".", ":", "param", "sig_dic", ":", "html_media_type", "=", "{", "en", ":", "tag_media_type", "zh", ":", "Media_type", "dic", ":", "{", "1", ":", "Document", "2", ":", "Data", "3", ":", "Program", "}", "type", ":", ...
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/script/autocrud/func_gen_html.py#L223-L247
bukun/TorCMS
torcms/model/post_model.py
MPost.query_recent_most
def query_recent_most(num=8, recent=30): ''' Query the records from database that recently updated. :param num: the number that will returned. :param recent: the number of days recent. ''' time_that = int(time.time()) - recent * 24 * 3600 return TabPost.select().w...
python
def query_recent_most(num=8, recent=30): ''' Query the records from database that recently updated. :param num: the number that will returned. :param recent: the number of days recent. ''' time_that = int(time.time()) - recent * 24 * 3600 return TabPost.select().w...
[ "def", "query_recent_most", "(", "num", "=", "8", ",", "recent", "=", "30", ")", ":", "time_that", "=", "int", "(", "time", ".", "time", "(", ")", ")", "-", "recent", "*", "24", "*", "3600", "return", "TabPost", ".", "select", "(", ")", ".", "whe...
Query the records from database that recently updated. :param num: the number that will returned. :param recent: the number of days recent.
[ "Query", "the", "records", "from", "database", "that", "recently", "updated", ".", ":", "param", "num", ":", "the", "number", "that", "will", "returned", ".", ":", "param", "recent", ":", "the", "number", "of", "days", "recent", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/post_model.py#L26-L37
bukun/TorCMS
torcms/model/post_model.py
MPost.delete
def delete(uid): ''' Delete by uid ''' q_u1 = TabPostHist.delete().where(TabPostHist.post_id == uid) q_u1.execute() q_u2 = TabRel.delete().where(TabRel.post_f_id == uid or TabRel.post_t_id == uid) q_u2.execute() q_u3 = TabCollect.delete().where(TabCollect...
python
def delete(uid): ''' Delete by uid ''' q_u1 = TabPostHist.delete().where(TabPostHist.post_id == uid) q_u1.execute() q_u2 = TabRel.delete().where(TabRel.post_f_id == uid or TabRel.post_t_id == uid) q_u2.execute() q_u3 = TabCollect.delete().where(TabCollect...
[ "def", "delete", "(", "uid", ")", ":", "q_u1", "=", "TabPostHist", ".", "delete", "(", ")", ".", "where", "(", "TabPostHist", ".", "post_id", "==", "uid", ")", "q_u1", ".", "execute", "(", ")", "q_u2", "=", "TabRel", ".", "delete", "(", ")", ".", ...
Delete by uid
[ "Delete", "by", "uid" ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/post_model.py#L40-L70
bukun/TorCMS
torcms/model/post_model.py
MPost.__update_rating
def __update_rating(uid, rating): ''' Update the rating for post. ''' entry = TabPost.update( rating=rating ).where(TabPost.uid == uid) entry.execute()
python
def __update_rating(uid, rating): ''' Update the rating for post. ''' entry = TabPost.update( rating=rating ).where(TabPost.uid == uid) entry.execute()
[ "def", "__update_rating", "(", "uid", ",", "rating", ")", ":", "entry", "=", "TabPost", ".", "update", "(", "rating", "=", "rating", ")", ".", "where", "(", "TabPost", ".", "uid", "==", "uid", ")", "entry", ".", "execute", "(", ")" ]
Update the rating for post.
[ "Update", "the", "rating", "for", "post", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/post_model.py#L87-L94
bukun/TorCMS
torcms/model/post_model.py
MPost.__update_kind
def __update_kind(uid, kind): ''' update the kind of post. ''' entry = TabPost.update( kind=kind, ).where(TabPost.uid == uid) entry.execute() return True
python
def __update_kind(uid, kind): ''' update the kind of post. ''' entry = TabPost.update( kind=kind, ).where(TabPost.uid == uid) entry.execute() return True
[ "def", "__update_kind", "(", "uid", ",", "kind", ")", ":", "entry", "=", "TabPost", ".", "update", "(", "kind", "=", "kind", ",", ")", ".", "where", "(", "TabPost", ".", "uid", "==", "uid", ")", "entry", ".", "execute", "(", ")", "return", "True" ]
update the kind of post.
[ "update", "the", "kind", "of", "post", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/post_model.py#L97-L106
bukun/TorCMS
torcms/model/post_model.py
MPost.update_cnt
def update_cnt(uid, post_data): ''' update content. ''' entry = TabPost.update( cnt_html=tools.markdown2html(post_data['cnt_md']), user_name=post_data['user_name'], cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'].strip()), time_upda...
python
def update_cnt(uid, post_data): ''' update content. ''' entry = TabPost.update( cnt_html=tools.markdown2html(post_data['cnt_md']), user_name=post_data['user_name'], cnt_md=tornado.escape.xhtml_escape(post_data['cnt_md'].strip()), time_upda...
[ "def", "update_cnt", "(", "uid", ",", "post_data", ")", ":", "entry", "=", "TabPost", ".", "update", "(", "cnt_html", "=", "tools", ".", "markdown2html", "(", "post_data", "[", "'cnt_md'", "]", ")", ",", "user_name", "=", "post_data", "[", "'user_name'", ...
update content.
[ "update", "content", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/post_model.py#L117-L128
bukun/TorCMS
torcms/model/post_model.py
MPost.update_order
def update_order(uid, order): ''' Update the order of the posts. ''' entry = TabPost.update( order=order ).where(TabPost.uid == uid) entry.execute()
python
def update_order(uid, order): ''' Update the order of the posts. ''' entry = TabPost.update( order=order ).where(TabPost.uid == uid) entry.execute()
[ "def", "update_order", "(", "uid", ",", "order", ")", ":", "entry", "=", "TabPost", ".", "update", "(", "order", "=", "order", ")", ".", "where", "(", "TabPost", ".", "uid", "==", "uid", ")", "entry", ".", "execute", "(", ")" ]
Update the order of the posts.
[ "Update", "the", "order", "of", "the", "posts", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/post_model.py#L131-L138
bukun/TorCMS
torcms/model/post_model.py
MPost.update
def update(uid, post_data, update_time=False): ''' update the infor. ''' title = post_data['title'].strip() if len(title) < 2: return False cnt_html = tools.markdown2html(post_data['cnt_md']) try: if update_time: entry2 = T...
python
def update(uid, post_data, update_time=False): ''' update the infor. ''' title = post_data['title'].strip() if len(title) < 2: return False cnt_html = tools.markdown2html(post_data['cnt_md']) try: if update_time: entry2 = T...
[ "def", "update", "(", "uid", ",", "post_data", ",", "update_time", "=", "False", ")", ":", "title", "=", "post_data", "[", "'title'", "]", ".", "strip", "(", ")", "if", "len", "(", "title", ")", "<", "2", ":", "return", "False", "cnt_html", "=", "t...
update the infor.
[ "update", "the", "infor", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/post_model.py#L141-L175
bukun/TorCMS
torcms/model/post_model.py
MPost.add_or_update
def add_or_update(uid, post_data): ''' Add or update the post. ''' cur_rec = MPost.get_by_uid(uid) if cur_rec: MPost.update(uid, post_data) else: MPost.create_post(uid, post_data)
python
def add_or_update(uid, post_data): ''' Add or update the post. ''' cur_rec = MPost.get_by_uid(uid) if cur_rec: MPost.update(uid, post_data) else: MPost.create_post(uid, post_data)
[ "def", "add_or_update", "(", "uid", ",", "post_data", ")", ":", "cur_rec", "=", "MPost", ".", "get_by_uid", "(", "uid", ")", "if", "cur_rec", ":", "MPost", ".", "update", "(", "uid", ",", "post_data", ")", "else", ":", "MPost", ".", "create_post", "(",...
Add or update the post.
[ "Add", "or", "update", "the", "post", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/post_model.py#L178-L186
bukun/TorCMS
torcms/model/post_model.py
MPost.create_post
def create_post(post_uid, post_data): ''' create the post. ''' title = post_data['title'].strip() if len(title) < 2: return False cur_rec = MPost.get_by_uid(post_uid) if cur_rec: return False entry = TabPost.create( t...
python
def create_post(post_uid, post_data): ''' create the post. ''' title = post_data['title'].strip() if len(title) < 2: return False cur_rec = MPost.get_by_uid(post_uid) if cur_rec: return False entry = TabPost.create( t...
[ "def", "create_post", "(", "post_uid", ",", "post_data", ")", ":", "title", "=", "post_data", "[", "'title'", "]", ".", "strip", "(", ")", "if", "len", "(", "title", ")", "<", "2", ":", "return", "False", "cur_rec", "=", "MPost", ".", "get_by_uid", "...
create the post.
[ "create", "the", "post", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/post_model.py#L189-L220
bukun/TorCMS
torcms/model/post_model.py
MPost.query_cat_random
def query_cat_random(catid, **kwargs): ''' Get random lists of certain category. ''' num = kwargs.get('limit', 8) if catid == '': rand_recs = TabPost.select().order_by(peewee.fn.Random()).limit(num) else: rand_recs = TabPost.select().join( ...
python
def query_cat_random(catid, **kwargs): ''' Get random lists of certain category. ''' num = kwargs.get('limit', 8) if catid == '': rand_recs = TabPost.select().order_by(peewee.fn.Random()).limit(num) else: rand_recs = TabPost.select().join( ...
[ "def", "query_cat_random", "(", "catid", ",", "*", "*", "kwargs", ")", ":", "num", "=", "kwargs", ".", "get", "(", "'limit'", ",", "8", ")", "if", "catid", "==", "''", ":", "rand_recs", "=", "TabPost", ".", "select", "(", ")", ".", "order_by", "(",...
Get random lists of certain category.
[ "Get", "random", "lists", "of", "certain", "category", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/post_model.py#L223-L239
bukun/TorCMS
torcms/model/post_model.py
MPost.query_random
def query_random(**kwargs): ''' Return the random records of centain kind. ''' if 'limit' in kwargs: limit = kwargs['limit'] elif 'num' in kwargs: limit = kwargs['num'] else: limit = 10 kind = kwargs.get('kind', None) ...
python
def query_random(**kwargs): ''' Return the random records of centain kind. ''' if 'limit' in kwargs: limit = kwargs['limit'] elif 'num' in kwargs: limit = kwargs['num'] else: limit = 10 kind = kwargs.get('kind', None) ...
[ "def", "query_random", "(", "*", "*", "kwargs", ")", ":", "if", "'limit'", "in", "kwargs", ":", "limit", "=", "kwargs", "[", "'limit'", "]", "elif", "'num'", "in", "kwargs", ":", "limit", "=", "kwargs", "[", "'num'", "]", "else", ":", "limit", "=", ...
Return the random records of centain kind.
[ "Return", "the", "random", "records", "of", "centain", "kind", "." ]
train
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/model/post_model.py#L242-L269