Example #1
0
File: models.py Project: 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)
Example #2
0
File: views.py Project: C14L/anu2
 def get_queryset(self):
     self.city = City.get_by_url(self.kwargs['city'])
     _cities = City.get_cities_around_city(self.city, dist=25)
     _category = self.kwargs['category']
     self.category = get_object_or_404(Category, slug=_category)
     return Post.objects.by_category(self.category).filter(city__in=_cities)
Example #3
0
File: views.py Project: C14L/anu2
 def get_context_data(self, **kwargs):
     cats = settings.ANUNCIOS['CATEGORIES']
     context = super().get_context_data(**kwargs)
     context['city'] = City.get_by_url(self.kwargs['city'])
     context['grouping_list'] = [x for x in cats if x['parent'] is None]
     return context