def event_post_to_twitter(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 twitter_ext.has_profile(request.user): context = { "user": request.user, "event": event, } twitter_ext.post_message(request.user, render_to_string("events/twitter_message.txt", context)) messages.add_message(request, messages.SUCCESS, ugettext("Success shared the event %(event_title)s on Twitter") % { "event_title": event.title } ) return HttpResponseRedirect(event.get_absolute_url()) else: messages.add_message(request, messages.ERROR, ugettext("Link your account with a Twitter account first to enable share on Facebook feature.") ) return HttpResponseRedirect(reverse('acct_twitter'))
def post_to_twitter(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 twitter_ext.has_profile(request.user): context = { "user": request.user, "calendar": calendar, } twitter_ext.post_message(request.user, render_to_string("calendars/twitter_message.txt", context)) messages.add_message(request, messages.SUCCESS, ugettext("Success shared the calendar %(calendar_name)s on Twitter") % { "calendar_name": calendar.name } ) return HttpResponseRedirect(calendar.get_absolute_url()) else: messages.add_message(request, messages.ERROR, ugettext("Link your account with a Twitter account first to enable share on Twitter feature.") ) return HttpResponseRedirect(reverse('acct_twitter'))