Пример #1
0
def do_buy_claim(request, item):
    user = request.user
    order = item.order
    shipping_date = order.get_shipping_date()
    less_than_7_days = shipping_date > (datetime.now().date() - timedelta(7))
    more_than_5_days = shipping_date < (datetime.now().date() - timedelta(5))

    return {
        'shpere': 'Buy',
        'game': item.item,
        'order': order,
        'item': item,
        'less_than_7_days': less_than_7_days,
        'more_than_5_days': more_than_5_days,
        'shipping_date': shipping_date,
        'shipping_date_plus_7': shipping_date + timedelta(7),
        'forms': {
            'game_is_damaged': GameIsDamagedForm.create(user, item),
            'wrong_game': WrongGameForm.create(user, item),
            'dont_receive_yet': DontReceiveForm.create(user, item, initial={
                'first_name': order.first_name,
                'last_name': order.last_name,
                'shipping_address1': order.shipping_address1,
                'shipping_address2': order.shipping_address2,
                'shipping_city': order.shipping_city,
                'shipping_state': order.shipping_state,
                'shipping_zip_code': order.shipping_zip_code,
            })
        },
    }
Пример #2
0
def do_rent_claim(request, item):
    user = request.user
    shipped_date = item.date_shipped
    less_than_7_days = (shipped_date or datetime.now()).date() > (datetime.now().date() - timedelta(7))
    order = item

    if order.status == RentOrderStatus.Returned:
        raise Http404()

    return {
        'shpere': 'Rent',
        'game': item.item,
        'order': order,
        'item': item,
        'less_than_7_days': less_than_7_days,
        'shipped_date': shipped_date,
        'shipped_date_plus_7': (shipped_date or datetime.now()) + timedelta(7),
        'forms': {
            'game_is_damaged': GameIsDamagedForm.create(user, item),
            'wrong_game': WrongGameForm.create(user, item),
            'mailer_is_empty': MailerIsEmptyForm.create(user, item),
            'dont_receive_yet': DontReceiveForm.create(user, item, initial={
                'first_name': order.first_name,
                'last_name': order.last_name,
                'shipping_address1': order.shipping_address1,
                'shipping_address2': order.shipping_address2,
                'shipping_city': order.shipping_city,
                'shipping_state': order.shipping_state,
                'shipping_zip_code': order.shipping_zip_code,
            }),
            'gamemine_not_receive_game': GamemineNotRecieveForm.create(user, item),
        },
    }