Example #1
0
 def get_school_by_name(school_name):
     """get schoolname
     """
     schools = School.objects.filter(schoolname=school_name)
     if schools.exists():
         school = schools.last()
         headmaster_id = PermissionHelper.get_school_headmaster(school.id)
         return {
             'id': school.id,
             'schoolname': school.schoolname,
             'description': school.description,
             'headmaster': UserHelper.get_name_by_id(headmaster_id),
             'population': PermissionHelper.get_school_population(school.id)
         }
     return None
Example #2
0
 def get_school(school_id):
     """get school
     """
     if school_id == 0:
         return {
             'id': 0,
             'schoolname': '-',
             'description': '-',
             'headmaster': '-',
             'population': -1
         }
     schools = School.objects.filter(id=school_id)
     headmaster_id = PermissionHelper.get_school_headmaster(school_id)
     if schools.exists():
         school = schools.last()
         return {
             'id': school_id,
             'schoolname': school.schoolname,
             'description': school.description,
             'headmaster': UserHelper.get_name_by_id(headmaster_id),
             'population': PermissionHelper.get_school_population(school_id)
         }
     return None