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


Python MEP.view方法代码示例

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


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

示例1: home

# 需要导入模块: from meps.models import MEP [as 别名]
# 或者: from meps.models.MEP import view [as 别名]
def home(request):
    #Les 7 lignes a venir sont un peu degueu
    homes = Edito.objects.all()
    if homes:
        edito_title = homes[0].edito_title
        edito = homes[0].edito
    else:
        edito_title = ''
        edito = ''

    groups = list(MEP.view('meps/groups', group=True))
    groups.sort(key=lambda group: group['value']['count'], reverse=True)

    countries = list(MEP.view('meps/countries', group=True))
    countries.sort(key=lambda group: group['value']['count'], reverse=True)

    votes = Vote.view('votes/all', descending=True)

    context = {
        'groups': groups,
        'countries': countries,
        'votes': votes,
        'edito_title': edito_title,
        'edito' : edito
    }
    return direct_to_template(request, 'home.html', context)
开发者ID:mparisot-wescale,项目名称:memopol2,代码行数:28,代码来源:views.py

示例2: index_by_country

# 需要导入模块: from meps.models import MEP [as 别名]
# 或者: from meps.models.MEP import view [as 别名]
def index_by_country(request, country_code):
    meps_by_country = list(MEP.view("meps/by_country", key=country_code))
    country_infos = MEP.view("meps/countries", key=country_code)
    meps_by_country.sort(key=lambda mep: mep["last"])

    context = {"meps": meps_by_country, "country": list(country_infos)[0]["value"]["name"]}
    return direct_to_template(request, "index.html", context)
开发者ID:stfp,项目名称:memopol2,代码行数:9,代码来源:views.py

示例3: index_by_group

# 需要导入模块: from meps.models import MEP [as 别名]
# 或者: from meps.models.MEP import view [as 别名]
def index_by_group(request, group):
    meps_by_group = MEP.view('meps/by_group', key=group)
    group_infos = MEP.view('meps/groups', key=group)
    context = {
        'meps': meps_by_group,
        'group': list(group_infos)[0]['value']['name'],
    }
    return direct_to_template(request, 'index.html', context)
开发者ID:mparisot-wescale,项目名称:memopol2,代码行数:10,代码来源:views.py

示例4: index_by_group

# 需要导入模块: from meps.models import MEP [as 别名]
# 或者: from meps.models.MEP import view [as 别名]
def index_by_group(request, group):
    meps_by_group = list(MEP.view('meps/by_group', key=group))
    group_infos = MEP.view('meps/groups', key=group)
    meps_by_group.sort(key=lambda mep: mep['last'])
    context = {
        'meps': meps_by_group,
        'group': group_infos.first()['value'],
    }
    return direct_to_template(request, 'meps/by_group.html', context)
开发者ID:nka11,项目名称:memopol2,代码行数:11,代码来源:views.py

示例5: index_by_country

# 需要导入模块: from meps.models import MEP [as 别名]
# 或者: from meps.models.MEP import view [as 别名]
def index_by_country(request, country_code):
    meps_by_country = MEP.view('meps/by_country', key=country_code)
    country_infos = MEP.view('meps/countries', key=country_code)

    context = {
        'meps': meps_by_country,
        'country': list(country_infos)[0]['value']['name'],
    }
    return direct_to_template(request, 'index.html', context)
开发者ID:mparisot-wescale,项目名称:memopol2,代码行数:11,代码来源:views.py

示例6: index_countries

# 需要导入模块: from meps.models import MEP [as 别名]
# 或者: from meps.models.MEP import view [as 别名]
def index_countries(request):
    countries = MEP.view('meps/countries')

    countries = list(MEP.view('meps/countries', group=True))
    countries.sort(key=lambda group: group['value']['count'], reverse=True)

    context = {
        'countries': countries,
    }
    return direct_to_template(request, 'index.html', context)
开发者ID:tOkeshu,项目名称:memopol2,代码行数:12,代码来源:views.py

示例7: mep_addposition

# 需要导入模块: from meps.models import MEP [as 别名]
# 或者: from meps.models.MEP import view [as 别名]
def mep_addposition(request, mep_id):
    if not request.is_ajax():
        return HttpResponseServerError()
    results = {'success':False}
    # make sure the mep exists
    mep_ = MEP.view('meps/by_id', key=mep_id).first()

    # For testing purpose: add the possibility to cause a failure in the js (if
    # in debug) to see what's would happened for the user
    try:
        text = request.GET.get(u'text', '')
        if settings.DEBUG:
            if 'slow' in text:
                time.sleep(10)
            if 'fail' in text:
                raise Exception("Simulated failure ! (input contains 'fail' and DEBUG is on)")
        pos = Position(mep_id=mep_id, content=text)
        pos.submitter_username = request.user.username
        pos.submitter_ip = request.META["REMOTE_ADDR"]
        pos.submit_datetime = datetime.today()
        pos.moderated = False
        pos.visible = False
        pos.save()
        results = {'success':True}
    except:
        pass
    return HttpResponse(simplejson.dumps(results), mimetype='application/json')
开发者ID:tOkeshu,项目名称:memopol2,代码行数:29,代码来源:views.py

示例8: mep

