Ejemplo n.º 1
0
def json_cities(request, country=None):
    """ return all cities for given country in format [[PK, __str___],...] """
    if country is None:
        filter = City.objects.all()  # IGNORE:E1101
    else:
        filter = City.objects.filter(country=country)  # IGNORE:E1101
    return response_from_filter(filter)
Ejemplo n.º 2
0
def json_contacts(request, country=None, city=None):
    """ return all contacts for given country and city in format [[PK, __str___],...] """
    exclude = request.GET.get("exclude_by", None)
    contacts = Contact.objects.all()  # IGNORE:E1101
    if country is not None and int(country):
        contacts = contacts.filter(country=country)
    if city is not None and int(city):
        contacts = contacts.filter(city=city)
    if exclude is not None and int(exclude):
        contacts = contacts.exclude(id=exclude)
    return response_from_filter(contacts)
Ejemplo n.º 3
0
def json_countries(request):
    """ return all countries in format [[PK, __str___],...] """
    return response_from_filter(Country.objects.all())  # IGNORE:E1101