ผลต่างระหว่างรุ่นของ "Common Functions"
ไม่มีความย่อการแก้ไข |
ไม่มีความย่อการแก้ไข |
||
บรรทัดที่ 1: | บรรทัดที่ 1: | ||
== Main Functions == | == Main Functions == | ||
'''<syntaxhighlight lang="python" id=" | '''<syntaxhighlight lang="python" id="grab_id"> | ||
grab_id(bookcode, sch_kw, models, isgl=False, datatype="data", month=None, sch_col="docno") | grab_id(bookcode, sch_kw, models, isgl=False, datatype="data", month=None, sch_col="docno") | ||
</syntaxhighlight>''' | </syntaxhighlight>''' | ||
บรรทัดที่ 18: | บรรทัดที่ 18: | ||
|} | |} | ||
'''<syntaxhighlight lang="python" id=" | '''<syntaxhighlight lang="python" id="grab_whole_doc"> | ||
grab_whole_doc(bookcode, identifiers, master_model, detail_models, isgl=False, | grab_whole_doc(bookcode, identifiers, master_model, detail_models, isgl=False, | ||
datatype="data", month=None) | datatype="data", month=None) | ||
บรรทัดที่ 37: | บรรทัดที่ 37: | ||
|} | |} | ||
'''<syntaxhighlight lang="python" id=" | '''<syntaxhighlight lang="python" id="gen_dbcommit_resp"> | ||
gen_dbcommit_resp(dbtype, tbname, model, form, perm_bit=None, allowed_action=None, | gen_dbcommit_resp(dbtype, tbname, model, form, perm_bit=None, allowed_action=None, | ||
suppress_success_msg=False, lock_on_add=True, head_id_col="id", | suppress_success_msg=False, lock_on_add=True, head_id_col="id", | ||
บรรทัดที่ 44: | บรรทัดที่ 44: | ||
{| style="margin-left:20px;" | {| style="margin-left:20px;" | ||
|- style="vertical-align:top;" | |- style="vertical-align:top;" | ||
| style="width:120px;" | '''Description''' || | | style="width:120px;" | '''Description''' || Conduct form validation and, if passed, commit the form data to database. | ||
|- style="vertical-align:top;" | |- style="vertical-align:top;" | ||
| '''Parameters''' || | | '''Parameters''' || '''DO NOT''' rely on argument order beyond ''perm_bit''. | ||
* ''' | * '''dbtype''' ''(str)'': Pointer to let CuneiFox grab the correct database file. Options include {{code|lang=python|'data'}}, {{code|lang=python|'table'}}, {{code|lang=python|'report'}}, and {{code|lang=python|'temp'}}. | ||
* ''' | * '''tbname''' ''(str)'': The database file name (without file extension). | ||
* '''model''' ''(CuneiModel)'': The model to commit to. | |||
* '''form''' ''(FlaskForm-CuneiForm)'': The form to read the committing data from. | |||
* '''perm_bit''' ''(int)'': The integer permission bit. This form of permission control is quite rigid and works well with single-table databases. | |||
* '''allowed_action''' ''({{code|lang=python|{'add':<bool>, 'edit':<bool>, 'delete':<bool>} }})'': A more complicated form of permission control. This allows for more precise control. However, it cannot be read directly from a permission database, but must be interpreted from the stored integer value upon use. | |||
* '''suppress_success_msg''' ''(bool)'': Whether to show a message on action success. | |||
* '''lock_on_add''' ''(bool)'': Lock the document upon successful add-type commit. (This works for multi-table databases by putting the current username in the '''editting''' column of the header table.) | |||
* '''head_id_col''' ''(str)'': The name of the field unique to each entry. (The field must be present both in the form and in the database table.) | |||
* '''get_dict''' ''(list)'': If provided, '''{{code|new_entry}}''' is returned as a dict instead of a CuneiModel instance. (Values from field names listed in this argument are returned as their integer references. This is useful for ForeignKeyFields.) | |||
* '''skip_validation''' ''(bool)'': Whether the form validation step is skipped. '''ONLY SET THIS IF THE FORM IS VALIDATED ELSEWHERE.''' | |||
* '''month''' ''(date or datetime)'': (Only applies for dbtype {{code|lang=python|'data'}}) The month sub-directory of the database. If not given, the program infers the month from the session time. | |||
|- style="vertical-align:top;" | |- style="vertical-align:top;" | ||
| '''Returns''' || | | '''Returns''' || | ||
* ''' | * '''db_mod_code''' ''(int or {{code|lang=python|None}})'': The returned value can be: | ||
* ''' | ** '''{{code|lang=python|None}}''': Indicate a '''permission error'''. | ||
|- | ** '''{{code|lang=python|2}}''': For a successful/failed '''addition''' attempt. | ||
** '''{{code|lang=python|3}}''': For a successful/failed '''edit''' attempt. | |||
** '''{{code|lang=python|4}}''': For a successful/failed '''deletion''' attempt. | |||
* '''new_entry''' ''(CuneiModel instance or dict or {{code|lang=python|None}})'': CuneiModel instance or a dict representing the successfully added/edited entry. Returned {{code|lang=python|None}} for a failed attempt. | |||
* '''resp_dict''' ''(dict or int)'': | |||
** '''For a successful/failed attempt''': The {{code|data}} dict to be sent to the client-side. This function takes care of the '''{{code|lang=python|'data'}}''', '''{{code|lang=python|'flash_messages'}}''', and '''{{code|lang=python|'err'}}''' keys. | |||
** '''For a permission error''': Integer '''{{code|lang=python|403}}'''. | |||
|} | |} | ||
'''<syntaxhighlight lang="python" id=" | '''<syntaxhighlight lang="python" id="prefetch_all_docs"> | ||
prefetch_all_docs(bookcode, master_spec, detail_specs, isgl=False, datatype="data", | prefetch_all_docs(bookcode, master_spec, detail_specs, isgl=False, datatype="data", | ||
month=None, headid=None, id_col="id", return_instance=False, crossers=[]) | month=None, headid=None, id_col="id", return_instance=False, crossers=[]) | ||
บรรทัดที่ 76: | บรรทัดที่ 91: | ||
|} | |} | ||
'''<syntaxhighlight lang="python" id=" | '''<syntaxhighlight lang="python" id="prep_copy"> | ||
prep_copy(cp_form, bookcode, head_model, detail_models=[], isgl=False) | prep_copy(cp_form, bookcode, head_model, detail_models=[], isgl=False) | ||
</syntaxhighlight>''' | </syntaxhighlight>''' | ||
บรรทัดที่ 94: | บรรทัดที่ 109: | ||
|} | |} | ||
'''<syntaxhighlight lang="python" id=" | '''<syntaxhighlight lang="python" id="create_doc_copy"> | ||
create_doc_copy(cp_form, copy_params, bookcode, orig_doc, head_model, detail_models={}, | create_doc_copy(cp_form, copy_params, bookcode, orig_doc, head_model, detail_models={}, | ||
isgl=False, omit_cols=[]) | isgl=False, omit_cols=[]) | ||
บรรทัดที่ 113: | บรรทัดที่ 128: | ||
|} | |} | ||
'''<syntaxhighlight lang="python" id=" | '''<syntaxhighlight lang="python" id="check_modact_stat"> | ||
check_modact_stat(modid=None, modcode=None, mode="activate", response="return") | check_modact_stat(modid=None, modcode=None, mode="activate", response="return") | ||
</syntaxhighlight>''' | </syntaxhighlight>''' | ||
บรรทัดที่ 131: | บรรทัดที่ 146: | ||
|} | |} | ||
'''<syntaxhighlight lang="python" id=" | '''<syntaxhighlight lang="python" id="process_doc_file"> | ||
process_doc_file(dbtype, tbname, model, at_form, isgl=False, month=None) | process_doc_file(dbtype, tbname, model, at_form, isgl=False, month=None) | ||
</syntaxhighlight>''' | </syntaxhighlight>''' | ||
บรรทัดที่ 149: | บรรทัดที่ 164: | ||
|} | |} | ||
'''<syntaxhighlight lang="python" id=" | '''<syntaxhighlight lang="python" id="gen_random_token"> | ||
gen_random_token(length=10, lower=True, upper=True, number=True) | gen_random_token(length=10, lower=True, upper=True, number=True) | ||
</syntaxhighlight>''' | </syntaxhighlight>''' | ||
บรรทัดที่ 186: | บรรทัดที่ 201: | ||
|} | |} | ||
'''<syntaxhighlight lang="python" id=" | '''<syntaxhighlight lang="python" id="process_doclock"> | ||
process_doclock(beacon_args, module_name, perm_name, headmodel=None, paired_gl=None) | process_doclock(beacon_args, module_name, perm_name, headmodel=None, paired_gl=None) | ||
</syntaxhighlight>''' | </syntaxhighlight>''' | ||
บรรทัดที่ 204: | บรรทัดที่ 219: | ||
|} | |} | ||
'''<syntaxhighlight lang="python" id=" | '''<syntaxhighlight lang="python" id="change_datetime"> | ||
change_datetime(form, reset=False, date_obj=None, time_obj=None) | change_datetime(form, reset=False, date_obj=None, time_obj=None) | ||
</syntaxhighlight>''' | </syntaxhighlight>''' | ||
บรรทัดที่ 223: | บรรทัดที่ 238: | ||
== Thread Functions == | == Thread Functions == | ||
'''<syntaxhighlight lang="python" id=" | '''<syntaxhighlight lang="python" id="init_task_db"> | ||
init_task_db(job_token, overall_load, new_stat="", activity_str="", | init_task_db(job_token, overall_load, new_stat="", activity_str="", | ||
suppress_request=True, further_action="") | suppress_request=True, further_action="") | ||
บรรทัดที่ 242: | บรรทัดที่ 257: | ||
|} | |} | ||
'''<syntaxhighlight lang="python" id=" | '''<syntaxhighlight lang="python" id="update_task_db"> | ||
update_task_db(job_token, finished_load=0, overall_load=None, | update_task_db(job_token, finished_load=0, overall_load=None, | ||
new_stat=None, activity_str=None, further_action=None) | new_stat=None, activity_str=None, further_action=None) | ||
บรรทัดที่ 261: | บรรทัดที่ 276: | ||
|} | |} | ||
'''<syntaxhighlight lang="python" id=" | '''<syntaxhighlight lang="python" id="read_task_db"> | ||
read_task_db(job_token) | read_task_db(job_token) | ||
</syntaxhighlight>''' | </syntaxhighlight>''' | ||
บรรทัดที่ 279: | บรรทัดที่ 294: | ||
|} | |} | ||
'''<syntaxhighlight lang="python" id=" | '''<syntaxhighlight lang="python" id="read_resus_import_file"> | ||
read_resus_import_file(job_token, will_abort=False) | read_resus_import_file(job_token, will_abort=False) | ||
</syntaxhighlight>''' | </syntaxhighlight>''' | ||
บรรทัดที่ 298: | บรรทัดที่ 313: | ||
== Printing Functions == | == Printing Functions == | ||
'''<syntaxhighlight lang="python" id=" | '''<syntaxhighlight lang="python" id="print_in_thread"> | ||
print_in_thread(job_token, doc_objs, pseudo_mapper, modcode, template_name, | print_in_thread(job_token, doc_objs, pseudo_mapper, modcode, template_name, | ||
svg_name=None, stat_cols=[], skip_company_template=False, | svg_name=None, stat_cols=[], skip_company_template=False, | ||
บรรทัดที่ 318: | บรรทัดที่ 333: | ||
|} | |} | ||
'''<syntaxhighlight lang="python" id=" | '''<syntaxhighlight lang="python" id="gen_qr"> | ||
gen_qr(num, qr_type="out", info=None) | gen_qr(num, qr_type="out", info=None) | ||
</syntaxhighlight>''' | </syntaxhighlight>''' | ||
บรรทัดที่ 336: | บรรทัดที่ 351: | ||
|} | |} | ||
'''<syntaxhighlight lang="python" id=" | '''<syntaxhighlight lang="python" id="replace_printsvg"> | ||
replace_printsvg(tbfm_mapper, modcode, bookname=None, svg_name=None, suffix=None, | replace_printsvg(tbfm_mapper, modcode, bookname=None, svg_name=None, suffix=None, | ||
job_data=None, clear_printed=True, skip_company_template=False, | job_data=None, clear_printed=True, skip_company_template=False, | ||
บรรทัดที่ 357: | บรรทัดที่ 372: | ||
== Spreadsheet Export Functions == | == Spreadsheet Export Functions == | ||
'''<syntaxhighlight lang="python" id=" | '''<syntaxhighlight lang="python" id="gen_spreadsheet"> | ||
gen_spreadsheet(specs, round_all=None, col_desc=None, col_size={}) | gen_spreadsheet(specs, round_all=None, col_desc=None, col_size={}) | ||
</syntaxhighlight>''' | </syntaxhighlight>''' | ||
บรรทัดที่ 376: | บรรทัดที่ 391: | ||
== Import & Mass Delete Functions == | == Import & Mass Delete Functions == | ||
'''<syntaxhighlight lang="python" id=" | '''<syntaxhighlight lang="python" id="docimport_to_db"> | ||
docimport_to_db(file_path, dbtype, dbname, models, specs, month=None, | docimport_to_db(file_path, dbtype, dbname, models, specs, month=None, | ||
verify_cmd=None, post_cmd=None, addi_args=[], autorun_specs=None, | verify_cmd=None, post_cmd=None, addi_args=[], autorun_specs=None, | ||
บรรทัดที่ 396: | บรรทัดที่ 411: | ||
|} | |} | ||
'''<syntaxhighlight lang="python" id=" | '''<syntaxhighlight lang="python" id="doc_mass_delete"> | ||
doc_mass_delete(dbtype, dbname, models, doc_objs=[], month=None, post_cmd=None, | doc_mass_delete(dbtype, dbname, models, doc_objs=[], month=None, post_cmd=None, | ||
job_token=None, addi_args=[], docno_to_skip=[]) | job_token=None, addi_args=[], docno_to_skip=[]) |
รุ่นแก้ไขเมื่อ 08:29, 23 กรกฎาคม 2567
Main Functions
grab_id(bookcode, sch_kw, models, isgl=False, datatype="data", month=None, sch_col="docno")
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
grab_whole_doc(bookcode, identifiers, master_model, detail_models, isgl=False,
datatype="data", month=None)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
gen_dbcommit_resp(dbtype, tbname, model, form, perm_bit=None, allowed_action=None,
suppress_success_msg=False, lock_on_add=True, head_id_col="id",
get_dict=None, skip_validation=False, month=None)
Description | Conduct form validation and, if passed, commit the form data to database. |
Parameters | DO NOT rely on argument order beyond perm_bit.
|
Returns |
|
prefetch_all_docs(bookcode, master_spec, detail_specs, isgl=False, datatype="data",
month=None, headid=None, id_col="id", return_instance=False, crossers=[])
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
prep_copy(cp_form, bookcode, head_model, detail_models=[], isgl=False)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
create_doc_copy(cp_form, copy_params, bookcode, orig_doc, head_model, detail_models={},
isgl=False, omit_cols=[])
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
check_modact_stat(modid=None, modcode=None, mode="activate", response="return")
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
process_doc_file(dbtype, tbname, model, at_form, isgl=False, month=None)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
gen_random_token(length=10, lower=True, upper=True, number=True)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
User Authentication Functions
process_beacon_args(internal_args, request)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
process_doclock(beacon_args, module_name, perm_name, headmodel=None, paired_gl=None)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
change_datetime(form, reset=False, date_obj=None, time_obj=None)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
Thread Functions
init_task_db(job_token, overall_load, new_stat="", activity_str="",
suppress_request=True, further_action="")
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
update_task_db(job_token, finished_load=0, overall_load=None,
new_stat=None, activity_str=None, further_action=None)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
read_task_db(job_token)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
read_resus_import_file(job_token, will_abort=False)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
Printing Functions
print_in_thread(job_token, doc_objs, pseudo_mapper, modcode, template_name,
svg_name=None, stat_cols=[], skip_company_template=False,
make_pdfa3=False)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
gen_qr(num, qr_type="out", info=None)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
replace_printsvg(tbfm_mapper, modcode, bookname=None, svg_name=None, suffix=None,
job_data=None, clear_printed=True, skip_company_template=False,
make_pdfa3=False)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
Spreadsheet Export Functions
gen_spreadsheet(specs, round_all=None, col_desc=None, col_size={})
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
Import & Mass Delete Functions
docimport_to_db(file_path, dbtype, dbname, models, specs, month=None,
verify_cmd=None, post_cmd=None, addi_args=[], autorun_specs=None,
job_token=None, custom_datasets=None)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
doc_mass_delete(dbtype, dbname, models, doc_objs=[], month=None, post_cmd=None,
job_token=None, addi_args=[], docno_to_skip=[])
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |