当前位置: 首页>>代码示例>>Python>>正文


Python messages.success方法代码示例

本文整理汇总了Python中django.contrib.messages.success方法的典型用法代码示例。如果您正苦于以下问题:Python messages.success方法的具体用法?Python messages.success怎么用?Python messages.success使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.contrib.messages的用法示例。


在下文中一共展示了messages.success方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: delete_product

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import success [as 别名]
def delete_product(request, pk, group):
    from django.db.models import ProtectedError
    product = get_object_or_404(Product, pk=pk)

    if request.method == 'POST':
        try:
            product.delete()
            Inventory.objects.filter(product=product).delete()
            messages.success(request, _("Product deleted"))
        except ProtectedError:
            messages.error(request, _('Cannot delete product'))

        return redirect(list_products, group)

    action = request.path
    return render(request, 'products/remove.html', locals()) 
开发者ID:fpsw,项目名称:Servo,代码行数:18,代码来源:product.py

示例2: upload_gsx_parts

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import success [as 别名]
def upload_gsx_parts(request, group=None):
    from servo.forms.product import PartsImportForm
    form = PartsImportForm()

    data = {'action': request.path}

    if request.method == "POST":

        form = PartsImportForm(request.POST, request.FILES)

        if form.is_valid():
            data = form.cleaned_data
            filename = "servo/uploads/products/partsdb.csv"
            destination = open(filename, "wb+")

            for chunk in data['partsdb'].chunks():
                destination.write(chunk)

            messages.success(request, _("Parts database uploaded for processing"))
            return redirect(list_products)

    data['form'] = form
    return render(request, "products/upload_gsx_parts.html", data) 
开发者ID:fpsw,项目名称:Servo,代码行数:25,代码来源:product.py

示例3: edit_group

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import success [as 别名]
def edit_group(request, group='all'):
    if group == 'all':
        group = CustomerGroup()
    else:
        group = CustomerGroup.objects.get(slug=group)

    title = group.name
    form = GroupForm(instance=group)

    if request.method == "POST":
        form = GroupForm(request.POST, instance=group)
        if form.is_valid():
            group = form.save()
            messages.success(request, _(u'%s saved') % group.name)
            return redirect(index, group.slug)
        messages.error(request, form.errors['name'][0])
        return redirect(index)

    return render(request, "customers/edit_group.html", locals()) 
开发者ID:fpsw,项目名称:Servo,代码行数:21,代码来源:customer.py

示例4: edit_calendar

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import success [as 别名]
def edit_calendar(request, pk=None, view="week"):
    from servo.models.calendar import CalendarForm
    calendar = Calendar(user=request.user)

    if pk:
        calendar = get_object_or_404(Calendar, pk=pk)
        if not calendar.user == request.user:
            messages.error(request, _('You can only edit your own calendar'))
            return redirect(calendars)

    if request.method == "POST":
        form = CalendarForm(request.POST, instance=calendar)

        if form.is_valid():
            calendar = form.save()
            messages.success(request, _("Calendar saved"))
            return redirect(view_calendar, calendar.pk, 'week')

    form = CalendarForm(instance=calendar)

    data = {'title': calendar.title}
    data['form'] = form
    data['action'] = request.path

    return render(request, "accounts/calendar_form.html", data) 
开发者ID:fpsw,项目名称:Servo,代码行数:27,代码来源:account.py

示例5: register

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import success [as 别名]
def register(request):
    """
    New user applying for access
    """
    form = RegistrationForm()
    data = {'title': _("Register")}

    if request.method == 'POST':

        form = RegistrationForm(request.POST)

        if form.is_valid():
            user = User(is_active=False)
            user.email = form.cleaned_data['email']
            user.last_name = form.cleaned_data['last_name']
            user.first_name = form.cleaned_data['first_name']
            user.set_password(form.cleaned_data['password'])
            user.save()

            messages.success(request, _(u'Your registration is now pending approval.'))

            return redirect(login)

    data['form'] = form
    return render(request, 'accounts/register.html', data) 
开发者ID:fpsw,项目名称:Servo,代码行数:27,代码来源:account.py

示例6: delete_device

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import success [as 别名]
def delete_device(request, product_line, model, pk):
    dev = get_object_or_404(Device, pk=pk)

    if request.method == 'POST':
        from django.db.models import ProtectedError
        try:
            dev.delete()
            messages.success(request, _("Device deleted"))
        except ProtectedError:
            messages.error(request, _("Cannot delete device with GSX repairs"))
            return redirect(dev)

        return redirect(index)

    data = {'action': request.path}
    data['device'] = dev

    return render(request, "devices/remove.html", data) 
开发者ID:fpsw,项目名称:Servo,代码行数:20,代码来源:device.py

示例7: update_gsx_details

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import success [as 别名]
def update_gsx_details(request, pk):
    """
    Updates devices GSX warranty details
    """
    device = get_object_or_404(Device, pk=pk)
    try:
        GsxAccount.default(request.user)
        device.update_gsx_details()
        messages.success(request, _("Warranty status updated successfully"))
    except Exception as e:
        messages.error(request, e)

    if request.session.get('return_to'):
        return redirect(request.session['return_to'])

    return redirect(device) 
开发者ID:fpsw,项目名称:Servo,代码行数:18,代码来源:device.py

示例8: close

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import success [as 别名]
def close(request, pk):
    """Close this Service Order."""
    order = get_object_or_404(Order, pk=pk)

    if request.method == 'POST':
        try:
            order.close(request.user)
        except Exception as e:
            messages.error(request, e)
            return redirect(order)

        if request.session.get("current_order_id"):
            del(request.session['current_order_id'])
            del(request.session['current_order_code'])
            del(request.session['current_order_customer'])

        messages.success(request, _('Order %s closed') % order.code)

        return redirect(order)

    data = {'order': order, 'action': reverse(close, args=[pk])}
    return render(request, "orders/close.html", data) 
