forked from sunnah-com/api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
51 lines (44 loc) · 1.48 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from flask_sqlalchemy import SQLAlchemy
from main import app
db = SQLAlchemy(app)
db.reflect()
class HadithCollection(db.Model):
__tablename__ = 'Collections'
def serialize(self):
return {
'name': self.name,
'has_books': self.hasbooks,
'title_en': self.englishTitle,
'title_ar': self.arabicTitle,
'num_hadith': self.numhadith,
'total_hadith': self.totalhadith,
'has_chapters': self.haschapters,
'short_intro': self.shortintro,
}
class Book(db.Model):
__tablename__ = 'BookData'
def serialize(self):
return {
'book_id': self.ourBookID,
'book_name_en': self.englishBookName,
'book_name_ar': self.arabicBookName,
'first_number': self.firstNumber,
'last_number': self.lastNumber,
'total_number': self.totalNumber
}
class Hadith(db.Model):
__tablename__ = 'HadithTable'
def serialize(self):
return {
'collection': self.collection,
'book_id': self.bookID,
'bab_number': str(self.babNumber),
'hadith_number': self.hadithNumber,
'bab_name_en': self.englishBabName,
'text_en': self.englishText,
'urn_ar': self.arabicURN,
'bab_name_ar': self.arabicBabName,
'text_ar': self.arabicText,
'grade_ar': self.arabicgrade1,
'grade_en': self.englishgrade1,
}