當前位置: 首頁>>代碼示例>>Python>>正文


Python translation.ugettext_noop方法代碼示例

本文整理匯總了Python中django.utils.translation.ugettext_noop方法的典型用法代碼示例。如果您正苦於以下問題:Python translation.ugettext_noop方法的具體用法?Python translation.ugettext_noop怎麽用?Python translation.ugettext_noop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.utils.translation的用法示例。


在下文中一共展示了translation.ugettext_noop方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_context_data

# 需要導入模塊: from django.utils import translation [as 別名]
# 或者: from django.utils.translation import ugettext_noop [as 別名]
def get_context_data(self, **kwargs):
        self.secondary_nav_items = copy.deepcopy(self.secondary_nav_items_base)
        if switch_is_active('enable_performance_learning_outcome'):
            if not any(d['name'] == 'learning_outcomes' for d in self.secondary_nav_items):
                self.secondary_nav_items.append({
                    'name': 'learning_outcomes',
                    'text': ugettext_noop('Learning Outcomes'),
                    'view': 'courses:performance:learning_outcomes',
                    'scope': 'course',
                    'lens': 'performance',
                    'report': 'outcomes',
                    'depth': ''
                })
                translate_dict_values(self.secondary_nav_items, ('text',))

        context_data = super(PerformanceTemplateView, self).get_context_data(**kwargs)
        self.presenter = CoursePerformancePresenter(self.access_token, self.course_id)

        context_data['no_data_message'] = self.no_data_message
        context_data['js_data']['course'].update({
            'contentTableHeading': _('Assignment Name')  # overwrite for different heading
        })

        return context_data 
開發者ID:edx,項目名稱:edx-analytics-dashboard,代碼行數:26,代碼來源:performance.py

示例2: delete

# 需要導入模塊: from django.utils import translation [as 別名]
# 或者: from django.utils.translation import ugettext_noop [as 別名]
def delete(self):
        node, dcnode = self.node, self.dcnode

        if dcnode.dc.vm_set.filter(node=node).exists():
            raise PreconditionRequired(_('Node has VMs in datacenter'))

        if dcnode.dc.backup_set.filter(node=node).exists():
            raise PreconditionRequired(_('Node has VM backups in datacenter'))

        ser = DcNodeSerializer(self.request, dcnode)
        ser.object.delete()
        DcNode.update_all(node=node)
        # noinspection PyStatementEffect
        ser.data

        return SuccessTaskResponse(self.request, None, obj=node, detail_dict=ser.detail_dict(), msg=LOG_NODE_DETACH) 
開發者ID:erigones,項目名稱:esdc-ce,代碼行數:18,代碼來源:api_views.py

示例3: delete

# 需要導入模塊: from django.utils import translation [as 別名]
# 或者: from django.utils.translation import ugettext_noop [as 別名]
def delete(self, ns):
        """Update node-storage"""
        ser = NodeStorageSerializer(self.request, ns)
        node = ns.node

        for vm in node.vm_set.all():
            if ns.zpool in vm.get_used_disk_pools():  # active + current
                raise PreconditionRequired(_('Storage is used by some VMs'))

        if node.is_backup:
            if ns.backup_set.exists():
                raise PreconditionRequired(_('Storage is used by some VM backups'))

        obj = ns.log_list
        owner = ns.storage.owner
        ser.object.delete()  # Will delete Storage in post_delete

        return SuccessTaskResponse(self.request, None, obj=obj, owner=owner, msg=LOG_NS_DELETE, dc_bound=False) 
開發者ID:erigones,項目名稱:esdc-ce,代碼行數:20,代碼來源:api_views.py

示例4: safe_summary

# 需要導入模塊: from django.utils import translation [as 別名]
# 或者: from django.utils.translation import ugettext_noop [as 別名]
def safe_summary(self, encoded):
        algorithm, iterations, salt, hash = encoded.split('$', 3)
        assert algorithm == self.algorithm
        return OrderedDict([
            (_('algorithm'), algorithm),
            (_('iterations'), iterations),
            (_('salt'), mask_hash(salt)),
            (_('hash'), mask_hash(hash)),
        ]) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:11,代碼來源:hashers.py

