Esempio n. 1
0
def add_old_mehvarz_to_new(_added_mehvar_id,_selected_code_id):
    py_db.executesql("""
insert into tbl_irib_olaviats_mozoo_mehvarz
(`iomm_name`,`iomm_link`) values
('{0}','{1}')""".format(
    py_db.executeAndReturnRows("select _text from mehvarz where id="+_selected_code_id)[0][0],
    _added_mehvar_id
    ))
    print "ok"
Esempio n. 2
0
def add_to_headers(_added_texxxxxxt,_added_typeeeeee,_parent_______id):
    sqlstr = ""
    if _added_typeeeeee == "1":
	sqlstr = "insert into tbl_irib_olaviats (io_Onvan) values ('{0}')".format(_added_texxxxxxt)
    if _added_typeeeeee == "2":
	sqlstr = "insert into tbl_irib_olaviats_mozoo (iom_name, iom_link) values ('{0}','{1}')".format(_added_texxxxxxt,_parent_______id)
    if _added_typeeeeee == "3":
	sqlstr = "insert into tbl_irib_olaviats_mozoo_mehvarz (iomm_name,iomm_link) values ('{0}','{1}')".format(_added_texxxxxxt,_parent_______id)
    if _added_typeeeeee == "4":
	sqlstr = "insert into tbl_irib_channels (ic_name) values ('{0}')".format(_added_texxxxxxt,_parent_______id)
    py_db.executesql(sqlstr)
    print "ok refresh"
Esempio n. 3
0
def del_headers(_type_of_updateing,_id_of_selected_header):
    sqlstr=""
    if int(_type_of_updateing)==1:
	sqlstr="delete from tbl_irib_olaviats  where io_id='{1}'".format('',_id_of_selected_header)
    if int(_type_of_updateing)==2:
	sqlstr="delete from tbl_irib_olaviats_mozoo where iom_id='{1}'".format('',_id_of_selected_header)
    if int(_type_of_updateing)==3:
	sqlstr="delete from tbl_irib_olaviats_mozoo_mehvarz  where iomm_id='{1}'".format('',_id_of_selected_header)
    if int(_type_of_updateing)==4:
	sqlstr="delete from tbl_irib_channels  where ic_id='{1}'".format('',_id_of_selected_header)
    #print sqlstr
    py_db.executesql(sqlstr)
    print "ok"
Esempio n. 4
0
def update_headers(_text_of_value,_type_of_updateing,_id_of_selected_header):
    sqlstr=""
    if int(_type_of_updateing)==1:
	sqlstr="update tbl_irib_olaviats set io_Onvan = '{0}' where io_id='{1}'".format(_text_of_value,_id_of_selected_header)
    if int(_type_of_updateing)==2:
	sqlstr="update tbl_irib_olaviats_mozoo set iom_name = '{0}' where iom_id='{1}'".format(_text_of_value,_id_of_selected_header)
    if int(_type_of_updateing)==3:
	sqlstr="update tbl_irib_olaviats_mozoo_mehvarz set iomm_name = '{0}' where iomm_id='{1}'".format(_text_of_value,_id_of_selected_header)
    if int(_type_of_updateing)==4:
	sqlstr="update tbl_irib_channels set ic_name = '{0}' where ic_id='{1}'".format(_text_of_value,_id_of_selected_header)
    #print sqlstr
    py_db.executesql(sqlstr)
    print "ok"
Esempio n. 5
0
def do_update(request,keyfieldID):
    update_str = ""
    sql="select f_table_name,f_key_field from tbl_forms where f_id=(select fi_link_to_form_name from tbl_form_items where fi_id='{0}' limit 1)".format(request[0][0])
    
    tt = py_db.executeAndReturnRows(sql)
    table_name = tt[0][0]
    ketfield_name = tt[0][1]
    
    for item in request:
        if update_str == "":update_str ="{0}='{1}'".format(item[2][15],item[1])
        else: update_str +=",{0}='{1}'".format(item[2][15],item[1])
        
    sql="update {0} set {1} where {2}".format(table_name,update_str,ketfield_name+"='{0}'".format(keyfieldID[0]))
    #print sql
    
    sql=sql.replace("'empty'",'(NULL)')
    py_db.executesql(sql)
Esempio n. 6
0
def do_insert(request):
    insert_str = ""
    before_value = ""
    after_value = ""
    sql="select f_table_name from tbl_forms where f_id=(select fi_link_to_form_name from tbl_form_items where fi_id='{0}' limit 1)".format(request[0][0])
    table_name = py_db.executeAndReturnRows(sql)[0][0]
    #print request
    for item in request:
        #print item.__str__()+"<br>"
        #['1', '1', (1L, u'\u0646\u0627\u0645', 1, None, None, None, 1, 0, None, None, 1L, 1L, None, None, None, u'soccc_name')]
        if before_value == "":before_value ="{0}".format(item[2][15])
        else: before_value +=",{0}".format(item[2][15])
        if after_value == "":after_value ="'{0}'".format(item[1])
        else: after_value +=",'{0}'".format(item[1])
        
    sql="insert into {0} ({1}) values ({2})".format(table_name,before_value,after_value)
    py_db.executesql(sql)
    return sql
