Beispiel #1
0
    def do_fix(self):
        for r in RentOrder.objects.exclude(status__in=[RentOrderStatus.Shipped, RentOrderStatus.Prepared, RentOrderStatus.Pending]):
            claims = Claim.list(r).filter(status=CaseStatus.New)
            for c in claims:
                c.status = CaseStatus.AutoClosed
                c.save()
        for c in GamemineNotReceiveGameClaim.objects.filter(status__in=[CaseStatus.New, CaseStatus.Closed], sphere_of_claim=SphereChoice.Rent):
            rent_order = c.claim_object
            scans = rent_order.incoming_tracking_scans or {}
            if 'I' in scans or 'A' in scans or 'D' in scans:
                rent_order.inventory.status = InventoryStatus.USPSLost
            else:
                p = rent_order.user.get_profile()
                p.inc_strikes(1, True)
                rent_order.inventory.status = InventoryStatus.Lost
            rent_order.inventory.save()
            rent_order.status = RentOrderStatus.Claim
            rent_order.save()
            for cc in Claim.list(rent_order):
                cc.status = CaseStatus.AutoClosed
                cc.save()
        for c in DontReceiveClaim.objects.filter(status__in=[CaseStatus.New, CaseStatus.Closed], sphere_of_claim=SphereChoice.Rent):
            rent_order = c.claim_object
            scans = rent_order.outgoing_tracking_scans or {}
            if 'I' in scans or 'A' in scans or 'D' in scans:
                p = rent_order.user.get_profile()
                p.inc_strikes(1, True)
                rent_order.inventory.status = InventoryStatus.Lost
            else:
                rent_order.inventory.status = InventoryStatus.USPSLost
            rent_order.inventory.save()
            rent_order.status = RentOrderStatus.Claim
            rent_order.save()
            for cc in Claim.list(rent_order):
                cc.status = CaseStatus.AutoClosed
                cc.save()

        for c in WrongGameClaim.objects.filter(status__in=[CaseStatus.New], sphere_of_claim=SphereChoice.Rent):
            c.next_penalty_payment_date = c.date + timedelta(10)
            c.status = CaseStatus.AutoClosed
            c.save()
            rent_order = c.claim_object
            p = rent_order.user.get_profile()
            p.inc_strikes(1, True)

        for c in GameIsDamagedClaim.objects.filter(status__in=[CaseStatus.New], sphere_of_claim=SphereChoice.Rent):
            c.next_penalty_payment_date = c.date + timedelta(10)
            c.status = CaseStatus.AutoClosed
            c.save()
            # MVI-005: Commented out lines below since it makes second strike on user for damages game (first strike
            # was done upon filling claim by user)
            # rent_order = c.claim_object
            # p = rent_order.user.get_profile()
            # p.inc_strikes(1, True)

        for p in Profile.objects.filter(strikes=3):
            p.suspend_rent_account()
Beispiel #2
0
    def do_fix_2x_speed(self):
        for o in RentOrder.objects.filter(status=RentOrderStatus.Shipped, scanned_in_route=False, user__profile__strikes=0):
            plan = MemberRentalPlan.get_current_plan(o.user)
            if not plan or plan.status != RentalPlanStatus.Active:
                continue
            if Claim.list(o).count():
                continue

            scans = o.incoming_tracking_scans or {}
            if "I" in scans or "D" in scans or "A" in scans:
                d = scans.get("I", scans.get("D", scans.get("A")))
                d = datetime.strptime(d, "%Y-%m-%d %H:%M:%S")
                if not d or d <= datetime.datetime.now() - datetime.timedelta(7):
                    continue
                o.scanned_in_route = True
                o.save()
                p = o.user.get_profile()
                p.extra_rent_slots += 1
                p.save()
                print o
Beispiel #3
0
def order_details(request, order_id):
    order = get_object_or_404(RentOrder, id=order_id)

    class DCField(forms.ModelChoiceField):
        def label_from_instance(self, obj):
            return obj.code

    class Form(forms.Form):
        dc = DCField(queryset=Dropship.objects.all(), label='Re-send from')

    p = request.user.get_profile()

    can_be_resent = order.status == RentOrderStatus.Shipped and (request.user.is_superuser or p.group in [Group.DC_Manager, Group.DC_Operator])

    form = None
    if can_be_resent or request.user.is_superuser:
        dc = p.dc
        if request.method == 'POST':
            if not dc:
                form = Form(request.POST)
                if not form.is_valid():
                    return redirect('staff:rent_order_details', order.id)
                dc = form.cleaned_data['dc']

            Claim.list(order).delete()

            data = order.user.get_profile().get_name_data()
            data.update(order.user.get_profile().get_shipping_address_data(prefix='shipping'))
            map(lambda k: setattr(order, *k), data.items())

            order.outgoing_endicia_data = None
            order.outgoing_mail_label = None
            order.outgoing_tracking_number = None
            order.outgoing_tracking_scans = None

            order.incoming_endicia_data = None
            order.incoming_mail_label = None
            order.incoming_tracking_number = None
            order.incoming_tracking_scans = None

            order.status = RentOrderStatus.Prepared
            order.date_prepared = datetime.now()
            order.prepared_by = request.user
            order.source_dc = dc

            order.date_shipped = None
            order.date_delivered = None
            order.date_shipped_back = None
            order.date_returned = None

            order.add_event('The order was re-sent by %s from %s DC' % (p.get_name_display(), dc.code))
            order.save()

            order.inventory.dropship = dc
            order.inventory.status = InventoryStatus.Pending
            order.inventory.tmp_new_dc_code_aproved = True
            order.inventory.save()

            return redirect('staff:page', 'Rent/Orders')
        else:
            if not dc:
                dc = order.user.get_profile().dropship or order.source_dc
                form = Form(initial={'dc': dc.id})

    return {
        'title': 'Rent Order Details: #%s (%s)' % (order.order_no(), order.get_status_display()),
        'order': order,
        'page_class': 'staff-page-rent-order-details',
        'can_be_resent': can_be_resent,
        'form': form,
    }
Beispiel #4
0
 def claims(self):
     from project.claims.models import Claim
     return Claim.list(self)
Beispiel #5
0
 def claims(self):
     return Claim.list(self)