Python django.utils.translation.ugettext_noop() Examples
The following are 30
code examples of django.utils.translation.ugettext_noop().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
django.utils.translation
, or try the search function
.
Example #1
Source File: api_views.py From esdc-ce with Apache License 2.0 | 6 votes |
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)
Example #2
Source File: api_views.py From esdc-ce with Apache License 2.0 | 6 votes |
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)
Example #3
Source File: performance.py From edx-analytics-dashboard with GNU Affero General Public License v3.0 | 6 votes |
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
Example #4
Source File: dc_view.py From esdc-ce with Apache License 2.0 | 5 votes |
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
Example #5
Source File: hashers.py From python2017 with MIT License | 5 votes |
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
Example #6
Source File: hashers.py From python2017 with MIT License | 5 votes |
def safe_summary(self, encoded): algorithm, salt, hash = encoded.split('$', 2) assert algorithm == self.algorithm return OrderedDict([ (_('algorithm'), algorithm), (_('salt'), mask_hash(salt, show=2)), (_('hash'), mask_hash(hash)), ])
Example #7
Source File: hashers.py From python2017 with MIT License | 5 votes |
def safe_summary(self, encoded): assert encoded.startswith('sha1$$') hash = encoded[6:] return OrderedDict([ (_('algorithm'), self.algorithm), (_('hash'), mask_hash(hash)), ])
Example #8
Source File: hashers.py From python2017 with MIT License | 5 votes |
def safe_summary(self, encoded): return OrderedDict([ (_('algorithm'), self.algorithm), (_('hash'), mask_hash(encoded, show=3)), ])
Example #9
Source File: hashers.py From python2017 with MIT License | 5 votes |
def safe_summary(self, encoded): algorithm, salt, data = encoded.split('$', 2) assert algorithm == self.algorithm return OrderedDict([ (_('algorithm'), algorithm), (_('salt'), salt), (_('hash'), mask_hash(data, show=3)), ])
Example #10
Source File: utils.py From jarvis with GNU General Public License v2.0 | 5 votes |
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)
Example #11
Source File: utils.py From jarvis with GNU General Public License v2.0 | 5 votes |
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
Example #12
Source File: vm_define.py From esdc-ce with Apache License 2.0 | 5 votes |
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)
Example #13
Source File: hashers.py From GTDWeb with GNU General Public License v2.0 | 5 votes |
def safe_summary(self, encoded): algorithm, empty, algostr, work_factor, data = encoded.split('$', 4) assert algorithm == self.algorithm salt, checksum = data[:22], data[22:] return OrderedDict([ (_('algorithm'), algorithm), (_('work factor'), work_factor), (_('salt'), mask_hash(salt)), (_('checksum'), mask_hash(checksum)), ])
Example #14
Source File: api_views.py From esdc-ce with Apache License 2.0 | 5 votes |
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
Example #15
Source File: api_views.py From esdc-ce with Apache License 2.0 | 5 votes |
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
Example #16
Source File: api_views.py From esdc-ce with Apache License 2.0 | 5 votes |
def __init__(self, request, name, data): super(DcStorageView, self).__init__(request) self.data = data self.name = name dc = request.dc if name: try: zpool, hostname = name.split('@') if not (zpool and hostname): raise ValueError except ValueError: raise ObjectNotFound(model=NodeStorage) attrs = {'node__hostname': hostname, 'zpool': zpool} if request.method != 'POST': attrs['dc'] = dc ns = get_object(request, NodeStorage, attrs, sr=('node', 'storage', 'storage__owner',), exists_ok=True, noexists_fail=True) ns.set_dc(dc) try: # Bug #chili-525 + checks if node is attached to Dc (must be!) ns.set_dc_node(DcNode.objects.get(node=ns.node, dc=dc)) except DcNode.DoesNotExist: raise PreconditionRequired(_('Compute node is not available')) else: # many ns = NodeStorage.objects.filter(dc=dc).order_by(*self.order_by) if self.full or self.extended: dc_nodes = {dn.node.hostname: dn for dn in DcNode.objects.select_related('node').filter(dc=request.dc)} ns = ns.select_related('node', 'storage', 'storage__owner') for i in ns: # Bug #chili-525 i.set_dc_node(dc_nodes.get(i.node.hostname, None)) i.set_dc(dc) self.ns = ns
Example #17
Source File: api_views.py From esdc-ce with Apache License 2.0 | 5 votes |
def delete(self): dc, img = self.request.dc, self.img if img.is_used_by_vms(dc=dc): raise PreconditionRequired(_('Image is used by some VMs')) ser = self.serializer(self.request, img) img.dc.remove(dc) res = SuccessTaskResponse(self.request, None, obj=img, detail_dict=ser.detail_dict(), msg=LOG_IMAGE_DETACH) self._remove_dc_binding(res) return res
Example #18
Source File: api_views.py From esdc-ce with Apache License 2.0 | 5 votes |
def delete(self): dc, domain = self.request.dc, self.domain if dc.settings.VMS_VM_DOMAIN_DEFAULT == domain.name: raise ExpectationFailed(_('Default VM domain cannot be removed from datacenter')) ser = DomainSerializer(self.request, domain) DomainDc.objects.filter(dc=dc, domain_id=domain.id).delete() res = SuccessTaskResponse(self.request, None, obj=domain, detail_dict=ser.detail_dict(), msg=LOG_DOMAIN_DETACH) self._remove_dc_binding(res) return res
Example #19
Source File: api_views.py From esdc-ce with Apache License 2.0 | 5 votes |
def delete(self): self._check_node() ns, img = self.ns, self.img zpool = ns.zpool for vm in ns.node.vm_set.all(): if img.uuid in vm.get_image_uuids(zpool=zpool): raise PreconditionRequired(_('Image is used by some VMs')) return self._run_execute(LOG_IMG_DELETE, 'imgadm delete -P %s %s 2>&1' % (ns.zpool, img.uuid), img.DELETING)
Example #20
Source File: hashers.py From python2017 with MIT License | 5 votes |
def safe_summary(self, encoded): (algorithm, variety, version, time_cost, memory_cost, parallelism, salt, data) = self._decode(encoded) assert algorithm == self.algorithm return OrderedDict([ (_('algorithm'), algorithm), (_('variety'), variety), (_('version'), version), (_('memory cost'), memory_cost), (_('time cost'), time_cost), (_('parallelism'), parallelism), (_('salt'), mask_hash(salt)), (_('hash'), mask_hash(data)), ])
Example #21
Source File: hashers.py From GTDWeb with GNU General Public License v2.0 | 5 votes |
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)), ])
Example #22
Source File: hashers.py From GTDWeb with GNU General Public License v2.0 | 5 votes |
def safe_summary(self, encoded): algorithm, salt, hash = encoded.split('$', 2) assert algorithm == self.algorithm return OrderedDict([ (_('algorithm'), algorithm), (_('salt'), mask_hash(salt, show=2)), (_('hash'), mask_hash(hash)), ])
Example #23
Source File: hashers.py From GTDWeb with GNU General Public License v2.0 | 5 votes |
def safe_summary(self, encoded): algorithm, salt, hash = encoded.split('$', 2) assert algorithm == self.algorithm return OrderedDict([ (_('algorithm'), algorithm), (_('salt'), mask_hash(salt, show=2)), (_('hash'), mask_hash(hash)), ])
Example #24
Source File: hashers.py From GTDWeb with GNU General Public License v2.0 | 5 votes |
def safe_summary(self, encoded): assert encoded.startswith('sha1$$') hash = encoded[6:] return OrderedDict([ (_('algorithm'), self.algorithm), (_('hash'), mask_hash(hash)), ])
Example #25
Source File: hashers.py From GTDWeb with GNU General Public License v2.0 | 5 votes |
def safe_summary(self, encoded): algorithm, salt, data = encoded.split('$', 2) assert algorithm == self.algorithm return OrderedDict([ (_('algorithm'), algorithm), (_('salt'), salt), (_('hash'), mask_hash(data, show=3)), ])
Example #26
Source File: hashers.py From openhgsenti with Apache License 2.0 | 5 votes |
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)), ])
Example #27
Source File: hashers.py From openhgsenti with Apache License 2.0 | 5 votes |
def safe_summary(self, encoded): algorithm, empty, algostr, work_factor, data = encoded.split('$', 4) assert algorithm == self.algorithm salt, checksum = data[:22], data[22:] return OrderedDict([ (_('algorithm'), algorithm), (_('work factor'), work_factor), (_('salt'), mask_hash(salt)), (_('checksum'), mask_hash(checksum)), ])
Example #28
Source File: hashers.py From openhgsenti with Apache License 2.0 | 5 votes |
def safe_summary(self, encoded): algorithm, salt, hash = encoded.split('$', 2) assert algorithm == self.algorithm return OrderedDict([ (_('algorithm'), algorithm), (_('salt'), mask_hash(salt, show=2)), (_('hash'), mask_hash(hash)), ])
Example #29
Source File: hashers.py From openhgsenti with Apache License 2.0 | 5 votes |
def safe_summary(self, encoded): algorithm, salt, hash = encoded.split('$', 2) assert algorithm == self.algorithm return OrderedDict([ (_('algorithm'), algorithm), (_('salt'), mask_hash(salt, show=2)), (_('hash'), mask_hash(hash)), ])
Example #30
Source File: hashers.py From openhgsenti with Apache License 2.0 | 5 votes |
def safe_summary(self, encoded): assert encoded.startswith('sha1$$') hash = encoded[6:] return OrderedDict([ (_('algorithm'), self.algorithm), (_('hash'), mask_hash(hash)), ])