Esempio n. 1
0
def displayLinkedData(value):
    if value is None:
        return None
    else:
        try:
            url = value.get_absolute_url()
        except AttributeError:
            # url = reverse('xgds_data_displayRecord',
            #               args=[field.rel.to.__module__.split('.')[0],
            #                     field.rel.to.__name__,
            #                     getattr(value,pk(value).name)])
            url = reverse('xgds_data_displayRecord',
                          args=[intmoduleName(value),
                                intmodelName(value),
                                pkValue(value)])
        try:
            return format_html(u'<A HREF="{0}">{1}</A>',mark_safe(url),unicode(value))
        except NameError:
            return mark_safe('<A HREF="' + url + '">'+ unicode(value) + '</A>')
Esempio n. 2
0
def recordList(reslog, results):
    """
    Logs a ranked list of results
    """
    if logEnabled():
        if results:
            ranks = range(1, min(201, len(results)))
            ranks.extend([(2 ** p) for p in range(8, 1 + int(floor(log(len(results), 2))))])
            ranks.append(len(results))
            items = [ResponseList(response=reslog,
                                  rank=r,
#                                  fclass=str(getListItemProperty(results[r - 1], '__class__')),
                                  fclass=goodLookingModelName(concrete_model(results[r - 1])),
#                                  fid=getFid(results[r - 1],  pk(getListItemProperty(results[r - 1], '__class__')))
                                  fid=pkValue(results[r - 1])
                                  )
                     for r in ranks]
            try:
                ResponseList.objects.bulk_create(items)
            except TypeError as e:
#                print('dlogging.py is confused by {0}'.format(getListItemProperty(results[r - 1], '__class__')))
                print('dlogging.py is confused by {0} instance'.format(goodLookingModelName(concrete_model(results[r - 1]))))
            except ValueError as e:
                print(e)