'Central method for setting content ratings.
This overwrites or creates ratings, it doesn\'t delete and expects data
of the form::
{<ratingsbodies class>: <rating class>, ...}'

@use_master
def set_content_ratings(self, data):

    from . import tasks
    if (not data):
        return
    log.info(('IARC    setting    content    ratings    for    app:%s:%s' % (self.id, self.app_slug)))
    for (ratings_body, rating) in data.items():
        (cr, created) = self.content_ratings.safer_get_or_create(ratings_body=ratings_body.id, defaults={'rating': rating.id})
        if (not created):
            cr.update(rating=rating.id, modified=datetime.datetime.now())
    log.info(('IARC    content    ratings    set    for    app:%s:%s' % (self.id, self.app_slug)))
    (geodata, c) = Geodata.objects.get_or_create(addon=self)
    save = False
    has_usk_refused = self.content_ratings.filter(ratings_body=mkt.ratingsbodies.USK.id, rating=mkt.ratingsbodies.USK_REJECTED.id).exists()
    save = (geodata.region_de_usk_exclude != has_usk_refused)
    geodata.region_de_usk_exclude = has_usk_refused
    save = (save or geodata.region_br_iarc_exclude or geodata.region_de_iarc_exclude)
    geodata.region_br_iarc_exclude = False
    geodata.region_de_iarc_exclude = False
    if ((self.status == mkt.STATUS_DISABLED) and self.iarc_purged):
        self.update(status=mkt.STATUS_PUBLIC, iarc_purged=False)
    if save:
        geodata.save()
        log.info('Un-excluding    IARC-excluded    app:%s    from    br/de')
    tasks.index_webapps.delay([self.id])
