Example #1
0
def service_feed(request, service_name):
    profile = request.profile

    if request.method == 'POST':
        message = request.POST.get('message',None)
        image_url = request.POST.get('image_url',None)
        caption = request.POST.get('caption',None)

        if not message and not image:
            return HttpResponse(status=400)

        if service_name == 'facebook':

            fb_user = FacebookUser(profile)
            fb_user.post_to_feed(message,image_url,caption)
            params = {'message':message,'image':image_url,'caption':caption}
            return render('profile/post.html', {'params':params})

        elif service_name == 'twitter':
            tw_user = TwitterUser(profile)
            tw_user.post_to_feed(message,image_url,caption)
            params = {'message':message,'image':image_url,'caption':caption}
            return render('profile/post.html', {'params':params})

    raise NotImplementedError, 'may not be used'
Example #2
0
def new(request):
    user = request.user

    existing_profile = Profile.filter('user ='******'profile_edit', profile=existing_profile.uid))

    return render('profile/new.html', {'user': user})
Example #3
0
def view(request, game_id):
    game = Game.get_by_uid(game_id)
    if game is None:
        raise Http404

    current_round = game.get_current_round()
    rounds = game.get_rounds()
    threads = current_round.get_threads(request.profile)
    player_list = [r.player for r in game.get_active_roles()]

    context = dict(profile=request.profile,
                   player_list=player_list,
                   game=game,
                   current_round=current_round,
                   rounds=rounds,
                   threads=threads)
    context['serialized'] = json_encode(context)
    return render('game/view.html', context)
Example #4
0
def index(request):
    if request.method == 'GET':
        games = Game.all()
        return render('game/list.html',
                      dict(games=games))

    elif request.method == 'POST':
        if not hasattr(request, 'user') or not request.user:
            login_url = users.create_login_url(request.get_full_path())
            return redirect(login_url)
        values = request.POST
        game = Game(name=values.get('name', 'Unnamed game'),
                    game_starter=request.profile,
                    signup_deadline=datetime.now() + timedelta(7),
                    signups=[])
        game.put()

        game.start_pregame()
        game.add_to_waitlist(request.profile)

        # redirect to the game
        return redirect('/games/%s' % game.uid)
Example #5
0
def index(request):
    if hasattr(request, 'user') and request.user:
        return render('root/index_profile.html', {'profile':request.profile})
    return render('root/index_anonymous.html')
Example #6
0
def index(request, profile_id=None):
    return render('profile/index.html')
Example #7
0
@login_required
def show(request, profile_id):
    profile = Profile.all().filter('uid =', profile_id).get()
    #bd_end_user = EndUser(end_user_login=profile.uid)

    eul = "profile:%s" % profile.uid
    c = Client(settings.BDM_SECRET, settings.BDM_KEY)
    try:
        bd_end_user = c.get('end_user/%s' % eul)[0]
    except ValueError, e:
        payload = dict(end_user_login=eul)
        bd_end_user = c.post('end_user', payload=payload)[0]

    if profile.uid == request.profile.uid:
        is_editable = True
        return render('profile/show.html', {'bd_end_user':bd_end_user, 'is_editable':is_editable})

    return render('profile/show.html', {'bd_end_user':bd_end_user})

@login_required
def edit(request):
    profile = request.profile

    # The user might have deauthorized us, try and grab their
    # profile with the access token we've stored
    try:
        # Grab the users profile from facebook to get their UID
        graph = facebook.GraphAPI(profile.fb_token)
        user = graph.get_object("me")
    except facebook.GraphAPIError, e:
        profile.fb_token = ''
Example #8
0
def test(request, game_id, round_id, thread_id):
    return render('test.html', dict(game_id=game_id,
                                    round_id=round_id,
                                    thread_id=thread_id))