示例5: __str__

# 需要導入模塊: from django.utils import translation [as 別名]
# 或者: from django.utils.translation import ugettext_noop [as 別名]
def __str__(self):
        return _noop(
            'Message received from: {name}\n'
            'User email: {email}\n\n'
            '{message}'
        ).format(
            name=self.name,
            email=self.email,
            message=self.message
        ) 
開發者ID:eventoL,項目名稱:eventoL,代碼行數:12,代碼來源:models.py

示例6: harden_runtime

# 需要導入模塊: from django.utils import translation [as 別名]
# 或者: from django.utils.translation import ugettext_noop [as 別名]
def harden_runtime(self, password, encoded):
        _, data = encoded.split('$', 1)
        salt = data[:29]  # Length of the salt in bcrypt.
        rounds = data.split('$')[2]
        # work factor is logarithmic, adding one doubles the load.
        diff = 2**(self.rounds - int(rounds)) - 1
        while diff > 0:
            self.encode(password, force_bytes(salt))
            diff -= 1 
開發者ID:bpgc-cte,項目名稱:python2017,代碼行數:11,代碼來源:hashers.py

示例7: safe_summary

# 需要導入模塊: from django.utils import translation [as 別名]
# 或者: from django.utils.translation import ugettext_noop [as 別名]
def safe_summary(self, encoded):
        from django.contrib.auth.hashers import mask_hash
        from django.utils.translation import ugettext_noop as _
        handler = self.passlib_handler
        items = [
            # since this is user-facing, we're reporting passlib's name,
            # without the distracting PASSLIB_HASHER_PREFIX prepended.
            (_('algorithm'), handler.name),
        ]
        if hasattr(handler, "parsehash"):
            kwds = handler.parsehash(encoded, sanitize=mask_hash)
            for key, value in iteritems(kwds):
                key = self._translate_kwds.get(key, key)
                items.append((_(key), value))
        return OrderedDict(items) 
開發者ID:haynieresearch,項目名稱:jarvis,代碼行數:17,代碼來源:utils.py

示例8: getorig

# 需要導入模塊: from django.utils import translation [as 別名]
# 或者: from django.utils.translation import ugettext_noop [as 別名]
def getorig(self, path, default=None):
        """return original (unpatched) value for path"""
        try:
            value, _= self._state[path]
        except KeyError:
            value = self._get_path(path)
        return default if value is _UNSET else value 
開發者ID:haynieresearch,項目名稱:jarvis,代碼行數:9,代碼來源:utils.py

示例9: delete

# 需要導入模塊: from django.utils import translation [as 別名]
# 或者: from django.utils.translation import ugettext_noop [as 別名]
def delete(self, vm, data, **kwargs):
        """Delete VM definition"""
        if vm.is_deployed():
            raise VmIsNotOperational(_('VM is not notcreated'))

        owner = vm.owner
        dead_vm = vm.log_list
        uuid = vm.uuid
        hostname = vm.hostname
        alias = vm.alias
        zabbix_sync = vm.is_zabbix_sync_active()
        external_zabbix_sync = vm.is_external_zabbix_sync_active()
        task_id = SuccessTaskResponse.gen_task_id(self.request, vm=dead_vm, owner=owner)

        # Every VM NIC could have an association to other tables. Cleanup first:
        for nic in vm.json_get_nics():
            # noinspection PyBroadException
            try:
                nic_ser = VmDefineNicSerializer(self.request, vm, nic)
                nic_ser.delete_ip(task_id)
            except Exception as ex:
                logger.exception(ex)
                continue

        # Finally delete VM
        logger.debug('Deleting VM %s from DB', vm)
        vm.delete()

        try:
            return SuccessTaskResponse(self.request, None, vm=dead_vm, owner=owner, task_id=task_id, msg=LOG_DEF_DELETE)
        finally:
            # Signal!
            vm_undefined.send(TaskID(task_id, request=self.request), vm_uuid=uuid, vm_hostname=hostname, vm_alias=alias,
                              dc=self.request.dc, zabbix_sync=zabbix_sync, external_zabbix_sync=external_zabbix_sync) 
