Exemplo n.º 1
0
def event_post_to_wall(request, event_id, group_slug=None, bridge=None):
    
    group, bridge = group_and_bridge(request)
    if group:
        is_member = group.request.user_is_member()
        events = group.content_objects(Event)
    else:
        is_member = True
        events = Event.objects.filter(object_id=None)
    
    event = get_object_or_404(events, id=event_id)
    
    if request.method == "POST":
        if  facebook_ext.has_profile(request.user):
            context = {
                "user": request.user,
                "event": event,
            }
            facebook_ext.post_wall(request.user, render_to_string("events/facebook_wall.txt", context))
            messages.add_message(request, messages.SUCCESS,
                ugettext("Success shared the event %(event_title)s on Facebook") % {
                    "event_title": event.title
                }
            )
            return HttpResponseRedirect(event.get_absolute_url())
        else:
            messages.add_message(request, messages.ERROR,
                ugettext("Link your account with a Facebook account first to enable share on Facebook feature.")
            )
            return HttpResponseRedirect(reverse('acct_facebook'))
Exemplo n.º 2
0
def post_to_wall(request, group_slug=None):
    
    calendar = get_object_or_404(Calendar, slug=group_slug)
    is_member = calendar.user_is_member(request.user)
    
    if request.method == "POST":
        if  facebook_ext.has_profile(request.user):
            context = {
                "user": request.user,
                "calendar": calendar,
            }
            facebook_ext.post_wall(request.user, render_to_string("calendars/facebook_wall.txt", context))
            messages.add_message(request, messages.SUCCESS,
                ugettext("Success shared the calendar %(calendar_name)s on Facebook") % {
                    "calendar_name": calendar.name
                }
            )
            return HttpResponseRedirect(calendar.get_absolute_url())
        else:
            messages.add_message(request, messages.ERROR,
                ugettext("Link your account with a Facebook account first to enable share on Facebook feature.")
            )
            return HttpResponseRedirect(reverse('acct_facebook'))