def __importFHeads(self, zip, fingerprint, replacing):
        fheads = json.loads(zip.read('fheads.json'),
                            object_hook=json_util.object_hook)
        tmap = None
        before = None

        if replacing:
            tmap = {}

        for head in fheads:

            this_head = FingerprintHead()

            if replacing:
                head['fingerprint_id_id'] = fingerprint.id

                before = head['id']
                del head['id']

            this_head.__dict__.update(head)

            this_head.save()

            if replacing:
                tmap[before] = this_head.id

        return tmap
Example #2
0
    def __importFHeads(self, zip ,fingerprint , replacing):
        fheads = json.loads(zip.read('fheads.json'), object_hook=json_util.object_hook)
        tmap = None
        before = None

        if replacing:
            tmap = {}

        for head in fheads:

            this_head = FingerprintHead()

            if replacing:
                head['fingerprint_id_id'] = fingerprint.id

                before = head['id']
                del head['id']

            this_head.__dict__.update(head)

            this_head.save()

            if replacing:
                tmap[before] = this_head.id


        return tmap
def generateWeekReport(fingerprint, newsletter):

    returnable = {}

    latest_check = timezone.now() - timedelta(days=7)

    fh = FingerprintHead.objects.filter(fingerprint_id=fingerprint,
                                        date__gte=latest_check)

    if len(fh) == 0:
        returnable['db_changes'] = None
    else:
        returnable['db_changes'] = render_to_string(
            'subscriptions/fingerprint_changes.html', {
                'base_url': settings.BASE_URL,
                'changes': FingerprintHead.mergeChanges(fh),
                'fingerprint': fingerprint.fingerprint_hash
            })

    discussion = Comment.objects.filter(object_pk=fingerprint.id,
                                        submit_date__gte=latest_check)
    if not config.discussion or len(discussion) == 0:
        returnable['discussion'] = None
    else:
        returnable['discussion'] = render_to_string(
            'subscriptions/discussion_changes.html', {
                'base_url': settings.BASE_URL,
                'discussions': discussion,
                'fingerprint': fingerprint.fingerprint_hash
            })

    characteristic = Characteristic.objects.filter(
        created_date__gte=latest_check).order_by('-created_date')
    if not config.population_characteristics or len(characteristic) == 0:
        returnable['characteristic'] = None
    else:
        returnable['characteristic'] = render_to_string(
            'subscriptions/pop_changes.html', {
                'base_url': settings.BASE_URL,
                'pop': characteristic
            })

    return returnable
Example #4
0
def generateWeekReport(fingerprint, newsletter):

    returnable = {}

    latest_check = timezone.now() - timedelta(days=7)

    fh = FingerprintHead.objects.filter(fingerprint_id = fingerprint, date__gte = latest_check)

    if len(fh) == 0:
        returnable['db_changes'] = None
    else:
        returnable['db_changes'] = render_to_string('subscriptions/fingerprint_changes.html', {
                                        'base_url': settings.BASE_URL,
                                        'changes': FingerprintHead.mergeChanges(fh),
                                        'fingerprint': fingerprint.fingerprint_hash
                                    })

    discussion = Comment.objects.filter(object_pk = fingerprint.id, submit_date__gte = latest_check)
    if not config.discussion or len(discussion) == 0:
        returnable['discussion'] = None
    else:
        returnable['discussion'] = render_to_string('subscriptions/discussion_changes.html', {
                                        'base_url': settings.BASE_URL,
                                        'discussions': discussion,
                                        'fingerprint': fingerprint.fingerprint_hash
                                    })

    characteristic = Characteristic.objects.filter(created_date__gte = latest_check).order_by('-created_date')
    if not config.population_characteristics or len(characteristic) == 0:
        returnable['characteristic'] = None
    else:
        returnable['characteristic'] = render_to_string('subscriptions/pop_changes.html', {
                                        'base_url': settings.BASE_URL,
                                        'pop': characteristic
                                    })

    return returnable