当前位置: 首页>>代码示例>>Python>>正文


Python Author.from_slug方法代码示例

本文整理汇总了Python中models.Author.from_slug方法的典型用法代码示例。如果您正苦于以下问题:Python Author.from_slug方法的具体用法?Python Author.from_slug怎么用?Python Author.from_slug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Author的用法示例。


在下文中一共展示了Author.from_slug方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ajax_graph

# 需要导入模块: from models import Author [as 别名]
# 或者: from models.Author import from_slug [as 别名]
def ajax_graph(request):
    INSTANCE = get_instance(request)
    #instance = request.GET.get('instance', '')
    #if instance not in INSTANCES:
    #    raise Http404
    
    #instance = INSTANCES[settings.INSTANCE]
    
    #tag = request.GET.get('tag', '')
    #if not tag:
    print INSTANCE
    network = request.GET.get('network')
    if network == 'authors':
        return ajax_graph_authors(request)
    elif network == 'properties':
        return ajax_graph_properties(request)
    
    
    
    border_w = float(request.GET.get('borderW'))
    border_n = float(request.GET.get('borderN'))
    border_e = float(request.GET.get('borderE'))
    border_s = float(request.GET.get('borderS'))
    author_id = request.GET.get('author', '')
    layout_id = request.GET.get('layout')
    #weight_id = request.GET.get('weight')
    feature = request.GET.get('feature')
    heatmap = request.GET.get('heatmap')
    
    #if '_' in feature:
    #    raise Http404
    #accumulated = int(request.GET.get('accumulated'))
    #print "acc: '%s'" % accumulated
    #accumulated = 1 if accumulated and accumulated != "off" else 0
    """if tag:
        tag = instance.HASHTAGS.get(tag)
        if tag is None:
            raise Http404
        tags_levels = instance.get_environment(tag, True)
        tags = []
        for level in tags_levels[:-1]:
            tags.extend(level)
        network = instance.NETWORKS[tag.tag]
        clusters, positions = network
        edges = []
        for tag in tags:
            edges.append([tag.tag, sorted(((tag.tag, count) for tag, count in tag.co_tags.iteritems()),
                key=lambda (t, c): c, reverse=True)])   
            tag.x, tag.y = positions[tag.tag]
        tags = [[tag.x, tag.y, tag.tag, tag.count, clusters[tag.tag]] for tag in tags]
        sub_tags = []
    else:"""
    
    if layout_id not in [key for name, key, dot_prog in settings.LAYOUTS]:
        raise Http404
    if author_id == '':
        #author_id = None
        author = None
        if feature not in dict(data.FEATURES[INSTANCE]):
            raise Http404
    else:
        try:
            author = Author.from_slug(author_id, INSTANCE)
        except Author.DoesNotExist:
            raise Http404
        #author_id = author.instance_name
        if feature not in dict(data.AUTHOR_FEATURES[INSTANCE]):
            raise Http404
        #print author_id
    """if author_id not in WEIGHTS:
        raise Http404
    if layout_id not in GRAPH_POSITIONS_TREE:
        raise Http404
    if author_id is None:
        tree = GRAPH_POSITIONS_TREE[layout_id]
    else:
        tree = PickledData.objects.get(settings.INSTANCE,
            'graph_positions_tree_%s_%s' % (layout_id, author_id))
    tree_id = (weight_id, accumulated)
    if tree_id not in tree:
        raise Http404
    tree = tree[tree_id]"""
    #print WEIGHTS[weight_id][accumulated].items()[:100]
    #print WEIGHTS[weight_id][accumulated]['http://who.int/icd#ICDCategory']
    
    #print "HI"
            
    STEP = 10
    categories = []
    sql = []
    sql_params = []
    for x in range(STEP):
        for y in range(STEP):
            """print (
                border_w + x * (border_e - border_w) / STEP,
                border_w + (x + 1) * (border_e - border_w) / STEP,
                border_n + y * (border_s - border_n) / STEP,
                border_n + (y + 1) * (border_s - border_n) / STEP
            )"""
            """categories_sub = tree.get(
#.........这里部分代码省略.........
开发者ID:simonwalk,项目名称:iCAT-Analytics,代码行数:103,代码来源:views.py


注:本文中的models.Author.from_slug方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。