Esempio n. 7
0
def set_edit_post(edited_data):
    edited_array = []
    set_channels = "  ";
    ed = edited_data.split("yupp")
    get_txt = ed[0]
    get_mehvar = ed[1]
    get_hadaf_id = ed[3]

    for sd in ed[2].split("^"):
	if sd!="":
	    
	    set_channels =  """
	    delete from tbl_irib_mehvarha_content where imc_channels_link={0} and imc_mehvar_link={1};
	
		""".format(sd.split(">")[0],get_hadaf_id)
	    py_db.executesql(set_channels)
	    if sd.split(">")[1] != "0":
		set_channels = """
	    insert into tbl_irib_mehvarha_content (imc_channels_link,imc_mehvar_link,imc_type) values({0},{1},{2});
	
		    """.format(sd.split(">")[0],get_hadaf_id,sd.split(">")[1])
	    py_db.executesql(set_channels)
    
    py_db.executesql("update tbl_irib_mehvarha set cim_name='{0}', cim_codes='{1}' where cim_id = {2}".format(get_txt,get_mehvar,get_hadaf_id))
Esempio n. 8
0
def update_edited_data(_data):
    dt=unquote_u(_data)

    #print dt
    #print dt
    soup = BeautifulSoup(dt)
    dd = ""
    inputs = soup.findAll('input')
    final_array = []
    for sp in inputs:
	obj_attr = sp.attrs
	if 'value' in sp.attrs:
	    obj_value = sp.attrs['value']
	else:
	    obj_value = ""
	obj_id = obj_attr['id']
	obj_type = obj_attr['type']
	obj_id_type = obj_id.split("_")[0]
	
	obj_value_olaviats_mozoo_mehvar = ""
	obj_value_Code_Group_Shabake = ""
	if obj_id.split("_")[0]!="txt":
	    obj_value_olaviats_mozoo_mehvar = obj_id.split("_")[1].split("cvf")[0]
	    obj_value_Code_Group_Shabake = obj_id.split("_")[1].split("cvf")[1]

	    
	dynamic_key = ''
	if obj_id_type == "txtspm":
	    dynamic_key = obj_id.split("_")[2]
	if obj_id_type == "txtpercm":
	    dynamic_key = obj_id.split("_")[2]
	final_array.append(
	    [obj_id_type,
	     obj_value,
             obj_value_olaviats_mozoo_mehvar,
 	     obj_value_Code_Group_Shabake,
	     dynamic_key])
    get_objects_txtsp = filter(lambda x:x[0] == "txtsp",final_array)
    get_objects_txtperc = filter(lambda x:x[0] == "txtperc",final_array)
    get_objects_txtspm = filter(lambda x:x[0] == "txtspm",final_array)
    get_objects_txtpercm = filter(lambda x:x[0] == "txtpercm",final_array)
    
    # get_objects_txtsp[0][0]  = txtsp object suffix
    # get_objects_txtsp[0][1]  = object value
    # get_objects_txtsp[0][2]  = Channel Group ID
    # get_objects_txtsp[0][3]  = Mehvar ID
    # get_objects_txtsp[0][4]  = code dynamic ezafeh shodeha dar soorate added
    
    objects_combined_txtsp_with_txtperc = []
    for o in get_objects_txtsp:
	for o1 in get_objects_txtperc:
	    if o[2]==o1[2] and o[3]==o1[3] :
		objects_combined_txtsp_with_txtperc.append([o,o1])
   
   
    objects_combined_dynamic_txtsp_with_txtperc = []
    for o in get_objects_txtspm:
	for o1 in get_objects_txtpercm:
	    if o[2]==o1[2] and o[3]==o1[3] and o[4]==o1[4]:
		objects_combined_dynamic_txtsp_with_txtperc.append([o,o1])