开发者ID:fpsw,项目名称:Servo,代码行数:24,代码来源:order.py

示例9: delete

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import success [as 别名]
def delete(request, pk):
    
    order = get_object_or_404(Order, pk=pk)

    if request.method == "POST":
        return_to = order.get_queue_url()
        try:
            order.delete()
            del(request.session['current_order_id'])
            del(request.session['current_order_code'])
            del(request.session['current_order_customer'])
            messages.success(request, _(u'Order %s deleted') % order.code)
            return redirect(return_to)
        except Exception as e:
            ed = {'order': order.code, 'error': e}
            msg = _(u'Cannot delete order %(order)s: %(error)s') % ed
            messages.error(request, msg)
            return redirect(order)

    action = request.path
    return render(request, "orders/delete_order.html", locals()) 
开发者ID:fpsw,项目名称:Servo,代码行数:23,代码来源:order.py

示例10: device_from_product

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import success [as 别名]
def device_from_product(request, pk, item_id):
    """
    Turns a SOI into a device and attaches it to this order
    """
    order = get_object_or_404(Order, pk=pk)
    soi = ServiceOrderItem.objects.get(pk=item_id)

    try:
        GsxAccount.default(request.user, order.queue)
        device = Device.from_gsx(soi.sn, user=request.user)
        device.save()
        event = order.add_device(device, request.user)
        messages.success(request, event)
    except Exception as e:
        messages.error(request, e)

    return redirect(order) 
开发者ID:fpsw,项目名称:Servo,代码行数:19,代码来源:order.py

示例11: create_po

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import success [as 别名]
def create_po(request, product_id=None, order_id=None):
    """
    Creates a new Purchase Order
    """
    po = PurchaseOrder(created_by=request.user)
    po.location = request.user.get_location()
    po.save()

    if order_id is not None:
        po.sales_order = get_object_or_404(Order, pk=order_id)
        po.save()
        for i in ServiceOrderItem.objects.filter(order_id=order_id):
            po.add_product(i, amount=1, user=request.user)

    if product_id is not None:
        product = get_object_or_404(Product, pk=product_id)
        po.add_product(product, amount=1, user=request.user)

    messages.success(request, _("Purchase Order %d created" % po.pk))

    return redirect(edit_po, po.pk) 
开发者ID:fpsw,项目名称:Servo,代码行数:23,代码来源:purchases.py

示例12: delete_note

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import success [as 别名]
def delete_note(request, pk):
    """
    Deletes a note
    """
    note = get_object_or_404(Note, pk=pk)

    if request.method == 'POST':
        note.delete()
        messages.success(request, _("Note deleted"))

        if request.session.get('return_to'):
            url = request.session.get('return_to')
            del(request.session['return_to'])
        elif note.order_id:
            url = note.order.get_absolute_url()

        return redirect(url)

    return render(request, 'notes/remove.html', {'note': note}) 
开发者ID:fpsw,项目名称:Servo,代码行数:21,代码来源:note.py

示例13: add_part

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import success [as 别名]
def add_part(request, repair, part):
    """
    Adds this part to this GSX repair
    """
    rep = get_object_or_404(Repair, pk=repair)
    soi = rep.order.serviceorderitem_set.get(pk=part)

    if request.method == "POST":
        try:
            part = rep.add_part(soi, request.user)
            data = {'part': part.part_number, 'repair': rep.confirmation}
            msg = _("Part %(part)s added to repair %(repair)s") % data
            messages.success(request, msg)
        except gsxws.GsxError, e:
            messages.error(request, e)

        return redirect(rep.order) 
开发者ID:fpsw,项目名称:Servo,代码行数:19,代码来源:gsx.py

示例14: remove_part

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import success [as 别名]
def remove_part(request, repair, part):
    rep = get_object_or_404(Repair, pk=repair)
    part = get_object_or_404(ServicePart, pk=part)

    if request.method == "POST":

        rep.connect_gsx(request.user)
        gsx_rep = rep.get_gsx_repair()
        orderline = part.get_repair_order_line()
        orderline.toDelete = True
        orderline.orderLineNumber = part.line_number

        try:
            gsx_rep.update({'orderLines': [orderline]})
            data = {'part': part.code, 'repair': rep.confirmation}
            msg = _(u"Part %(part)s removed from %(repair)s") % data
            messages.success(request, msg)
        except gsxws.GsxError, e:
            messages.error(request, e)

        return redirect(rep.order) 
开发者ID:fpsw,项目名称:Servo,代码行数:23,代码来源:gsx.py

示例15: delete_repair

# 需要导入模块: from django.contrib import messages [as 别名]
# 或者: from django.contrib.messages import success [as 别名]
def delete_repair(request, pk):
    """Delete this unsubmitted GSX repair."""
    repair = get_object_or_404(Repair, pk=pk)

    if repair.is_submitted():
        messages.error(request, _('Submitted repairs cannot be deleted'))
        return redirect(repair.order)

    if request.method == 'POST':
        order = repair.order
        repair.delete()
        messages.success(request, _('GSX repair deleted'))
        return redirect(order)

    context = {'action': request.path}
    return render(request, 'repairs/delete_repair.html', context) 
开发者ID:fpsw,项目名称:Servo,代码行数:18,代码来源:gsx.py


注:本文中的django.contrib.messages.success方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。