開發者ID:erigones,項目名稱:esdc-ce,代碼行數:36,代碼來源:vm_define.py

示例10: delete

# 需要導入模塊: from django.utils import translation [as 別名]
# 或者: from django.utils.translation import ugettext_noop [as 別名]
def delete(self):
        dc, request = self.dc, self.request

        if dc.is_default():
            raise PreconditionRequired(_('Default datacenter cannot be deleted'))
        if dc.dcnode_set.exists():
            raise PreconditionRequired(_('Datacenter has nodes'))  # also "checks" DC backups
        if dc.vm_set.exists():
            raise PreconditionRequired(_('Datacenter has VMs'))
        if dc.backup_set.exists():
            raise PreconditionRequired(_('Datacenter has backups'))  # should be checked by dcnode check above

        dc_id = dc.id
        ser = self.serializer(request, dc)
        dc_bound_objects = dc.get_bound_objects()

        # After deleting a DC the current_dc is automatically set to DefaultDc by the on_delete db field parameter
        ser.object.delete()

        # Remove cached tasklog for this DC (DB tasklog entries will be remove automatically)
        delete_tasklog_cached(dc_id)

        res = SuccessTaskResponse(request, None)  # no msg => won't be logged

        # Every DC-bound object looses their DC => becomes DC-unbound
        task_id = res.data.get('task_id')

        connection.on_commit(lambda: dc_relationship_changed.send(task_id, dc_name=ser.object.name))  # Signal!

        # Update bound virt objects to be DC-unbound after DC removal
        for model, objects in dc_bound_objects.items():
            msg = LOG_VIRT_OBJECT_UPDATE_MESSAGES.get(model, None)
            if objects and msg:
                for obj in objects:
                    if obj.dc_bound:
                        # noinspection PyUnresolvedReferences
                        remove_dc_binding_virt_object(task_id, msg, obj, user=request.user, dc_id=DefaultDc.id)

        return res 
開發者ID:erigones,項目名稱:esdc-ce,代碼行數:41,代碼來源:dc_view.py

示例11: delete

# 需要導入模塊: from django.utils import translation [as 別名]
# 或者: from django.utils.translation import ugettext_noop [as 別名]
def delete(self):
        dc, net = self.request.dc, self.net

        if net.is_used_by_vms(dc=dc):
            raise PreconditionRequired(_('Network is used by some VMs'))

        ser = NetworkSerializer(self.request, net)
        net.dc.remove(dc)
        res = SuccessTaskResponse(self.request, None, obj=net, detail_dict=ser.detail_dict(), msg=LOG_NETWORK_DETACH)
        self._remove_dc_binding(res)

        return res 
開發者ID:erigones,項目名稱:esdc-ce,代碼行數:14,代碼來源:api_views.py

示例12: delete

# 需要導入模塊: from django.utils import translation [as 別名]
# 或者: from django.utils.translation import ugettext_noop [as 別名]
def delete(self):
        dc, vmt = self.request.dc, self.vmt

        if dc.vm_set.filter(template=vmt).exists():
            raise PreconditionRequired(_('Template is used by some VMs'))

        ser = self.serializer(self.request, vmt)
        vmt.dc.remove(dc)
        res = SuccessTaskResponse(self.request, None, obj=vmt, detail_dict=ser.detail_dict(), msg=LOG_TEMPLATE_DETACH)
        self._remove_dc_binding(res)

        return res 
開發者ID:erigones,項目名稱:esdc-ce,代碼行數:14,代碼來源:api_views.py


注:本文中的django.utils.translation.ugettext_noop方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。