Beispiel #1
0
def show_member(request, member, page=None):
    member = get_view_member(member)
    member.posts = member.get_posts()

    res = MemberResource()
    res_bundle = res.build_bundle(obj=member, request=request)
    member_json = res.serialize(None, res.full_dehydrate(res_bundle), 'application/json')
    args = dict(member=member, member_json=member_json, party_json=get_parties(request))
    activity_types = list(MemberActivityType.objects.all())
    types = [[t.type, _(t.name)] for t in activity_types]
    weights = {t.type: t.weight for t in activity_types}

    max_time = member.memberactivity_set.aggregate(Max("time"))['time__max']
    member_activity_end_date = max_time.date

    args['member_activity_end_date'] = member_activity_end_date
    args['activity_counts_json'] = res.serialize(None,
        member.get_activity_counts(), 'application/json')
    args['activity_types_json'] = res.serialize(None,
        types, 'application/json')
    args['activity_type_weights_json'] = res.serialize(None,
        weights, 'application/json')
    args['feed_filters'] = make_feed_filters(actor=True)
    args['feed_actions_json'] = simplejson.dumps(make_feed_actions(), ensure_ascii=False)
    kw_act = _get_member_activity_kws(member)
    kw_act_json = simplejson.dumps(kw_act, ensure_ascii=False)
    args['keyword_activity'] = kw_act_json
    template = 'member/details.html'

    return render_to_response(template, args,
        context_instance=RequestContext(request))
Beispiel #2
0
def show_member(request, member, page=None):
    member = get_view_member(member)
    member.posts = member.get_posts()

    res = MemberResource()
    res_bundle = res.build_bundle(obj=member, request=request)
    member_json = res.serialize(None, res.full_dehydrate(res_bundle),
                                'application/json')
    args = dict(member=member,
                member_json=member_json,
                party_json=get_parties(request))
    activity_types = list(MemberActivityType.objects.all())
    types = [[t.type, _(t.name)] for t in activity_types]
    weights = {t.type: t.weight for t in activity_types}

    max_time = member.memberactivity_set.aggregate(Max("time"))['time__max']
    member_activity_end_date = max_time.date

    args['member_activity_end_date'] = member_activity_end_date
    args['activity_counts_json'] = res.serialize(None,
                                                 member.get_activity_counts(),
                                                 'application/json')
    args['activity_types_json'] = res.serialize(None, types,
                                                'application/json')
    args['activity_type_weights_json'] = res.serialize(None, weights,
                                                       'application/json')
    add_feed_filters(args, actor=True)
    args['feed_actions_json'] = json.dumps(make_feed_actions(),
                                           ensure_ascii=False)
    kw_act = _get_member_activity_kws(member)
    kw_act_json = json.dumps(kw_act, ensure_ascii=False)
    args['keyword_activity'] = kw_act_json
    args['title'] = member.get_print_name()
    args['description'] = "Kansanedustajan {0} kiinnostuksen "\
        "kohteet ja aktiivisuus eduskunnassa.".format(member.get_print_name())
    template = 'member/details.html'

    if member.photo:
        args['meta_image'] = request.build_absolute_uri(member.photo.url)

    return render(request, template, args)
Beispiel #3
0
def show_member(request, member, page=None):
    member = get_view_member(member)
    member.posts = member.get_posts()

    res = MemberResource()
    res_bundle = res.build_bundle(obj=member, request=request)
    member_json = res.serialize(None, res.full_dehydrate(res_bundle), 'application/json')
    args = dict(member=member, member_json=member_json, party_json=get_parties(request))
    activity_types = list(MemberActivityType.objects.all())
    types = [[t.type, _(t.name)] for t in activity_types]
    weights = {t.type: t.weight for t in activity_types}

    max_time = member.memberactivity_set.aggregate(Max("time"))['time__max']
    member_activity_end_date = max_time.date

    args['member_activity_end_date'] = member_activity_end_date
    args['activity_counts_json'] = res.serialize(None,
        member.get_activity_counts(), 'application/json')
    args['activity_types_json'] = res.serialize(None,
        types, 'application/json')
    args['activity_type_weights_json'] = res.serialize(None,
        weights, 'application/json')
    add_feed_filters(args, actor=True)
    args['feed_actions_json'] = json.dumps(make_feed_actions(), ensure_ascii=False)
    kw_act = _get_member_activity_kws(member)
    kw_act_json = json.dumps(kw_act, ensure_ascii=False)
    args['keyword_activity'] = kw_act_json
    args['title'] = member.get_print_name()
    args['description'] = "Kansanedustajan {0} kiinnostuksen "\
        "kohteet ja aktiivisuus eduskunnassa.".format(member.get_print_name())
    template = 'member/details.html'

    if member.photo:
        args['meta_image'] = request.build_absolute_uri(member.photo.url)

    return render_to_response(template, args,
        context_instance=RequestContext(request))