def get(self, request, template_name="index.html"): from misc.models import PartnerReviews, WebsiteNotifications promo_ids = policies = [] reviews = PartnerReviews.objects.all().order_by('sequence') customerreview_banner_url = os.path.join( settings.STATIC_URL, settings.PLACEHOLDER_BANNER_IMAGE) banner_record = S3Object.objects.filter(customerreview_banner=True)[:1] featured_lines = S3Object.objects.filter( is_featured_item=True, attribute_id__in=request.volumes_available_ids) website_banner_ids = WebsiteBanner.objects.filter(active=True) company_logo_id = S3Object.objects.filter(company_logo=True) if is_user_business(request.user): promo_ids = eval( IrConfigParameters.objects.get_param('promo_business_ids', '[]')) else: promo_ids = eval( IrConfigParameters.objects.get_param('promo_non_business_ids', '[]')) policies = WebsitePolicy.objects.filter( id__in=promo_ids).order_by('sequence')[:3] lines_list = [] if featured_lines.exists(): for line in featured_lines: try: lines_list.append((line.flavor_id, line.attribute_id)) except FlavorConcDetails.DoesNotExist: pass if banner_record.exists(): customerreview_banner_url = create_aws_url( banner_record[0]._meta.db_table, str(banner_record[0].id)) if company_logo_id.exists(): company_logo_url = create_aws_url( company_logo_id[0]._meta.db_table, str(company_logo_id[0].id)) # Facebook payload = { 'access_token': settings.FACEBOOK_ACCESSS_TOKEN, 'fields': "has_rating,has_review,rating,review_text,reviewer" } res = requests.get( 'https://graph.facebook.com/v2.9/vapeUjuice/ratings', params=payload) facebook = res.json() star_range = range(0, 5) website_notifications = WebsiteNotifications.objects.filter( active=True) return render(request, "index.html", locals())
def get(self, request, template_name="contactus.html"): banner_url = os.path.join(settings.STATIC_URL, settings.PLACEHOLDER_BANNER_IMAGE) banner_record = S3Object.objects.filter(contactus_banner=True)[:1] banner_record_500340 = S3Object.objects.filter( contactus_banner_500340=True)[:1] name = "Contact Us" if banner_record.exists(): banner_url = create_aws_url(banner_record[0]._meta.db_table, str(banner_record[0].id)) if banner_record_500340.exists(): banner_url_500340 = create_aws_url( banner_record_500340[0]._meta.db_table, str(banner_record_500340[0].id)) return render(request, template_name, locals())
def get(self, request, template_name="privacy_policy.html"): banner_url = os.path.join(settings.STATIC_URL, settings.PLACEHOLDER_BANNER_IMAGE) banner_record = S3Object.objects.filter(privacy_policy_banner=True)[:1] name = "Privacy Policy" if banner_record.exists(): banner_url = create_aws_url(banner_record[0]._meta.db_table, str(banner_record[0].id)) return render(request, template_name, locals())
def get_image_url(self, volume_id): image_line = self.flavor_attribute_image_ids.filter( attribute_id=volume_id)[:1] url = os.path.join(settings.STATIC_URL, settings.PLACEHOLDER_FLAVOR_IMAGE) if image_line.exists(): url = create_aws_url(image_line[0]._meta.db_table, str(image_line[0].id)) return url
def get(self, request, template_name="aboutus.html"): banner_url = os.path.join(settings.STATIC_URL, settings.PLACEHOLDER_BANNER_IMAGE) banner_record = S3Object.objects.filter(aboutus_banner=True)[:1] name = "About Us" if banner_record.exists(): banner_url = create_aws_url(banner_record[0]._meta.db_table, str(banner_record[0].id)) employees = HrEmployee.objects.filter( publish=True).order_by('sequence') return render(request, template_name, locals())
def get(self, request, template_name="checkout.html"): name = self._name back_url = request.GET.get('back_url', False) back_url_name = request.GET.get('back_url_name', 'No Name') if back_url: back_url = quote(back_url.encode('utf-8')) checkout_banner_url = os.path.join(settings.STATIC_URL, settings.PLACEHOLDER_BANNER_IMAGE) banner_record = S3Object.objects.filter(checkout_banner=True)[:1] if banner_record.exists(): checkout_banner_url = create_aws_url( banner_record[0]._meta.db_table, str(banner_record[0].id)) country_allowed_shipping = country_ids.filter(is_shipping_allowed=True) countries_list = map(lambda x: (x.id, x.name), country_allowed_shipping) address = False shipping_allowed = True age_checked = request.COOKIES.get('ac_custom_verified', False) if request.user.is_authenticated: states_list = [] partner = request.user.odoo_user.partner_id address = { 'name': partner.name, 'is_company': partner.is_company, 'street': partner.street, 'country_id': partner.country_id and partner.country_id.id or False, 'country': partner.country_id and partner.country_id.name, 'street2': partner.street2, 'city': partner.city, 'state': partner.state_id and partner.state_id.name, 'state_id': partner.state_id and partner.state_id.id or False, 'zip': partner.zip, } if partner.country_id: states_list = partner.country_id.country_state_ids.all() if partner.country_id: shipping_allowed = partner.country_id in country_allowed_shipping # Running a loop through all cart items to tick which ones are checkedout request.CART_DATA['actual_cart_items'].checkedout = False for i in request.CART_DATA.get('checkout_cart_items', []): i.checkedout = True i.save() return render(request, template_name, locals())
def get(self, request, template_name="search.html"): lines_list = [] search = request.GET.get('search', False) page = int(request.GET.get('page', 1)) per_page = int(request.GET.get('per_page', 20)) if search: lines_list = ProductVariant.objects.filter( Q(product_tmpl_id__name__icontains=search) | Q(tab_id__name__icontains=search) | Q(vol_id__name__icontains=search)).filter( Q(product_tmpl_id__sale_ok=True), Q(product_tmpl_id__type='product'), Q(active=True), Q(vol_id__in=request.volumes_available_ids), Q(tab_id__visible_all_customers=True), Q(tab_id__consumable_stockable='product'), Q(tab_id__active=True), Q(tab_id__vol_id__in=request.volumes_available_ids) ).distinct('flavor_id__id', 'vol_id__id') paginator = Paginator(lines_list, per_page) try: lines = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. lines = paginator.page(1) except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. lines = paginator.page(paginator.num_pages) per_page_options = _PER_PAGE_OPTIONS search_banner_url = os.path.join(settings.STATIC_URL, settings.PLACEHOLDER_BANNER_IMAGE) banner_record = S3Object.objects.filter(search_banner=True)[:1] back_url = "?".join([ request.path, urlencode({ 'search': search, 'per_page': per_page, 'page': page }) ]) back_url = quote(back_url.encode("utf-8")) if banner_record.exists(): search_banner_url = create_aws_url(banner_record[0]._meta.db_table, str(banner_record[0].id)) return render(request, template_name, locals())
def get_image_url(self): return create_aws_url(self._meta.db_table, str(self.id))
def get_banner_url(self): url = os.path.join(settings.STATIC_URL, settings.PLACEHOLDER_BANNER_IMAGE) if self.banner_file_name: url = create_aws_url(self.banner_key, str(self.id)) return url
def get_image_url(self): url = os.path.join(settings.STATIC_URL, settings.PLACEHOLDER_PRODUCT_IMAGE) if self.file_name: url = create_aws_url(self._meta.db_table, str(self.id)) return url