예제 #1
0
파일: views.py 프로젝트: C14L/anu2
 def get_redirect_url(self, *args, **kwargs):
     q = self.request.GET.get('q', None)
     try:
         city = City.get_by_crc(q)
     except City.DoesNotExist:
         raise Http404
     return reverse('category-list-html', args=[city.tr_url])
예제 #2
0
파일: models.py 프로젝트: C14L/anu2
    def by_city(self, city):
        # city may be a pk, a url, a crc, or a City instance.
        if isinstance(city, int):
            city = City.objects.get(pk=city)
        elif isinstance(city, str) and city.count(', ') == 2:
            city = City.get_by_url(city)
        elif isinstance(city, str) and city.count('/') == 2:
            city = City.get_by_crc(city)

        return self.published_only().filter(city=city)
예제 #3
0
파일: forms.py 프로젝트: C14L/anu2
def _get_city_by_crc(crc):
    """Return the database object found by the string from the <input> field."""
    return City.get_by_crc(crc)