示例#1
0
def bandpage(request, band_url):
    band = get_object_or_404(Band, url=band_url)
    contributing_members = BandMember.objects.filter(band=band, role__in=(BandMember.BAND_MEMBER, BandMember.MANAGER))
    other_members = BandMember.objects.filter(band=band).exclude(role__in=(BandMember.BAND_MEMBER, BandMember.MANAGER, BandMember.BANNED))
    songs = Song.objects.filter(Q(band=band), Q(is_open_for_comments=True)|Q(is_open_source=True)).order_by('-date_added')[:10]
    song_data = json_dump([song.to_dict(chains=['band', 'comment_node', 'studio']) for song in songs])
    user_data = json_dump(request.user.get_profile().to_dict())
    return render_to_response('bandpage.html', locals(), context_instance=RequestContext(request))
示例#2
0
def userpage(request, username):
    target_user = get_object_or_404(User, username=username)
    members = BandMember.objects.filter(user=target_user).order_by('-space_donated')
    songs = Song.objects.filter(Q(owner=target_user), Q(is_open_for_comments=True)|Q(is_open_source=True)).order_by('-date_added')[:10]
    song_data = json_dump([song.to_dict(chains=['band', 'comment_node', 'studio']) for song in songs])
    if request.user.is_authenticated():
        user_data = json_dump(request.user.get_profile().to_dict())
    else:
        user_data = 'null'
    return render_to_response('userpage.html', locals(), context_instance=RequestContext(request))
示例#3
0
def bandpage(request, band_url):
    band = get_object_or_404(Band, url=band_url)
    contributing_members = BandMember.objects.filter(
        band=band, role__in=(BandMember.BAND_MEMBER, BandMember.MANAGER))
    other_members = BandMember.objects.filter(band=band).exclude(
        role__in=(BandMember.BAND_MEMBER, BandMember.MANAGER,
                  BandMember.BANNED))
    songs = Song.objects.filter(
        Q(band=band),
        Q(is_open_for_comments=True)
        | Q(is_open_source=True)).order_by('-date_added')[:10]
    song_data = json_dump([
        song.to_dict(chains=['band', 'comment_node', 'studio'])
        for song in songs
    ])
    user_data = json_dump(request.user.get_profile().to_dict())
    return render_to_response('bandpage.html',
                              locals(),
                              context_instance=RequestContext(request))
示例#4
0
def userpage(request, username):
    target_user = get_object_or_404(User, username=username)
    members = BandMember.objects.filter(
        user=target_user).order_by('-space_donated')
    songs = Song.objects.filter(
        Q(owner=target_user),
        Q(is_open_for_comments=True)
        | Q(is_open_source=True)).order_by('-date_added')[:10]
    song_data = json_dump([
        song.to_dict(chains=['band', 'comment_node', 'studio'])
        for song in songs
    ])
    if request.user.is_authenticated():
        user_data = json_dump(request.user.get_profile().to_dict())
    else:
        user_data = 'null'
    return render_to_response('userpage.html',
                              locals(),
                              context_instance=RequestContext(request))
示例#5
0
                err_msg = design.you_dont_have_enough_space_to_do_that

    plan = profile.plan
    if plan is None:
        plan = {
            'title': 'Free',
            'band_count_limit': settings.FREE_BAND_LIMIT,
            'usd_per_month': 0,
            'total_space': 0,
        }
    memberships = BandMember.objects.filter(user=user).exclude(role=BandMember.BANNED).order_by('-space_donated')

    user_data = profile.to_dict(access=SerializableModel.OWNER)
    user_data['space_used'] = profile.space_used()
    user_data['bands_in_count'] = profile.bands_in_count()
    user_data = json_dump(user_data);
    def member_to_dict(member):
        data = member.to_dict(access=SerializableModel.OWNER)
        data['band'] = member.band.to_dict(access=SerializableModel.OWNER)
        return data
    membership_data = json_dump([member_to_dict(member) for member in memberships])

    return render_to_response('account/plan.html', locals(), context_instance=RequestContext(request))

@login_required
def account_email(request):
    user = request.user
    profile = user.get_profile()
    if request.method == 'POST':
        form = EmailSubscriptionsForm(request.POST)
        if form.is_valid():
示例#6
0
    plan = profile.plan
    if plan is None:
        plan = {
            'title': 'Free',
            'band_count_limit': settings.FREE_BAND_LIMIT,
            'usd_per_month': 0,
            'total_space': 0,
        }
    memberships = BandMember.objects.filter(user=user).exclude(
        role=BandMember.BANNED).order_by('-space_donated')

    user_data = profile.to_dict(access=SerializableModel.OWNER)
    user_data['space_used'] = profile.space_used()
    user_data['bands_in_count'] = profile.bands_in_count()
    user_data = json_dump(user_data)

    def member_to_dict(member):
        data = member.to_dict(access=SerializableModel.OWNER)
        data['band'] = member.band.to_dict(access=SerializableModel.OWNER)
        return data

    membership_data = json_dump(
        [member_to_dict(member) for member in memberships])

    return render_to_response('account/plan.html',
                              locals(),
                              context_instance=RequestContext(request))


@login_required