Example #1
0
def fuckup_ios_delivery_types(delivery_types):
    RESTRICTION = {
        'meatme': [DELIVERY],
        'sushimarket': [DELIVERY],
        'nasushi': [DELIVERY],
        'perchiniribaris': [SELF, IN_CAFE],
        'perchiniribarislublino': [SELF, IN_CAFE],
        'burgerhouse': [SELF, IN_CAFE],
        'tykano': [SELF, IN_CAFE],
        'magnolia': [SELF, IN_CAFE],
        'chikarabar': [SELF, IN_CAFE],
        'sushivesla': [DELIVERY],
        'pastadeli': [SELF, IN_CAFE]
    }
    user = get_temporary_user()
    if not is_ios_user() or user.get(VERSION) != 2 or RESTRICTION.get(
            namespace_manager.get_namespace()) == None:
        return delivery_types
    send_error = False
    for delivery_type in delivery_types[:]:
        if int(delivery_type['id']) in RESTRICTION.get(
                namespace_manager.get_namespace()):
            delivery_types.remove(delivery_type)
            send_error = True
    if send_error:
        logging.warning('Cut delivery types: %s' % delivery_types)
        admins.send_error(
            'ios_fuckup', 'Catch Version 2 with 2 delivery types',
            str({
                'user_agent': user.get(USER_AGENT),
                'delivery_types': delivery_types,
                'version': user.get(VERSION),
                'namespace': namespace_manager.get_namespace()
            }))
    return delivery_types
Example #2
0
def get_delivery_text(delivery_sum, delivery_type, delivery_zone):
    if delivery_type != DELIVERY:
        return u''
    delivery_sum_str = u''
    user = get_temporary_user()
    with_delivery_sum = user.get(VERSION) < 5 or 'iOS' not in user.get(
        USER_AGENT)
    if with_delivery_sum:
        if delivery_sum:
            delivery_sum_str = u'Стоимость доставки %dр' % delivery_sum
        else:
            delivery_sum_str = u'Бесплатная доставка'
    if config.ADDITION_INFO_ABOUT_DELIVERY:
        if with_delivery_sum:
            delivery_sum_str += u'. '
        with_delivery_sum = True
        delivery_sum_str += config.ADDITION_INFO_ABOUT_DELIVERY
    if delivery_zone:
        if with_delivery_sum:
            delivery_sum_str += u'. '
        if not delivery_zone.found:
            delivery_sum_str += u'Точные условия доставки будут уточнены у оператора'
        else:
            if delivery_zone.comment:
                delivery_sum_str += delivery_zone.comment
    return delivery_sum_str
Example #3
0
def _post_request(resto_company,
                  path,
                  params=None,
                  payload=None,
                  log_response=True):
    url = '%s%s' % (__get_base_url(resto_company), path)
    if params:
        url = '%s?%s' % (url, urllib.urlencode(params))
    logging.info(url)
    if payload:
        payload = {
            k: unicode(v).encode('utf-8')
            for k, v in payload.iteritems()
        }
        payload = urllib.urlencode(payload)
    logging.info('payload = %s' % payload)
    response = urlfetch.fetch(
        url,
        method='POST',
        payload=payload,
        deadline=60,
        headers={'User-Agent': get_temporary_user()[USER_AGENT]})
    logging.info(response.status_code)
    response = json.loads(response.content)
    if log_response:
        logging.info(response)
    return response
Example #4
0
def fuckup_move_items_to_gifts(items, gifts):
    if get_temporary_user().get(VERSION) < 7 and is_ios_user():
        for item in items[:]:  # iterating over copy so we can remove()
            menu_item = MenuItem.get(item['item_id'])
            if not menu_item:
                gift_menu_item = GiftMenuItem.get_by_id(int(item['item_id']))
                if gift_menu_item:
                    gifts.append(item)
                    items.remove(item)
    return items, gifts
Example #5
0
def _get_request(company, path, params=None, log_response=True):
    url = '%s%s' % (__get_base_url(company), path)
    if params:
        url = '%s?%s' % (url, urllib.urlencode(params))
    logging.info(url)
    response = urlfetch.fetch(
        url,
        method='GET',
        deadline=60,
        headers={'User-Agent': get_temporary_user()[USER_AGENT]})
    logging.info(response.status_code)
    response = json.loads(response.content)
    if log_response:
        logging.info(response)
    return response
Example #6
0
def is_share_fuckup_ios_user():
    user = get_temporary_user()
    is_elephant_ua = 'ElephantBoutique/1.1.8' in user.get(USER_AGENT)
    is_red_cup_ua = 'RedCup' in user.get(USER_AGENT)
    return is_ios_user(
    ) and user.get(VERSION) < 5 and not is_elephant_ua and not is_red_cup_ua
Example #7
0
 def dict(self):
     tu = get_temporary_user()
     if tu[VERSION] <= 5:
         return self.dict_old()
     else:
         return self.dict_with_title()