Exemplo n.º 1
0
def process_log(objects, logger):
    '''
    Server Log is used to
    - update questions asked (via dashboard.models.Screening)
    - update person, animator details (via dashboard.models.Person)
    - create a new entry for newly linked video (via dashboard.models.Video)
    '''

    for object in objects:
        logger.info(object.entry_table)
        if object.entry_table == 'Screening':
            try:
                screening_object = Screening.objects.get(id=object.model_id)
                update_questions_asked(screening_object)
                logger.info(' Added Screening Questions Asked ')
            except Screening.DoesNotExist:
                continue


#        elif object.entry_table == "PersonAdoptPractice":
#            pap_object = models.PersonAdoptPractice.objects.get(id = object.model_id)
#            populate_adoptions(pap_object)
#            logfile.write(' Added Pap ')
        elif object.entry_table == 'Video':
            try:
                video_object = Video.objects.get(id=object.model_id)
                if object.action == -1:
                    delete_video(video_object)
                    logger.info(' Deleted Video ')
                else:
                    update_website_video(video_object)
                    logger.info(' Added Video ')
            except Video.DoesNotExist:
                continue
        elif object.entry_table == 'Person':
            try:
                person_object = Person.objects.get(id=object.model_id)
                if object.action == -1:
                    delete_person(person_object)
                    logger.info(' Deleted Person ')
                elif person_object.image_exists:
                    populate_farmers(person_object)
                    logger.info(' Added Person ')
            except Person.DoesNotExist:
                continue
        elif object.entry_table == 'Animator':
            try:
                animator_object = Animator.objects.get(id=object.model_id)
                if object.action == -1:
                    delete_animator(animator_object)
                    logger.info(' Deleted Animator ')
                else:
                    populate_animators(animator_object)
                    logger.info(' Added Animator ')
            except Animator.DoesNotExist:
                continue
        logger.info('\n')
Exemplo n.º 2
0
def process_log(objects, logger):
    """
    Server Log is used to
    - update questions asked (via dashboard.models.Screening)
    - update person, animator details (via dashboard.models.Person)
    - create a new entry for newly linked video (via dashboard.models.Video)
    """

    for object in objects:
        logger.info(object.entry_table)
        if object.entry_table == "Screening":
            try:
                screening_object = Screening.objects.get(id=object.model_id)
                update_questions_asked(screening_object)
                logger.info(" Added Screening Questions Asked ")
            except Screening.DoesNotExist:
                continue
        #        elif object.entry_table == "PersonAdoptPractice":
        #            pap_object = models.PersonAdoptPractice.objects.get(id = object.model_id)
        #            populate_adoptions(pap_object)
        #            logfile.write(' Added Pap ')
        elif object.entry_table == "Video":
            try:
                video_object = Video.objects.get(id=object.model_id)
                if object.action == -1:
                    delete_video(video_object)
                    logger.info(" Deleted Video ")
                else:
                    update_website_video(video_object)
                    logger.info(" Added Video ")
            except Video.DoesNotExist:
                continue
        elif object.entry_table == "Person":
            try:
                person_object = Person.objects.get(id=object.model_id)
                if object.action == -1:
                    delete_person(person_object)
                    logger.info(" Deleted Person ")
                elif person_object.image_exists:
                    populate_farmers(person_object)
                    logger.info(" Added Person ")
            except Person.DoesNotExist:
                continue
        elif object.entry_table == "Animator":
            try:
                animator_object = Animator.objects.get(id=object.model_id)
                if object.action == -1:
                    delete_animator(animator_object)
                    logger.info(" Deleted Animator ")
                else:
                    populate_animators(animator_object)
                    logger.info(" Added Animator ")
            except Animator.DoesNotExist:
                continue
        logger.info("\n")
Exemplo n.º 3
0
    def handle(self, *args, **options):

        # Deleting all previous comments mapped to persons
        Comment.objects.all().delete()

        # Populate Animator table
        animators = Animator.objects.all()
        for obj in animators:
            populate_animators(obj)

        # Populate Comments from Screenings
        try:
            count = 1
            screenings = Screening.objects.all()
            for obj in screenings:
                update_questions_asked(obj)
                count += 1
            print count     
        except Exception as e:
            print e