def index(request, country_code=None): template = 'pages/index.html' events = get_approved_events() map_events = serializers.serialize('json', events, fields=('geoposition', 'title', 'pk', 'slug', 'description', 'picture')) user_ip = get_client_ip(forwarded=request.META.get('HTTP_X_FORWARDED_FOR'), remote=request.META.get('REMOTE_ADDR')) country = get_country(country_code, user_ip) try: lan_lon = get_lat_lon_from_user_ip(user_ip) except GeoIPException: lan_lon = (58.08695, 5.58121) events = get_approved_events(order='pub_date', country_code=country.get( 'country_code', None)) all_countries = list_countries() return render_to_response(template, { 'latest_events': events, 'map_events': map_events, 'lan_lon': lan_lon, 'country': country, 'all_countries': all_countries, }, context_instance=RequestContext(request))
def map(request): template = 'pages/map.html' past = request.GET.get('past', 'no') user_ip = get_client_ip(forwarded=request.META.get('HTTP_X_FORWARDED_FOR'), remote=request.META.get('REMOTE_ADDR')) country = get_country_from_user_ip(user_ip) try: lan_lon = get_lat_lon_from_user_ip(user_ip) or (58.08695, 5.58121) except GeoIPException: lan_lon = (58.08695, 5.58121) ambassadors = get_ambassadors(country['country_code']) all_countries = list_countries() return render_to_response( template, { 'lan_lon': lan_lon, 'country': country, # all_countries minus two CUSTOM_COUNTRY_ENTRIES 'all_countries': all_countries[2:], 'past': past, 'ambassadors': ambassadors, }, context_instance=RequestContext(request))
def index(request): template = 'pages/index.html' past = request.GET.get('past', 'no') if past == 'yes': events = get_approved_events(past=True) else: events = get_approved_events() map_events = serializers.serialize('json', events, fields=('geoposition', 'title', 'pk', 'slug', 'description', 'picture')) user_ip = get_client_ip(forwarded=request.META.get('HTTP_X_FORWARDED_FOR'), remote=request.META.get('REMOTE_ADDR')) country = get_country_from_user_ip(user_ip) try: lan_lon = get_lat_lon_from_user_ip(user_ip) except GeoIPException: lan_lon = (58.08695, 5.58121) ambassadors = get_ambassadors(country['country_code']) all_countries = list_countries() return render_to_response( template, { 'map_events': map_events, 'lan_lon': lan_lon, 'country': country, # all_countries minus two CUSTOM_COUNTRY_ENTRIES 'all_countries': all_countries[2:], 'past': past, 'ambassadors': ambassadors, }, context_instance=RequestContext(request))
def search_events(request): user_ip = get_client_ip(forwarded=request.META.get('HTTP_X_FORWARDED_FOR'), remote=request.META.get('REMOTE_ADDR')) country_code = request.GET.get('country_code', None) country = get_country(country_code, user_ip) events = get_approved_events(country_code=country) if request.method == 'POST': form = SearchEventForm(request.POST) if form.is_valid(): search_filter = form.cleaned_data.get('search', None) country_filter = form.cleaned_data.get('country', None) theme_filter = form.cleaned_data.get('theme', None) audience_filter = form.cleaned_data.get('audience', None) events = get_filtered_events(search_filter, country_filter, theme_filter, audience_filter) country = {'country_code': country_filter} else: form = SearchEventForm(country_code=country['country_code']) events = get_approved_events(country_code=country['country_code']) return render_to_response('pages/search_events.html', { 'events': events, 'form': form, 'country': country['country_code'], }, context_instance=RequestContext(request))
def index(request): template = 'pages/index.html' past = request.GET.get('past', 'no') user_ip = get_client_ip(forwarded=request.META.get('HTTP_X_FORWARDED_FOR'), remote=request.META.get('REMOTE_ADDR')) country = get_country_from_user_ip(user_ip) try: lan_lon = get_lat_lon_from_user_ip(user_ip) except GeoIPException: lan_lon = (58.08695, 5.58121) ambassadors = get_ambassadors(country['country_code']) all_countries = list_countries() return render_to_response( template, { 'lan_lon': lan_lon, 'country': country, # all_countries minus two CUSTOM_COUNTRY_ENTRIES 'all_countries': all_countries[2:], 'past': past, 'ambassadors': ambassadors, }, context_instance=RequestContext(request))
def search_events(request): user_ip = get_client_ip(forwarded=request.META.get('HTTP_X_FORWARDED_FOR'), remote=request.META.get('REMOTE_ADDR')) country = get_country_from_user_ip(user_ip) events = get_approved_events(country_code=country) if request.method == 'POST': form = SearchEventForm(request.POST) if form.is_valid(): search_filter = form.cleaned_data.get('search', None) country_filter = form.cleaned_data.get('country', None) theme_filter = form.cleaned_data.get('theme', None) audience_filter = form.cleaned_data.get('audience', None) events = get_filtered_events(search_filter, country_filter, theme_filter, audience_filter) else: form = SearchEventForm(country_code=country['country_code']) events = get_approved_events(country_code=country['country_code']) return render_to_response( 'pages/search_events.html', { 'events': events, 'form': form, }, context_instance=RequestContext(request))
def index(request): template = "pages/index.html" past = request.GET.get("past", "no") user_ip = get_client_ip(forwarded=request.META.get("HTTP_X_FORWARDED_FOR"), remote=request.META.get("REMOTE_ADDR")) country = get_country_from_user_ip(user_ip) try: lan_lon = get_lat_lon_from_user_ip(user_ip) or (58.08695, 5.58121) except GeoIPException: lan_lon = (58.08695, 5.58121) ambassadors = get_ambassadors(country["country_code"]) all_countries = list_countries() return render_to_response( template, { "lan_lon": lan_lon, "country": country, # all_countries minus two CUSTOM_COUNTRY_ENTRIES "all_countries": all_countries[2:], "past": past, "ambassadors": ambassadors, }, context_instance=RequestContext(request), )
def index(request, country_code=None): template = 'pages/index.html' events = get_approved_events() map_events = serializers.serialize('json', events, fields=('geoposition', 'title', 'pk', 'slug', 'description', 'picture')) user_ip = get_client_ip(forwarded=request.META.get('HTTP_X_FORWARDED_FOR'), remote=request.META.get('REMOTE_ADDR')) country = get_country(country_code, user_ip) try: lan_lon = get_lat_lon_from_user_ip(user_ip) except GeoIPException: lan_lon = (58.08695, 5.58121) events = get_approved_events(order='pub_date', country_code=country.get('country_code', None)) all_countries = list_countries() return render_to_response( template, { 'latest_events': events, 'map_events': map_events, 'lan_lon': lan_lon, 'country': country, 'all_countries': all_countries, }, context_instance=RequestContext(request))
def search_events(request): country_code = request.GET.get('country_code', None) if not country_code: country_code = request.GET.get('country', None) if not country_code: user_ip = get_client_ip( forwarded=request.META.get('HTTP_X_FORWARDED_FOR'), remote=request.META.get('REMOTE_ADDR')) country = get_country(country_code, user_ip) country_code = country['country_code'] past = request.GET.get('past', 'no') past_events = False if past == 'yes': past_events = True search_query = request.GET.get('q', '') page = request.GET.get('page', None) theme_filter = request.GET.get('theme', None) audience_filter = request.GET.get('audience', None) template = 'pages/search_events.html' page_template = 'pages/ajax_faceted_search_events.html' form = SearchEventForm( country_code=country_code, past_events=past, search=search_query) events = get_filtered_events( search_query, country_code, theme_filter, audience_filter, past_events) if request.is_ajax(): return render_to_response( page_template, { 'events': events, 'page': page }, context_instance=RequestContext(request)) return render_to_response( template, { 'page_template': page_template, 'events': events, 'form': form, 'country': country_code, }, context_instance=RequestContext(request))
def search_events(request): country_filter = request.GET.get('country_code', None) if not country_filter: user_ip = get_client_ip( forwarded=request.META.get('HTTP_X_FORWARDED_FOR'), remote=request.META.get('REMOTE_ADDR')) country = get_country(country_filter, user_ip) country_filter = country['country_code'] past = request.GET.get('past', None) past_events = True if past and past == 'yes' else False search_query = request.GET.get('q', '') page = request.GET.get('page', None) template = 'pages/search_events.html' page_template = 'pages/ajax_faceted_search_events.html' if request.method == 'POST': form = SearchEventForm(request.POST) if form.is_valid(): search_filter = form.cleaned_data.get('search', None) country_filter = form.cleaned_data.get('country', None) theme_filter = form.cleaned_data.get('theme', None) audience_filter = form.cleaned_data.get('audience', None) past_events = form.cleaned_data.get('past_events', None) events = get_filtered_events(search_filter, country_filter, theme_filter, audience_filter, past_events) else: form = SearchEventForm(country_code=country_filter, past_events=past_events, search=search_query) events = get_filtered_events(search_filter=search_query, country_filter=country_filter, past_events=past_events) if request.is_ajax(): return render_to_response(page_template, { 'events': events, 'page': page }, context_instance=RequestContext(request)) return render_to_response(template, { 'page_template': page_template, 'events': events, 'form': form, 'country': country_filter, }, context_instance=RequestContext(request))
def search_events(request): country_filter = request.GET.get('country_code', None) if not country_filter: user_ip = get_client_ip(forwarded=request.META.get('HTTP_X_FORWARDED_FOR'), remote=request.META.get('REMOTE_ADDR')) country = get_country(country_filter, user_ip) country_filter = country['country_code'] past = request.GET.get('past', None) past_events = True if past and past=='yes' else False search_query = request.GET.get('q', '') template = 'pages/search_events.html' page_template = 'pages/ajax_faceted_search_events.html' if request.method == 'POST': form = SearchEventForm(request.POST) if form.is_valid(): search_filter = form.cleaned_data.get('search', None) country_filter = form.cleaned_data.get('country', None) theme_filter = form.cleaned_data.get('theme', None) audience_filter = form.cleaned_data.get('audience', None) past_events = form.cleaned_data.get('past_events',None) events = get_filtered_events(search_filter, country_filter, theme_filter, audience_filter, past_events) else: form = SearchEventForm(country_code=country_filter, past_events=past_events, search=search_query) events = get_filtered_events(search_filter=search_query, country_filter=country_filter, past_events=past_events) if request.is_ajax(): return render_to_response( page_template, {'events':events}, context_instance=RequestContext(request)) return render_to_response( template, { 'page_template': page_template, 'events': events, 'form': form, 'country': country_filter, }, context_instance=RequestContext(request))
def search_events(request): country_code = request.GET.get('country_code', None) if not country_code: country_code = request.GET.get('country', None) if not country_code: user_ip = get_client_ip( forwarded=request.META.get('HTTP_X_FORWARDED_FOR'), remote=request.META.get('REMOTE_ADDR')) country = get_country(country_code, user_ip) country_code = country['country_code'] past = request.GET.get('past', 'no') past_events = (past == 'yes') search_query = request.GET.get('q', '') page = request.GET.get('page', None) theme_filter = request.GET.getlist('theme', None) audience_filter = request.GET.getlist('audience', None) template = 'pages/search_events.html' page_template = 'pages/ajax_faceted_search_events.html' form = SearchEventForm(country_code=country_code, past_events=past, search=search_query, audience=audience_filter, theme=theme_filter) events = get_filtered_events(search_query, country_code, theme_filter, audience_filter, past_events) if request.is_ajax(): return render_to_response(page_template, { 'events': events, 'page': page }, context_instance=RequestContext(request)) return render_to_response(template, { 'page_template': page_template, 'events': events, 'form': form, 'country': country_code, }, context_instance=RequestContext(request))
def search_events(request): country_code = request.GET.get("country_code", None) if not country_code: country_code = request.GET.get("country", None) if not country_code: user_ip = get_client_ip( forwarded=request.META.get("HTTP_X_FORWARDED_FOR"), remote=request.META.get("REMOTE_ADDR") ) country = get_country(country_code, user_ip) country_code = country["country_code"] past = request.GET.get("past", "no") past_events = False if past == "yes": past_events = True search_query = request.GET.get("q", "") page = request.GET.get("page", None) theme_filter = request.GET.get("theme", None) audience_filter = request.GET.get("audience", None) template = "pages/search_events.html" page_template = "pages/ajax_faceted_search_events.html" form = SearchEventForm(country_code=country_code, past_events=past, search=search_query) events = get_filtered_events(search_query, country_code, theme_filter, audience_filter, past_events) if request.is_ajax(): return render_to_response( page_template, {"events": events, "page": page}, context_instance=RequestContext(request) ) return render_to_response( template, {"page_template": page_template, "events": events, "form": form, "country": country_code}, context_instance=RequestContext(request), )
def search_events(request): user_ip = get_client_ip(forwarded=request.META.get('HTTP_X_FORWARDED_FOR'), remote=request.META.get('REMOTE_ADDR')) country_code = request.GET.get('country_code', None) country = get_country(country_code, user_ip) events = get_approved_events(country_code=country) is_it_past = request.GET.get('past', 'no') if is_it_past == 'yes': past = True else: past = False if request.method == 'POST': form = SearchEventForm(request.POST) if form.is_valid(): search_filter = form.cleaned_data.get('search', None) country_filter = form.cleaned_data.get('country', None) theme_filter = form.cleaned_data.get('theme', None) audience_filter = form.cleaned_data.get('audience', None) past_events = form.cleaned_data.get('past_events',None) events = get_filtered_events(search_filter, country_filter, theme_filter, audience_filter, past_events) country = {'country_code': country_filter} if past_events: past = True else: form = SearchEventForm(country_code=country['country_code'],initial={'past_events': past}) events = get_approved_events(country_code=country['country_code'],past=past) return render_to_response( 'pages/search_events.html', { 'events': events, 'form': form, 'country': country['country_code'], 'past': past, }, context_instance=RequestContext(request))
def index(request, country_code=None): template = 'pages/index.html' events = get_approved_events() map_events = serializers.serialize('json', events, fields=('geoposition', 'title', 'pk', 'slug')) user_ip = get_client_ip(forwarded=request.META.get('HTTP_X_FORWARDED_FOR'), remote=request.META.get('REMOTE_ADDR')) if country_code and 'media' not in country_code: country_name = unicode(dict(countries)[country_code]) country = {'country_name': country_name, 'country_code': country_code} else: country = get_country_from_user_ip(user_ip) if request.is_ajax(): if request.META.get('HTTP_X_PJAX', None): template = 'pages/pjax_index.html' else: template = 'layout/all_events.html' try: lan_lon = get_lat_lon_from_user_ip(user_ip) except GeoIPException: lan_lon = (46.0608144, 14.497165600000017) events = get_approved_events(order='pub_date', country_code=country.get('country_code', None)) all_countries = list_countries() return render_to_response( template, { 'latest_events': events, 'map_events': map_events, 'lan_lon': lan_lon, 'country': country, 'all_countries': all_countries, }, context_instance=RequestContext(request))