Exemplo n.º 1
0
 def get(self, request, file):
     path = os.path.join(settings.MEDIA_ROOT + '/public/', file)
     if os.path.isfile(path):
         file_extension = os.path.splitext(path)[1].lower()
         image_data = open(path, "rb").read()
         content_type = CONTENT_TYPES.get(file_extension)
         if not content_type:
             content_type = 'application/' + file_extension[1:]
         return HttpResponse(image_data, content_type=content_type)
     return raise_404(request)
Exemplo n.º 2
0
 def get(self, request, product):
     selected_product = Product.objects.filter(is_public=True, name=product)
     categories = ProductCategory.objects.filter(is_main_category=True)
     if selected_product.count() > 0:
         selected_product = selected_product[0]
     else:
         return raise_404(request)
     return render(request, self.template_name, {
         'product': selected_product,
         'categories': categories
     })
Exemplo n.º 3
0
    def get(self, request, site):
        page = Page.objects.filter(page_name=site)
        all_pages = Page.objects.all()
        if page.count() == 1:
            page = page[0]
            if page.is_enabled:
                if page.link:
                    pass
                else:
                    sections = Section.objects.filter(page=page)
                    return render(request, 'index.html', {
                        'page': page,
                        'sections': sections,
                        'all_pages': all_pages
                    })

        # <view logic>
        return raise_404(request)