def campaigns_view(request, entity_cls=None): current_campaigns = entity_cls.objects.get_current_campaigns() tags = entity_cls.objects.unique_tags(current_campaigns) campaigns_json = [{'id': c.id, 'tags': jsonize(c.tags.all())} for c in current_campaigns] return {'title': 'Current preorders' if entity_cls == Preorder else 'Current campaigns', 'campaigns': current_campaigns, 'campaigns_json': json.dumps(campaigns_json), 'tags': json.dumps(jsonize(tags))}
def brands_view(request): brands = Brand.objects.get_everyone() for b in brands: b.country = b.countries.all()[0] countries = Brand.objects.unique_countries(brands) macroregions = Country.objects.unique_macroregions(countries) tags = Brand.objects.unique_tags(brands) letters = Brand.objects.first_letters(brands) prepped_brands = [{'id': brand.id, 'order': brand.order, 'tags': jsonize(brand.tag_categories.all()), 'countries': jsonize(brand.countries.all()), 'alias': brand.alias} for brand in brands] return {'countries': owear_json(countries), 'regions': owear_json(macroregions), 'tags': owear_json(tags), 'letters': json.dumps(letters), 'brands': brands, 'brands_data': json.dumps(prepped_brands), 'active_elements': ['nav_brands']}
def all_countries_json_view(request): countries = Country.objects.get_everyone() return jsonize(countries)
def all_tag_categories_json_view(request): tag_categories = TagCategory.objects.get_everyone() return jsonize(tag_categories)
def cities_of_country_json_view(request, country_id): cities = City.objects.get_by_country(country_id) return jsonize(cities)