Ejemplo n.º 1
0
 def clean_data(self):
     data = super(SoftwareService, self).clean_data()
     if not self.instance.pk:
         try:
             log = Operation.execute_action(self.instance, 'validate_creation')[0]
         except IndexError:
             pass
         else:
             if log.state != log.SUCCESS:
                 raise ValidationError(_("Validate creation execution has failed."))
             errors = {}
             if 'user-exists' in log.stdout:
                 errors['name'] = _("User with this username already exists.")
             if 'email-exists' in log.stdout:
                 errors['email'] = _("User with this email address already exists.")
             if errors:
                 raise ValidationError(errors)
     return data
Ejemplo n.º 2
0
 def clean_data(self):
     data = super(SoftwareService, self).clean_data()
     if not self.instance.pk:
         try:
             log = Operation.execute_action(self.instance, 'validate_creation')[0]
         except IndexError:
             pass
         else:
             if log.state != log.SUCCESS:
                 raise ValidationError(_("Validate creation execution has failed."))
             errors = {}
             if 'user-exists' in log.stdout:
                 errors['name'] = _("User with this username already exists.")
             if 'email-exists' in log.stdout:
                 errors['email'] = _("User with this email address already exists.")
             if errors:
                 raise ValidationError(errors)
     return data
Ejemplo n.º 3
0
def validate_path_exists(user, path):
    user.path_to_validate = path
    log = Operation.execute_action(user, "validate_path_exists")[0]
    if "path does not exists" in log.stderr:
        raise ValidationError(log.stderr)
Ejemplo n.º 4
0
def grant_permission(modeladmin, request, queryset):
    user = queryset.get()
    log = Operation.execute_action(user, 'grant_permission')