Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
EssentialModule, EssentialModuleSerializer, EssentialModuleViewSet, )
""" Model storing information about universities """
max_digits=10, decimal_places=6, validators=[MinValueValidator(-85.05112878), MaxValueValidator(85.05112878)], )
max_digits=10, decimal_places=6, validators=[MinValueValidator(-180), MaxValueValidator(180)], )
# a bit of denormalization
return {"lat": self.main_campus_lat, "lon": self.main_campus_lon}
"name", "acronym", "logo", "website", "city", "country", "main_campus_lat", "main_campus_lon", "denormalized_infos", ) "city", "country", "main_campus_lat", "main_campus_lon", "denormalized_infos", )
logger.info("Computing the denormalized offers/semester/major in university") for university in University.objects.all().prefetch_related( "offers", "exchanges", "corresponding_utc_partners" ): semesters_majors_minors = dict()
# handling of offers for offer in university.offers.all(): semester = "{}{}".format(offer.semester, offer.year) if semester not in semesters_majors_minors.keys(): semesters_majors_minors[semester] = dict() majors = offer.majors if majors is not None: possibilities = set( map(lambda s: s.lstrip().rstrip(), majors.split(",")) ) for major in possibilities: # No minors in offers semesters_majors_minors[semester][major] = list()
# handling of exchanges for exchange in university.exchanges.all(): semester = "{}{}".format(exchange.semester, exchange.year) if semester not in semesters_majors_minors.keys(): semesters_majors_minors[semester] = dict() major = exchange.student_major minor = exchange.student_minor if major is not None: if major not in semesters_majors_minors[semester].keys(): semesters_majors_minors[semester][major] = list() if ( minor is not None and minor not in semesters_majors_minors[semester][major] ): semesters_majors_minors[semester][major].append(minor)
# handling of corresponding_utc_partners is_destination_open = ( university.corresponding_utc_partners.filter( is_destination_open=True ).count() > 0 )
university.denormalized_infos = dict( is_destination_open=is_destination_open, semesters_majors_minors=semesters_majors_minors, ) university.save()
logger.info("Done the denormalized offers/semester/major in university") |