Ejemplo n.º 1
0
Archivo: gsx.py Proyecto: filipp/Servo
def create_repair(request, order_id, device_id, type):
    """
    Creates a GSX repair for the specified SRO and device
    and redirects to the repair's edit page.
    """
    from datetime import timedelta
    from django.utils import timezone

    order = get_object_or_404(Order, pk=order_id)
    device = order.devices.get(pk=device_id)

    repair = Repair(order=order, created_by=request.user, device=device)
    timediff = timezone.now() - order.created_at

    if timediff.seconds <= 3600:
        repair.unit_received_at = order.created_at - timedelta(hours=1)
    else:
        repair.unit_received_at = order.created_at

    repair.reference = request.user.gsx_poprefix + order.code

    try:
        repair.gsx_account = GsxAccount.default(request.user, order.queue)
    except Exception, e:
        messages.error(request, e)
        return redirect(order)
Ejemplo n.º 2
0
def create_repair(request, order_id, device_id, type):
    """
    Creates a GSX repair for the specified SRO and device
    and redirects to the repair's edit page.
    """
    from datetime import timedelta
    from django.utils import timezone

    order = get_object_or_404(Order, pk=order_id)
    device = order.devices.get(pk=device_id)

    repair = Repair(order=order, created_by=request.user, device=device)
    timediff = timezone.now() - order.created_at

    if timediff.seconds <= 3600:
        repair.unit_received_at = order.created_at - timedelta(hours=1)
    else:
        repair.unit_received_at = order.created_at

    repair.reference = request.user.gsx_poprefix + order.code

    try:
        repair.gsx_account = GsxAccount.default(request.user, order.queue)
    except Exception as e:
        messages.error(request, e)
        return redirect(order)

    repair.repair_type = type
    repair.tech_id = request.user.tech_id
    repair.save()

    return redirect(edit_repair, order.pk, repair.pk)
Ejemplo n.º 3
0
def import_repair(request, order_pk, device_pk):
    from servo.models import Device
    order = get_object_or_404(Order, pk=order_pk)
    device = get_object_or_404(Device, pk=device_pk)

    action = request.path
    form = ImportForm()

    if request.method == 'POST':
        form = ImportForm(request.POST)
        if form.is_valid():
            confirmation = form.cleaned_data['confirmation']
            try:
                repair = Repair.create_from_gsx(confirmation, order, device,
                                                request.user)
                messages.success(
                    request,
                    _('GSX repair %s imported successfully' % confirmation))
                return redirect(repair)
            except Exception as e:
                messages.error(request, e)
                return redirect(order)

    return render(request, "repairs/import_repair.html", locals())
Ejemplo n.º 4
0
def import_repair(request, order_pk, device_pk):
    from servo.models import Device
    order = get_object_or_404(Order, pk=order_pk)
    device = get_object_or_404(Device, pk=device_pk)

    action = request.path
    form = ImportForm()

    if request.method == 'POST':
        form = ImportForm(request.POST)
        if form.is_valid():
            confirmation = form.cleaned_data['confirmation']
            try:
                repair = Repair.create_from_gsx(confirmation,
                                                order,
                                                device,
                                                request.user)
                messages.success(request, _('GSX repair %s imported successfully' % confirmation))
                return redirect(repair)
            except Exception as e:
                messages.error(request, e)
                return redirect(order)

    return render(request, "repairs/import_repair.html", locals())