Exemplo n.º 1
0
def track_get(request):
    # TODO: Check user
    user = User.objects.get(id=request.user.id)
    try:
        track_id = request.POST['track_id']
    except:
        track_id = request.GET['track_id']
    track = TrackContainer.objects.get(id=track_id)
    track_content = get_track_content_display(track, True)
    return HttpResponse(str(track_content).replace("'",'"'),"json")
Exemplo n.º 2
0
def get_main_track_content(security, ascending = True,  display = False, divisor = 1.0):
    nav_value = Attributes.objects.get(identifier='NUM_TYPE_NAV', active=True)
    final_status = Attributes.objects.get(identifier='NUM_STATUS_FINAL', active=True)
    official_type = Attributes.objects.get(identifier='PRICE_TYPE_OFFICIAL', active=True)
    provider = security.associated_companies.filter(role__identifier='SCR_DP')
    if provider.exists():
        provider = provider[0]
        try:
            track = TrackContainer.objects.get(
                effective_container_id=security.id,
                type__id=nav_value.id,
                quality__id=official_type.id,
                source__id=provider.company.id,
                frequency__id=security.frequency.id,
                frequency_reference=security.frequency_reference,
                status__id=final_status.id)
            return get_track_content_display(track, ascending, False) if display else get_track_content(track, ascending, divisor)
        except:
            LOGGER.warn("No track found for container [" + str(security.id) + "]")
    return None
Exemplo n.º 3
0
def universe_details_edit(request):
    if request.POST.has_key('universe_id'):
        universe_id = request.POST['universe_id']
    else:
        universe_id = request.GET['universe_id']
    # TODO: Check user
    user = User.objects.get(id=request.user.id)
    try:
        source = Universe.objects.get(Q(id=universe_id),Q(public=True)|Q(owner__id=request.user.id))
    except:
        # TODO: Return error message
        return redirect('universes.html')
    context = {'universe': source, 'tracks': {}}
    
    nav_value = Attributes.objects.get(identifier='NUM_TYPE_NAV', active=True)
    final_status = Attributes.objects.get(identifier='NUM_STATUS_FINAL', active=True)
    official_type = Attributes.objects.get(identifier='PRICE_TYPE_OFFICIAL', active=True)
    monthly = Attributes.objects.get(identifier='FREQ_MONTHLY', active=True)
    for member in source.members.all():
        if member.type.identifier not in ['CONT_COMPANY', 'CONT_BACKTEST', 'CONT_PORTFOLIO', 'CONT_COMPANY', 'CONT_OPERATION', 'CONT_PERSON', 'CONT_UNIVERSE']:
            effective_class_name = Attributes.objects.get(identifier=member.type.identifier + '_CLASS', active=True).name
            effective_class = classes.my_class_import(effective_class_name)
            member = effective_class.objects.get(id=member.id)
            provider = member.associated_companies.filter(role__identifier='SCR_DP')
            if provider.exists():
                provider = provider[0]
                try:
                    track = TrackContainer.objects.get(
                        effective_container_id=member.id,
                        type__id=nav_value.id,
                        quality__id=official_type.id,
                        source__id=provider.company.id,
                        frequency__id=monthly.id,
                        status__id=final_status.id)
                    context['tracks']['track_' + str(member.id)] = get_track_content_display(track)
                except:
                    LOGGER.warn("No track found for container [" + str(member.id) + "]")
                    context['tracks']['track_' + str(member.id)] = []
    return render(request, 'universe_details_edit.html', context)