Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes in reference validation #701

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions app/crud/contents_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def get_parascripturals(db_:Session, resource_name, category=None, title=None,**
}
return response

def upload_parascripturals(db_: Session, resource_name, parascriptural, user_id=None):
def upload_parascripturals(db_: Session, resource_name, parascriptural, user_id=None):#pylint: disable=too-many-branches
'''Adds rows to the parascripturals table specified by resource_name'''
resource_db_content = db_.query(db_models.Resource).filter(
db_models.Resource.resourceName == resource_name).first()
Expand All @@ -431,13 +431,16 @@ def upload_parascripturals(db_: Session, resource_name, parascriptural, user_id=
#setting verseNumber to 000 if its not present
ref_start = utils.create_decimal_ref_id(db_,ref['book'],ref['chapter'],0)
ref['verseNumber'] = 0
if ref['verseEnd'] is not None:
ref_end = utils.create_decimal_ref_id(
db_,ref['bookEnd'],ref['chapterEnd'],ref['verseEnd'])
if ref['bookEnd'] is not None:
if ref['chapterEnd'] is not None and ref['verseEnd'] is not None:
ref_end = utils.create_decimal_ref_id(
db_,ref['bookEnd'],ref['chapterEnd'],ref['verseEnd'])
else:
#setting verseEnd to 999 if its not present
ref_end = utils.create_decimal_ref_id(db_,ref['bookEnd'],ref['chapterEnd'],999)
ref['verseEnd'] = 999
else:
#setting verseEnd to 999 if its not present
ref_end = utils.create_decimal_ref_id(db_,ref['bookEnd'],ref['chapterEnd'],999)
ref['verseEnd'] = 999
ref_end = None
else:
ref = None
ref_end = None
Expand Down Expand Up @@ -596,7 +599,7 @@ def get_audio_bible(db_:Session, resource_name, name=None,**kwargs): #pylint: di
}
return response

def upload_audio_bible(db_: Session, resource_name, audiobibles, user_id=None):
def upload_audio_bible(db_: Session, resource_name, audiobibles, user_id=None):#pylint: disable=too-many-branches
'''Adds rows to the audio bibles table specified by resource_name'''
resource_db_content = db_.query(db_models.Resource).filter(
db_models.Resource.resourceName == resource_name).first()
Expand All @@ -617,13 +620,16 @@ def upload_audio_bible(db_: Session, resource_name, audiobibles, user_id=None):
#setting verseNumber to 000 if its not present
ref_start = utils.create_decimal_ref_id(db_,ref['book'],ref['chapter'],0)
ref['verseNumber'] = 0
if ref['verseEnd'] is not None:
ref_end = utils.create_decimal_ref_id(
db_,ref['bookEnd'],ref['chapterEnd'],ref['verseEnd'])
if ref['bookEnd'] is not None:
if ref['chapterEnd'] is not None and ref['verseEnd'] is not None:
ref_end = utils.create_decimal_ref_id(
db_,ref['bookEnd'],ref['chapterEnd'],ref['verseEnd'])
else:
#setting verseEnd to 999 if its not present
ref_end = utils.create_decimal_ref_id(db_,ref['bookEnd'],ref['chapterEnd'],999)
ref['verseEnd'] = 999
else:
#setting verseEnd to 999 if its not present
ref_end = utils.create_decimal_ref_id(db_,ref['bookEnd'],ref['chapterEnd'],999)
ref['verseEnd'] = 999
ref_end = None
else:
ref = None
ref_end = None
Expand Down
7 changes: 4 additions & 3 deletions app/schema/schema_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ def check_verses(cls, val, values): # pylint: disable=E0213
@validator('chapterEnd')
def check_chapter_range(cls, val, values): # pylint: disable=E0213
'''chapter start should be less than or equal to chapter end'''
if 'chapter' in values and val < values['chapter']:
raise ValueError('chapter start should be less than or equal to chapter end')
return val
if val is not None:
if 'chapter' in values and val < values['chapter']:
raise ValueError('chapter start should be less than or equal to chapter end')
return val
def check_verse_range(cls, val, values): # pylint: disable=E0213
'''verse start should be less than or equal to verse end'''
if 'verseNumber' in values and val < values['verseNumber']:
Expand Down