#objects_combined_dynamic_txtsp_with_txtprec
    # get_objects_txtsp[0][0]  = txtsp object suffix
    # get_objects_txtsp[0][1]  = object value
    # get_objects_txtsp[0][2]  = Channel Group ID
    # get_objects_txtsp[0][3]  = Mehvar ID
    # get_objects_txtsp[0][4]  = code dynamic ezafeh shodeha dar soorate added
    today = datetime.datetime.now().strftime("%Y/%m/%d %H:%M:%S" );    
    for o in objects_combined_txtsp_with_txtperc:
	if o[1][1]!="":
	    prc = o[1][1]
	sqlstr = """
   UPDATE `irib`.`tbl_irib_ch_gr_meh`
SET 
  
  `icgm_out` = '{4}',
  `icgm_dateout` = '{5}'
  where
    `icgm_mehvar_link` = '{1}' and 
  `icgm_channel_link` = '{0}' and
  icgm_out = '0'

	""".format(o[0][2],
		   o[0][3],
		   o[0][1],
		   prc,
		   '1',
		   today)
	py_db.executesql(sqlstr)
    for o in objects_combined_dynamic_txtsp_with_txtperc:
	prc = 0
	if o[1][1]!="":
	    prc = o[1][1]
	sqlstr = """
   UPDATE `irib`.`tbl_irib_ch_gr_meh`
SET 
  `icgm_channel_link` = '{0}',
  `icgm_out` = '{4}',
  `icgm_dateout` = '{5}'
  where
    `icgm_mehvar_link` = '{1}' and 
  `icgm_channel_link` = '{0}' and
  icgm_out = '0'
	""".format(o[0][2],
		   o[0][3],
		   o[0][1],
		   prc,
		   '1',
		   today)
	py_db.executesql(sqlstr)
    
    for o in objects_combined_txtsp_with_txtperc:
	prc = 0
	if o[1][1]!="":
	    prc = o[1][1]
	sqlstr = """
	INSERT INTO `irib`.`tbl_irib_ch_gr_meh`
            (
             `icgm_channel_link`,
             `icgm_mehvar_link`,
             `icgm_special_text`,
             `icgm_percent`,
             `icgm_out`,
             `icgm_datecreate`,
             `icgm_dateout`)
VALUES (
        '{0}',
        '{1}',
        '{2}',
        '{3}',
        '0',
        '{4}',
        (NULL)	);
	
	""".format(o[0][3],
		   o[0][2],
		   o[0][1],
		   prc,
		   today)
	
	py_db.executesql(sqlstr)
    
    for o in objects_combined_dynamic_txtsp_with_txtperc:
	prc = 0
	if o[1][1]!="":
	    prc = o[1][1]
	sqlstr = """
	INSERT INTO `irib`.`tbl_irib_ch_gr_meh`
            (
             `icgm_channel_link`,
             `icgm_mehvar_link`,
             `icgm_special_text`,
             `icgm_percent`,
             `icgm_out`,
             `icgm_datecreate`,
             `icgm_dateout`)
VALUES (
        '{0}',
        '{1}',
        '{2}',
        '{3}',
        '0',
        '{4}',
        (NULL)	);
	
	""".format(o[0][3],
		   o[0][2],
		   o[0][1],
		   prc,
		   today)
	
	py_db.executesql(sqlstr)
	print "inserted"
    print "ok"
Esempio n. 9
0
    b=b.replace('ظ','ظ')
    b=b.replace('ق','ق')
    b=b.replace('ط','ط')
    b=b.replace('پ','پ')
    b=b.replace('د','د')
    

    
        

    print b    
    return b

#print ord("د")
#print ord("د")


rows = py_db.executeAndReturnRows("select * from mehvarz")
cco = 0
for row in rows:
    r1 = prepare_farsi_alf(row[1])
    py_db.executesql("""
                     update mehvarz set
                     _text = '{0}' where id='{1}'
                     """.format(r1,row[2]))
    cco += cco
    print cco
    
    
print "succ"
Esempio n. 10
0
def add_meh_to_book(sel_meh,sel_book):
    if sel_book=="-1": return
    py_db.executesql("insert into tbl_irib_book (ib_name,ib_parent) value ((select _text from mehvarz where id={0} limit 1),{1})".format(str(sel_meh),str(sel_book)))
    print py_db.executeAndReturnRows("select ib_id from tbl_irib_book where ib_parent="+str(sel_book)+" order by ib_id desc limit 1")[0][0].__str__()+"__"+py_db.executeAndReturnRows("select _text from mehvarz where id = "+str(sel_meh))[0][0]
Esempio n. 11
0
def edit_content(_id,txt):
    py_db.executesql("update tbl_irib_book set ib_name = '{0}' where ib_id = {1}".format(txt,_id))
    print 'ok';
Esempio n. 12
0
def del_dt(_del_ins_dt_sel):
    py_db.executesql("delete from tbl_irib_book where ib_id = '{0}'".format(_del_ins_dt_sel))
    print 'thisok';
Esempio n. 13
0
def insertdt(inds,isd):
    py_db.executesql("insert into tbl_irib_book (ib_name,ib_parent) values ('{0}','{1}')".format(inds,isd));
    print py_db.executeAndReturnRows("select ib_id from tbl_irib_book order by ib_id desc limit 1")[0][0]