def setShortcutValue(self, shortcut: PreferencesShortcut, value):
     previous_val = shortcut.default_value
     shortcut.default_value = value
     shortcut.save()
     auditing_service.audit_update(self.container, shortcut.tableName(),
                                   shortcut.id, "default_value",
                                   previous_val, value)
Exemple #2
0
 def onEntrypointChanged(self, entrypoint):
     previous_entrypoint = self.container.entrypoint
     self.container.entrypoint = entrypoint
     self.container.save()
     auditing_service.audit_update(self.container,
                                   self.container.tableName(),
                                   self.container.id, "entrypoint",
                                   previous_entrypoint, entrypoint)
Exemple #3
0
 def onCpuChanged(self):
     previous_cpu_limit = self.container.cpu_limit
     self.container.cpu_limit = self.ui.limit_cpu.value() / 100.0
     self.container.save()
     auditing_service.audit_update(self.container,
                                   self.container.tableName(),
                                   self.container.id, "cpu_limit",
                                   previous_cpu_limit,
                                   self.container.cpu_limit)
Exemple #4
0
 def onMemoryChanged(self):
     previous_memory_limit = self.container.memory_limit
     self.container.memory_limit = self.ui.limit_memory.value()
     self.container.save()
     auditing_service.audit_update(self.container,
                                   self.container.tableName(),
                                   self.container.id, "memory_limit",
                                   previous_memory_limit,
                                   self.container.memory_limit)
Exemple #5
0
 def onSwitched(self, check):
     previous_val = self.shortcut.enabled
     self.shortcut.enabled = check
     self.shortcut.save()
     auditing_service.audit_update(self.shortcut.container,
                                   self.shortcut.tableName(),
                                   self.shortcut.id, "enabled",
                                   previous_val, check)
     containers_service.fire(self.shortcut.container,
                             SHORTCUT_CONF_CHANGED_CHANNEL)
Exemple #6
0
 def onImageTagChange(self, index):
     if index > 0:
         tag = self.ui.image_tags.itemText(index).split(':')[1]
         previous_tag = self.container.tag
         self.container.tag = tag
         self.container.save()
         auditing_service.audit_update(self.container,
                                       self.container.tableName(),
                                       self.container.id, "tag",
                                       previous_tag, tag)
         containers_service.fire(self.container, 'tag_index', index)
 def onImageTagChange(self, full_tag_name):
     if not full_tag_name:
         return
     tag = full_tag_name.split(':')[1]
     previous_val = self.container.tag
     self.container.tag = tag
     self.container.save()
     auditing_service.audit_update(self.container,
                                   self.container.tableName(),
                                   self.container.id, "tag", previous_val,
                                   tag)
Exemple #8
0
 def setData(self, index, value, role=Qt.EditRole):
     if role == Qt.EditRole:
         record: Environment = self.array_data[index.row()]
         attr = self.header_data[index.column()]
         previous_val = getattr(record, attr)
         setattr(record, attr, value)
         record.save()
         auditing_service.audit_update(self.container, record.tableName(), record.id, attr, previous_val, value)
         return True
     else:
         return False
    def finish(self):
        if not self.ui.mapping_to.text() and self.ui.shortcut_type.currentText() != 'Constant':
            message = self._translate(self.template, 'The value of \'Mapping to\' can not be empty')
            QToolTip.showText(self.ui.mapping_to.mapToGlobal(QPoint()), message)
            return
        shortcut_type = self.ui.shortcut_type.currentText()
        mapping_to = self.ui.mapping_to.text()

        # Is create mode
        if self.is_creative_move and self.findShortcut(self.container, shortcut_type, mapping_to):
            msg = QMessageBox()
            msg.setIcon(QMessageBox.Critical)

            msg.setText(self._translate(self.template, "Preference shortcut already exists!!!"))
            msg.setInformativeText('Preference shortcut with type: %s, mapping to: %s is already exist!\n\n'
                                   'Please choose another one' % (shortcut_type, mapping_to))
            msg.setStandardButtons(QMessageBox.Ok)
            return msg.exec_()

        if self.is_creative_move:
            order = PreferencesShortcut.select().where(PreferencesShortcut.container == self.container).count() * 10000
            self.shortcut.order = order

        self.shortcut.container = self.container
        self.shortcut.label = self.ui.shortcut_label.text().strip()
        self.shortcut.default_value = self.ui.default_value.text().strip()
        self.shortcut.pref_type = self.ui.data_type.currentText().strip()
        self.shortcut.shortcut = self.ui.shortcut_type.currentText()
        self.shortcut.mapping_to = self.ui.mapping_to.text().strip()
        self.shortcut.description = self.ui.description.toPlainText().strip()

        if shortcut_service.hasChanged(self.shortcut):
            model = model_to_dict(self.shortcut)
            model_original = model_to_dict(shortcut_service.getShortcut(self.shortcut.id))
            changes = []
            for key in model:
                if model[key] != model_original[key] and key != 'id':
                    # Record changes, except label because it will not affect to the container it self
                    changes.append({'from': model_original[key], 'to': model[key], 'key': key})
            self.shortcut.save()
            if self.is_creative_move:
                auditing_service.audit_create(self.container, self.shortcut.tableName(), self.shortcut.id)
            else:
                for change in changes:
                    auditing_service.audit_update(self.container, self.shortcut.tableName(), self.shortcut.id,
                                                  change['key'], change['from'], change['to'])
        self.dialog.accept()