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


Python translation.ugettext_lazy方法代码示例

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


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

示例1: _validate_org_relation

# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import ugettext_lazy [as 别名]
def _validate_org_relation(self, rel, field_error='organization'):
        """
        if the relation is owned by a specific organization
        this object must be related to the same organization
        """
        # avoid exceptions caused by the relation not being set
        if not hasattr(self, rel):
            return
        rel = getattr(self, rel)
        if (
            rel
            and rel.organization_id
            and str(self.organization_id) != str(rel.organization_id)
        ):
            message = _(
                'Please ensure that the organization of this {object_label} '
                'and the organization of the related {related_object_label} match.'
            )
            message = message.format(
                object_label=self._meta.verbose_name,
                related_object_label=rel._meta.verbose_name,
            )
            raise ValidationError({field_error: message}) 
开发者ID:openwisp,项目名称:openwisp-users,代码行数:25,代码来源:mixins.py

示例2: clean

# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import ugettext_lazy [as 别名]
def clean(self):
        cd = super(CustomerForm, self).clean()

        phone = cd.get('phone')
        country = cd.get('country')

        if len(phone) < 1:
            return cd

        try:
            phonenumbers.parse(phone, country)
        except phonenumbers.NumberParseException:
            msg = _('Enter a valid phone number')
            self._errors["phone"] = self.error_class([msg])

        return cd 
开发者ID:fpsw,项目名称:Servo,代码行数:18,代码来源:customer.py

示例3: __init__

# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import ugettext_lazy [as 别名]
def __init__(self, *args, **kwargs):

        super(DeviceForm, self).__init__(*args, **kwargs)

        if Configuration.false('checkin_require_password'):
            self.fields['password'].required = False

        if Configuration.true('checkin_require_condition'):
            self.fields['condition'].required = True

        if kwargs.get('instance'):
            prod = gsxws.Product('')
            prod.description = self.instance.description

            if prod.is_ios:
                self.fields['password'].label = _('Passcode')

            if not prod.is_ios:
                del(self.fields['imei'])
            if not prod.is_mac:
                del(self.fields['username'])

        if Configuration.true('checkin_password'):
            self.fields['password'].widget = forms.TextInput(attrs={'class': 'span12'}) 
开发者ID:fpsw,项目名称:Servo,代码行数:26,代码来源:checkin.py

示例4: __init__

# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import ugettext_lazy [as 别名]
def __init__(self, *args, **kwargs):
        super(NoteForm, self).__init__(*args, **kwargs)
        note = kwargs['instance']
        self.fields['sender'] = forms.ChoiceField(
            label=_('From'),
            choices=note.get_sender_choices(),
            widget=forms.Select(attrs={'class': 'span12'})
        )

        self.fields['body'].widget = AutocompleteTextarea(
            rows=20,
            choices=Template.templates()
        )

        if note.order:
            url = reverse('notes-render_template', args=[note.order.pk])
            self.fields['body'].widget.attrs['data-url'] = url 
开发者ID:fpsw,项目名称:Servo,代码行数:19,代码来源:notes.py

示例5: create_from_gsx

# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import ugettext_lazy [as 别名]
def create_from_gsx(cls, confirmation, order, device, user):
        """Creates a new Repair for order with confirmation number."""
        try:
            repair = cls.objects.get(confirmation=confirmation)
            msg = {'repair': repair.confirmation, 'order': repair.order}
            raise ValueError(_('Repair %(repair)s already exists for order %(order)s') % msg)
        except cls.DoesNotExist:
            pass

        repair = cls(order=order, created_by=user)
        repair.device = device
        repair.confirmation = confirmation
        repair.gsx_account = GsxAccount.default(user, order.queue)
        repair.submitted_at = timezone.now() # RepairDetails doesn't have this!
        repair.save()

        try:
            repair.get_details()
            repair.update_status(user)
        except gsxws.GsxError as e:
            if e.code == 'RPR.LKP.01': # repair not found
                repair.delete()
                raise ValueError(_('Repair %s not found in GSX') % confirmation)

        return repair 
开发者ID:fpsw,项目名称:Servo,代码行数:27,代码来源:repair.py

示例6: sell

# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import ugettext_lazy [as 别名]
def sell(self, amount, location):
        """
        Deduct product from inventory with specified location
        """
        if not self.track_inventory():
            return

        try:
            inventory = Inventory.objects.get(product=self, location=location)
            
            try:
                inventory.amount_stocked  = inventory.amount_stocked - amount
                inventory.amount_reserved = inventory.amount_reserved - amount
            except Exception as e:
                # @TODO: Would be nice to trigger a warning
                pass

            inventory.save()
        except Inventory.DoesNotExist:
            raise ValueError(_(u"Product %s not found in inventory.") % self.code) 
开发者ID:fpsw,项目名称:Servo,代码行数:22,代码来源:product.py

示例7: activate_locale

# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import ugettext_lazy [as 别名]
def activate_locale(self):
        """
        Activates this user's locale
        """
        try:
            lc = self.locale.split('.')
            region = self.region.split('.')
            locale.setlocale(locale.LC_TIME, region)
            locale.setlocale(locale.LC_MESSAGES, lc)
            locale.setlocale(locale.LC_NUMERIC, region)
            locale.setlocale(locale.LC_MONETARY, region)
        except Exception as e:
            locale.setlocale(locale.LC_ALL, None)

        # Return the language code
        return self.locale.split('_', 1)[0] 
开发者ID:fpsw,项目名称:Servo,代码行数:18,代码来源:account.py

示例8: get_print_dict

# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import ugettext_lazy [as 别名]
def get_print_dict(self, kind='confirmation'):
        """
        Return context dict for printing this order
        """
        r = {}
        r['order'] = self
        r['conf'] = Configuration.conf()
        r['title'] = _(u"Service Order #%s") % self.code
        r['notes'] = self.note_set.filter(is_reported=True)

        if kind == 'receipt':
            try:
                # Include the latest invoice data for receipts
                r['invoice'] = self.invoice_set.latest()
            except Exception as e:
                pass

        return r 
开发者ID:fpsw,项目名称:Servo,代码行数:20,代码来源:order.py

示例9: set_location

# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import ugettext_lazy [as 别名]
def set_location(self, new_location, user):
        """
        Moves order to new location
        """
        # move the products too
        for soi in self.serviceorderitem_set.all():
            product = soi.product

            try:
                source = Inventory.objects.get(location=self.location, product=product)
                source.move(new_location, soi.amount)
            except Inventory.DoesNotExist:
                pass # @TODO: Is this OK?

        self.location = new_location
        msg = _(u"Order %s moved to %s") % (self.code, new_location.title)
        self.notify("set_location", msg, user)
        self.save()

        return msg 
开发者ID:fpsw,项目名称:Servo,代码行数:22,代码来源:order.py

示例10: add_product

# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import ugettext_lazy [as 别名]
def add_product(self, product, amount, user):
        """
        Adds this product to the Service Order with stock price
        """
        oi = ServiceOrderItem(order=self, created_by=user)
        oi.product = product
        oi.code = product.code
        oi.title = product.title
        oi.description = product.description
        oi.amount = amount

        oi.price_category = 'stock'
        oi.price = product.price_sales_stock

        oi.save()

        self.notify("product_added", _('Product %s added') % oi.title, user)

        return oi 
开发者ID:fpsw,项目名称:Servo,代码行数:21,代码来源:order.py

示例11: save

# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import ugettext_lazy [as 别名]
def save(self, *args, **kwargs):

        location = self.created_by.location

        if self.location_id is None:
            self.location = location

        if self.checkin_location is None:
            self.checkin_location = location

        if self.checkout_location is None:
            self.checkout_location = location

        if self.customer and self.customer_name == '':
            self.customer_name = self.customer.fullname

        super(Order, self).save(*args, **kwargs)

        if self.code is None:
            self.url_code = encode_url(self.id).upper()
            self.code = settings.INSTALL_ID + str(self.id).rjust(6, '0')
            event = _('Order %s created') % self.code
            self.notify('created', event, self.created_by)
            self.save() 
开发者ID:fpsw,项目名称:Servo,代码行数:26,代码来源:order.py

示例12: trigger_purchase_order_created

# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import ugettext_lazy [as 别名]
def trigger_purchase_order_created(sender, instance, created, **kwargs):

    sales_order = instance.sales_order

    if sales_order is None:
        return

    if not sales_order.is_editable:
        return

    if created:
        msg = _("Purchase Order %d created") % instance.id
        sales_order.notify("po_created", msg, instance.created_by)

    # Trigger status change for GSX repair submit (if defined)
    if instance.submitted_at:
        if sales_order.queue:
            queue = sales_order.queue
            if queue.status_products_ordered:
                # Queue has a status for product_ordered - trigger it
                new_status = queue.status_products_ordered
                sales_order.set_status(new_status, instance.created_by) 
开发者ID:fpsw,项目名称:Servo,代码行数:24,代码来源:purchases.py

示例13: send_sms_builtin

# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import ugettext_lazy [as 别名]
def send_sms_builtin(self, recipient, sender=None):
        """
        Sends SMS through built-in gateway
        """
        if not settings.SMS_HTTP_URL:
            raise ValueError(_('System is not configured for built-in SMS support.'))

        if sender is None:
            location = self.created_by.location
            sender = location.title

        data = urllib.urlencode({
            'username'  : settings.SMS_HTTP_USERNAME,
            'password'  : settings.SMS_HTTP_PASSWORD,
            'numberto'  : recipient.replace(' ', ''),
            'numberfrom': sender.encode(SMS_ENCODING),
            'message'   : self.body.encode(SMS_ENCODING),
        })

        from ssl import _create_unverified_context
        f = urllib.urlopen(settings.SMS_HTTP_URL, data, context=_create_unverified_context())
        return f.read() 
开发者ID:fpsw,项目名称:Servo,代码行数:24,代码来源:note.py

示例14: update_sn

# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import ugettext_lazy [as 别名]
def update_sn(self):
        # CTS parts not eligible for SN update
        if self.return_status == 'Convert To Stock':
            return

        if not self.repair.confirmation:
            raise ValueError(_('GSX repair has no dispatch ID'))

        product = self.order_item.product

        if not product.is_serialized:
            return

        if product.part_type == "MODULE":
            self.update_module_sn()
        elif product.part_type == "REPLACEMENT":
            self.update_replacement_sn() 
开发者ID:fpsw,项目名称:Servo,代码行数:19,代码来源:parts.py

示例15: __init__

# 需要导入模块: from django.utils import translation [as 别名]
# 或者: from django.utils.translation import ugettext_lazy [as 别名]
def __init__(self, attrs=None):
        _widgets = (
            widgets.TextInput(
                attrs={'data-geo': 'formatted_address', 'data-id': 'map_place'}
            ),
            widgets.TextInput(
                attrs={
                    'data-geo': 'lat',
                    'data-id': 'map_latitude',
                    'placeholder': _('Latitude'),
                }
            ),
            widgets.TextInput(
                attrs={
                    'data-geo': 'lng',
                    'data-id': 'map_longitude',
                    'placeholder': _('Longitude'),
                }
            ),
        )
        super(PlacesWidget, self).__init__(_widgets, attrs) 
开发者ID:oscarmcm,项目名称:django-places,代码行数:23,代码来源:widgets.py


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