# 需要导入模块: from meps.models import MEP [as 别名]
# 或者: from meps.models.MEP import view [as 别名]
def mep(request, mep_id):
    mep_ = MEP.view('meps/by_id', key=mep_id).first()
    positions = Position.objects.filter(mep_id=mep_id)
    score_list = mep_.scores
    print score_list
    print "XXX"
    score_list.sort(key = lambda k : k['value'])
    print score_list
    scores = [s['value'] for s in mep_.scores]
    
    #AAAWWWFFFUUUUUULLLLLLL
    i=0
    for score in score_list:
        score_list[i] = {'label': score['label'], 'value': score['value'], 'couleur': score['value']/10}
        i+=1

    context = {
        'mep_id': mep_id,
        'mep': mep_,
        'positions': positions,
        'visible_count': len([x for x in positions if x.visible]),
        'average': sum(scores)/len(scores) if len(scores) > 0 else "",
        'score_list' : score_list,
        'color_index' : map(lambda  i : int(float(i))/10 , scores),   ## TODO color_index
        'vote_colors' : ['#ff0000', '#dd0022', '#bb0044', '#dd0022', '#bb0044', '#990066', '#770088', '#5500aa', '#3300cc', '#0000ff'],
    }
    return direct_to_template(request, 'meps/mep.html', context)
开发者ID:tOkeshu,项目名称:memopol2,代码行数:29,代码来源:views.py

示例9: index_groups

# 需要导入模块: from meps.models import MEP [as 别名]
# 或者: from meps.models.MEP import view [as 别名]
def index_groups(request):

    groups = list(MEP.view("meps/groups", group=True))
    groups.sort(key=lambda group: group["value"]["count"], reverse=True)

    context = {"groups": groups}
    return direct_to_template(request, "index.html", context)
开发者ID:stfp,项目名称:memopol2,代码行数:9,代码来源:views.py

示例10: retrieve_meps_choices

# 需要导入模块: from meps.models import MEP [as 别名]
# 或者: from meps.models.MEP import view [as 别名]
def retrieve_meps_choices():
    """
    Dynamically retrieve MEPs ids from CouchDB to propose choices in Django.
    """
    meps = MEP.view('meps/all')
    try:
        return [(mep.id, mep.doc['infos']['name']['full']) for mep in meps]
    except ResourceNotFound:
        return []
开发者ID:mparisot-wescale,项目名称:memopol2,代码行数:11,代码来源:models.py

示例11: index_groups

# 需要导入模块: from meps.models import MEP [as 别名]
# 或者: from meps.models.MEP import view [as 别名]
def index_groups(request):

    groups = list(MEP.view('meps/groups', group=True))
    groups.sort(key=lambda group: group['value']['count'], reverse=True)

    context = {
        'groups': groups,
    }
    return direct_to_template(request, 'index.html', context)
开发者ID:tOkeshu,项目名称:memopol2,代码行数:11,代码来源:views.py

示例12: mep_raw

# 需要导入模块: from meps.models import MEP [as 别名]
# 或者: from meps.models.MEP import view [as 别名]
def mep_raw(request, mep_id):
    mep_ = MEP.view('meps/by_id', key=mep_id).first()
    jsonstr = simplejson.dumps(dict(mep_), indent=4)
    context = {
        'mep_id': mep_id,
        'mep': mep_,
        'jsonstr': jsonstr,
    }
    return direct_to_template(request, 'meps/mep_raw.html', context)
开发者ID:tOkeshu,项目名称:memopol2,代码行数:11,代码来源:views.py

示例13: mep

# 需要导入模块: from meps.models import MEP [as 别名]
# 或者: from meps.models.MEP import view [as 别名]
def mep(request, mep_id):
    mep_ = MEP.view('meps/by_id', key=mep_id).first()
    positions = Position.objects.filter(mep_id=mep_id)
    context = {
        'mep_id': mep_id,
        'mep': mep_,
        'positions': positions,
        'visible_count': len([x for x in positions if x.visible]),
    }
    return direct_to_template(request, 'meps/mep.html', context)
开发者ID:snipIA,项目名称:memopol2,代码行数:12,代码来源:views.py

示例14: query

# 需要导入模块: from meps.models import MEP [as 别名]
# 或者: from meps.models.MEP import view [as 别名]
def query(request):
    form = QueryForm(request.GET)
    if not form.is_valid():
        return render_to_response('query.html')
    key=[]
    for fltr in ['commitee_filter', 'political_filter', 'country_filter']:
        val=form.cleaned_data.get(fltr)
        if val: key.append(val)
    meps = MEP.view('meps/query', startkey=key)
    return render_to_response('query.html', { 'meps': meps})
开发者ID:tOkeshu,项目名称:memopol2,代码行数:12,代码来源:views.py

示例15: query

# 需要导入模块: from meps.models import MEP [as 别名]
# 或者: from meps.models.MEP import view [as 别名]
def query(request):
    form = QueryForm(request.GET)
    if not form.is_valid():
        return render_to_response('query.html')
    key=[]
    #for fltr in ('commitee_filter', 'group_filter', 'country_filter'):
    #    val=form.cleaned_data.get(fltr)
    #    if val: key.append(val)
    key=[form.cleaned_data.get('country_filter') or u'DE',
         form.cleaned_data.get('group_filter') or u'PPE',
         form.cleaned_data.get('commitee_filter',None)]
    print key
    meps = MEP.view('meps/query', key=key)
    return render_to_response('query.html', { 'meps': meps})
开发者ID:Bouska,项目名称:memopol2,代码行数:16,代码来源:views.py


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