2 from notes.models import *
4 def school_to_dict(school):
5 """Convert School -> Dict"""
6 s_dict = school.__dict__
9 school_dict['name'] = s_dict['name']
10 school_dict['slug'] = s_dict['slug']
11 school_dict['location'] = s_dict['location']
12 school_dict['url'] = s_dict['url']
13 school_dict['facebook_id'] = s_dict['facebook_id']
14 school_dict['id'] = s_dict['id']
18 def course_to_dict(course):
19 """Convert Course -> Dict"""
20 c_dict = course.__dict__
23 course_dict['name'] = c_dict['title']
24 course_dict['slug'] = c_dict['slug']
25 course_dict['school_id'] = c_dict['school_id']
26 # course_dict['file_count']
27 course_dict['desc'] = c_dict['desc']
28 course_dict['url'] = c_dict['url']
29 course_dict['academic_year'] = c_dict['acacemic_year']
30 # course_dict['instructor_name']
31 # course_dict['instructor_email']
32 course_dict['updated_at'] = c_dict['last_updated']
33 course_dict['id'] = c_dict['id']
36 def note_to_dict(note):
37 """Convert Note -> Dict"""
38 n_dict = note.__dict__
41 notes_dict['course_id'] = n_dict['course_id']
42 notes_dict['tags'] = [tag.name for tag in note.tags.all()]
43 notes_dict['name'] = n_dict['title']
44 notes_dict['desc'] = n_dict['description']
45 notes_dict['uploaded_at'] = n_dict['timestamp']
46 # notes_dict['file_type']
47 # notes_dict['note_file']
48 notes_dict['embed_url'] = n_dict['embed_url']
49 # notes_dict['download_url']
50 notes_dict['html'] = n_dict['html']
51 notes_dict['text'] = n_dict['text']
52 notes_dict['file_path'] = n_dict['file']
53 notes_dict['id'] = n_dict['id']