コード例 #1
0
ファイル: views.py プロジェクト: daniel-cussen/canubring
def trips(request, template, profile_attr='current_trips'):
    ctxt = dict()
    ctxt['trips'] = listing(request, getattr(request.user.userprofile, profile_attr))
    ctxt['past_trips'] = profile_attr == 'past_trips'
    if request.GET.get('m') == '1':
        ctxt['show_new_trip_sys_msg'] = True
    return render(request, template, ctxt)
コード例 #2
0
ファイル: views.py プロジェクト: daniel-cussen/canubring
def search(request, template):
    ctxt = dict()
    now = datetime.datetime.now()
    trip_results = Trip.objects.filter(destination_dt__gte=now)

    active_dep_countries = Country.objects.filter(dep_country_trips__in=trip_results).distinct().order_by('name')
    active_dest_countries = Country.objects.filter(dest_country_trips__in=trip_results).distinct().order_by('name')
    ctxt['active_dep_countries'] = active_dep_countries
    ctxt['active_dest_countries'] = active_dest_countries

    departure_country_complex_lookup = None
    departure_country = request.GET.get('departure_country', None)
    if departure_country:
        ctxt['departure_country'] = int(departure_country)
        departure_country_complex_lookup = (Q(dep_country__id=departure_country))

    destination_country_complex_lookup = None
    destination_country = request.GET.get('destination_country', None)
    if destination_country:
        ctxt['destination_country'] = int(destination_country)
        destination_country_complex_lookup = (Q(dest_country__id=destination_country))

    departure_city_complex_lookup = None
    departure_city = request.GET.get('departure_city', None)
    if departure_city:
        ctxt['departure_city'] = int(departure_city)
        departure_city_complex_lookup = (Q(dep_city__id=departure_city))

    destination_city_complex_lookup = None
    destination_city = request.GET.get('destination_city', None)
    if destination_city:
        ctxt['destination_city'] = int(destination_city)
        destination_city_complex_lookup = (Q(dest_city__id=destination_city))

    if departure_country_complex_lookup:
        trip_results = trip_results.filter(departure_country_complex_lookup)
    if destination_country_complex_lookup:
        trip_results = trip_results.filter(destination_country_complex_lookup)
    if departure_city_complex_lookup:
        trip_results = trip_results.filter(departure_city_complex_lookup)
    if destination_city_complex_lookup:
        trip_results = trip_results.filter(destination_city_complex_lookup)

    active_dep_cities = City.objects.filter(dep_city_trips__in=trip_results).distinct().order_by('name')
    active_dest_cities = City.objects.filter(dest_city_trips__in=trip_results).distinct().order_by('name')
    ctxt['active_dep_cities'] = active_dep_cities
    ctxt['active_dest_cities'] = active_dest_cities

    trips = listing(request, trip_results.order_by('destination_dt'))
    ctxt['trips'] = trips
    return render(request, template, ctxt)
コード例 #3
0
ファイル: views.py プロジェクト: daniel-cussen/canubring
def evaluations(request, template, profile_attr='get_reviews_about_me'):
    ctxt = dict()
    ctxt['reviews'] = listing(request, getattr(request.user.userprofile, profile_attr))
    ctxt['reviews_by_me'] = profile_attr == 'get_all_reviews_by_me'
    return render(request, template, ctxt)
コード例 #4
0
ファイル: views.py プロジェクト: daniel-cussen/canubring
def cargos(request, template, profile_attr='current_cargos'):
    ctxt = dict()
    ctxt['my_cargos'] = True
    ctxt['cargos'] = listing(request, getattr(request.user.userprofile, profile_attr))
    ctxt['past_cargos'] = profile_attr == 'past_cargos'
    return render(request, template, ctxt)