コード例 #1
0
def claim_atpostspud(request, spud_id):
    try:
        spud = SpudFromSocialMedia.objects.get(id=spud_id)
    except SpudFromSocialMedia.DoesNotExist:
        spud = None
    if spud.state == SpudFromSocialMedia.STATE_ACCEPTED:  # Don't allow dupes!
        spud = None
    template_data = {
        'spud': spud.expanded_data if spud else None,
        'spud_id': spud.id if spud else None
    }
    if request.method == "POST":
        action = request.POST.get('action', None)
        if action == "change_twitter" or action == "set_twitter":
            new_username = spud.expanded_data['user']['username']
            fan = request.current_role.entity
            fan.twitter = new_username
            fan.save()
            controller = SpudsController(request.current_role)
            controller.add_spud_from_fan(spud)
            template_data['username_changed'] = action == "change_twitter"
            template_data['username_set'] = action == "set_twitter"
    return render_to_response(
        'spudderspuds/pages/claim_atpostspud.html',
        template_data,
        context_instance=RequestContext(request))
コード例 #2
0
def claim_atpostspud(request, spud_id):
    try:
        spud = SpudFromSocialMedia.objects.get(id=spud_id)
    except SpudFromSocialMedia.DoesNotExist:
        spud = None
    if spud.state == SpudFromSocialMedia.STATE_ACCEPTED:  # Don't allow dupes!
        spud = None
    template_data = {
        'spud': spud.expanded_data if spud else None,
        'spud_id': spud.id if spud else None
    }
    if request.method == "POST":
        action = request.POST.get('action', None)
        if action == "change_twitter" or action == "set_twitter":
            new_username = spud.expanded_data['user']['username']
            fan = request.current_role.entity
            fan.twitter = new_username
            fan.save()
            controller = SpudsController(request.current_role)
            controller.add_spud_from_fan(spud)
            template_data['username_changed'] = action == "change_twitter"
            template_data['username_set'] = action == "set_twitter"
    return render_to_response('spudderspuds/pages/claim_atpostspud.html',
                              template_data,
                              context_instance=RequestContext(request))
コード例 #3
0
def is_signin_claiming_spud(request, fan, twitter, spud_id):
    if twitter:
        fan.twitter = twitter
        fan.save()
        if spud_id:
            controller = SpudsController(RoleFan(fan))
            spud = SpudFromSocialMedia.objects.get(id=spud_id)
            controller.add_spud_from_fan(spud)
            messages.success(
                request,
                "You twitter name to <b>%s</b> and you claimed your SPUD!" % twitter)
コード例 #4
0
def is_signin_claiming_spud(request, fan, twitter, spud_id):
    if twitter:
        fan.twitter = twitter
        fan.save()
        if spud_id:
            controller = SpudsController(RoleFan(fan))
            spud = SpudFromSocialMedia.objects.get(id=spud_id)
            controller.add_spud_from_fan(spud)
            messages.success(
                request,
                "You twitter name to <b>%s</b> and you claimed your SPUD!" %
                twitter)