Skip to content

Commit

Permalink
ddd
Browse files Browse the repository at this point in the history
  • Loading branch information
AthulyaMS committed Jan 8, 2024
1 parent d7a67c7 commit 9baae58
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
16 changes: 9 additions & 7 deletions app/crud/nlp_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ def project_suggest_translations(db_:Session, project_id, books, #pylint: disabl
raise NotAvailableException(f"Project with id, {project_id}, not found")
draft_rows = projects_crud.obtain_project_source(db_, project_id, books, sentence_id_range,
sentence_id_list, with_draft=True)
draft_rows = draft_rows['db_content']
# draft_rows = draft_rows['db_content']
if confirm_all:
for row in draft_rows:
for i, meta in enumerate(row.draftMeta):
Expand All @@ -812,12 +812,14 @@ def project_suggest_translations(db_:Session, project_id, books, #pylint: disabl
updated_drafts = auto_translate(**args)
db_.add_all(updated_drafts)
project_row.updatedUser = user_id
project_row.updateTime = datetime.now(ist_timezone).strftime('%Y-%m-%d %H:%M:%S')
response = {
'db_content':updated_drafts,
'project_content':project_row
}
return response
db_.commit()
# project_row.updateTime = datetime.now(ist_timezone).strftime('%Y-%m-%d %H:%M:%S')
# response = {
# 'db_content':updated_drafts,
# 'project_content':project_row
# }
# return response
return updated_drafts

def edit_glossary(db_: Session,token_info):
'''updates the given information of a gloss in db'''
Expand Down
20 changes: 12 additions & 8 deletions app/crud/projects_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,12 +406,12 @@ def obtain_project_draft(db_:Session, project_id, books, sentence_id_list, sente
raise NotAvailableException(f"Project with id, {project_id}, not found")
draft_rows = obtain_project_source(db_, project_id, books, sentence_id_list,
sentence_id_range, with_draft=True)
draft_rows = draft_rows['db_content']
# draft_rows = draft_rows['db_content']
if output_format == schemas_nlp.DraftFormats.USFM :
draft_out = nlp_crud.create_usfm(draft_rows)
# elif output_format == schemas_nlp.DraftFormats.JSON:
# draft_out = nlp_crud.export_to_json(project_row.sourceLanguage,
# project_row.targetLanguage, draft_rows, None)
elif output_format == schemas_nlp.DraftFormats.JSON:
draft_out = nlp_crud.export_to_json(project_row.sourceLanguage,
project_row.targetLanguage, draft_rows, None)
elif output_format == schemas_nlp.DraftFormats.PRINT:
draft_out = nlp_crud.export_to_print(draft_rows)
else:
Expand All @@ -427,8 +427,12 @@ def update_project_draft(db_:Session, project_id, sentence_list, user_id):
sentence_id_list = [sent.sentenceId for sent in sentence_list]
source_resp = obtain_project_source(db_, project_id,
sentence_id_list=sentence_id_list, with_draft=True)
project_row = source_resp['project_content']
sentences = source_resp['db_content']
# project_row = source_resp['project_content']
project_row = db_.query(db_models.TranslationProject).get(project_id)
if not project_row:
raise NotAvailableException(f"Project with id, {project_id}, not found")
sentences = source_resp
# sentences = source_resp['db_content']
for input_sent in sentence_list:
sent = None
for read_sent in sentences:
Expand Down Expand Up @@ -474,7 +478,7 @@ def obtain_project_progress(db_, project_id, books, sentence_id_list, sentence_i
raise NotAvailableException(f"Project with id, {project_id}, not found")
draft_rows = obtain_project_source(db_, project_id, books, sentence_id_list,
sentence_id_range, with_draft=True)
draft_rows = draft_rows["db_content"]
# draft_rows = draft_rows["db_content"]
confirmed_length = 0
suggestions_length = 0
untranslated_length = 0
Expand Down Expand Up @@ -588,7 +592,7 @@ def get_project_source_per_token(db_:Session, project_id, token, occurrences): #
sent_ids = [occur.sentenceId for occur in occurrences]
draft_rows = obtain_project_source(db_, project_id,
sentence_id_list=sent_ids, with_draft=True)
draft_rows = draft_rows['db_content']
# draft_rows = draft_rows['db_content']
occur_list = []
for occur in occurrences:
occur_list.append(occur.__dict__)
Expand Down

0 comments on commit 9baae58

Please sign in to comment.