def create_value(target, value, field_name, field_type, project_id):
    if field_type.startswith('user'):
        create_user(target, value)
        value['name'] = value['name'].replace(' ', '_')
    if field_name in jira.EXISTING_FIELDS:
        return
    if field_name.lower() not in [field.name.lower() for field in target.getProjectCustomFields(project_id)]:
        if field_name.lower() not in [field.name.lower() for field in target.getCustomFields()]:
            target.createCustomFieldDetailed(field_name, field_type, False, True, False, {})
        if field_type in ['string', 'date', 'integer', 'period']:
            try:
                target.createProjectCustomFieldDetailed(
                    project_id, field_name, "No " + field_name)
            except YouTrackException, e:
                if e.response.status == 409:
                    print e
                else:
                    raise e
        else:
            bundle_name = "%s: %s" % (project_id, field_name)
            create_bundle_safe(target, bundle_name, field_type)
            try:
                target.createProjectCustomFieldDetailed(
                    project_id, field_name, "No " + field_name,
                    {'bundle': bundle_name})
            except YouTrackException, e:
                if e.response.status == 409:
                    print e
                else:
                    raise e
Exemple #2
0
def create_value(target, value, field_name, field_type, project_id):
    if field_type.startswith('user'):
        create_user(target, value)
        value['name'] = value['name'].replace(' ', '_')
        value['name'] = value['name'].replace('/', '|')
    if field_name in jira.EXISTING_FIELDS:
        return
    if field_name.lower() not in [field.name.lower() for field in target.getProjectCustomFields(project_id)]:
        if field_name.lower() not in [field.name.lower() for field in target.getCustomFields()]:
            target.createCustomFieldDetailed(field_name, field_type, False, True, False, {})
        if field_type in ['string', 'date', 'integer', 'period']:
            try:
                target.createProjectCustomFieldDetailed(
                    project_id, field_name, "No " + field_name)
            except YouTrackException, e:
                if e.response.status == 409:
                    print e
                else:
                    raise e
        else:
            bundle_name = "%s: %s" % (project_id, field_name)
            create_bundle_safe(target, bundle_name, field_type)
            try:
                target.createProjectCustomFieldDetailed(
                    project_id, field_name, "No " + field_name,
                    {'bundle': bundle_name})
            except YouTrackException, e:
                if e.response.status == 409:
                    print e
                else:
                    raise e
def create_value(target, value, field_name, field_type, project_id):
    if field_type.startswith('user'):
        create_user(target, value)
        value['name'] = value['name'].replace(' ', '_')
    if field_name in jira.EXISTING_FIELDS:
        return
    if field_name.lower() not in [field.name.lower() for field in target.getProjectCustomFields(project_id)]:
        if field_name.lower() not in [field.name.lower() for field in target.getCustomFields()]:
            target.createCustomFieldDetailed(field_name, field_type, False, True, False, {})
        if field_type in ['string', 'date', 'integer', 'period']:
            target.createProjectCustomFieldDetailed(project_id, field_name, "No " + field_name)
        else:
            bundle_name = field_name + " bundle"
            create_bundle_safe(target, bundle_name, field_type)
            target.createProjectCustomFieldDetailed(project_id, field_name, "No " + field_name, {'bundle': bundle_name})
    if field_type in ['string', 'date', 'integer', 'period']:
        return
    project_field = target.getProjectCustomField(project_id, field_name)
    bundle = target.getBundle(field_type, project_field.bundle)
    try:
        if 'name' in value:
            target.addValueToBundle(bundle, value['name'])
        elif 'value' in value:
            target.addValueToBundle(bundle, value['value'])
    except YouTrackException:
        pass
Exemple #4
0
def create_value(target, value, field_name, field_type, project_id):
    if field_type.startswith('user'):
        create_user(target, value)
        value['name'] = value['name'].replace(' ', '_')
    if field_name in jira.EXISTING_FIELDS:
        return
    if field_name.lower() not in [
            field.name.lower()
            for field in target.getProjectCustomFields(project_id)
    ]:
        if field_name.lower() not in [
                field.name.lower() for field in target.getCustomFields()
        ]:
            target.createCustomFieldDetailed(field_name, field_type, False,
                                             True, False, {})
        if field_type in ['string', 'date', 'integer']:
            target.createProjectCustomFieldDetailed(project_id, field_name,
                                                    "No " + field_name)
        else:
            bundle_name = field_name + " bundle"
            create_bundle_safe(target, bundle_name, field_type)
            target.createProjectCustomFieldDetailed(project_id, field_name,
                                                    "No " + field_name,
                                                    {'bundle': bundle_name})
    if field_type in ['string', 'date', 'integer']:
        return
    project_field = target.getProjectCustomField(project_id, field_name)
    bundle = target.getBundle(field_type, project_field.bundle)
    try:
        if 'name' in value:
            target.addValueToBundle(bundle, value['name'])
        elif 'value' in value:
            target.addValueToBundle(bundle, value['value'])
    except YouTrackException:
        pass
def create_and_attach_custom_field(target, project_id, field_name, field_type):
    normalized_name = field_name.lower()
    if normalized_name not in [field.name.lower() for field in target.getProjectCustomFields(project_id)]:
        if normalized_name not in [field.name.lower() for field in target.getCustomFields()]:
            target.createCustomFieldDetailed(field_name, field_type, False, True)
        if field_type in ["integer", "string", "date"]:
            target.createProjectCustomFieldDetailed(project_id, field_name, "No " + field_name)
        else:
            bundle_name = field_name + " bundle"
            create_bundle_safe(target, bundle_name, field_type)
            target.createProjectCustomFieldDetailed(project_id, field_name, "No " + field_name, {"bundle": bundle_name})
def create_and_attach_custom_field(target, project_id, field_name, field_type):
    normalized_name = field_name.lower()
    if normalized_name not in [field.name.lower() for field in target.getProjectCustomFields(project_id)]:
        if normalized_name not in [field.name.lower() for field in target.getCustomFields()]:
            target.createCustomFieldDetailed(field_name, field_type, False, True)
        if field_type in ["integer", "string", "date"]:
            target.createProjectCustomFieldDetailed(project_id, field_name, "No " + field_name)
        else:
            bundle_name = field_name + " bundle"
            create_bundle_safe(target, bundle_name, field_type)
            target.createProjectCustomFieldDetailed(project_id, field_name, "No " + field_name, {"bundle": bundle_name})
 def _create_field(self, project_id, field_name, field_type):
     project_fields = self._target.getProjectCustomFields(project_id)
     if field_name.lower() not in [f.name.lower() for f in project_fields]:
         all_fields = self._target.getCustomFields()
         if field_name.lower() not in [f.name.lower() for f in all_fields]:
             self._target.createCustomFieldDetailed(
                 field_name, field_type, False, True, False, {})
         if field_type in ('string', 'date', 'integer', 'float', 'period'):
             self._target.createProjectCustomFieldDetailed(
                 project_id, field_name, 'No ' + field_name)
         else:
             bundle_name = field_name + ' bundle'
             create_bundle_safe(self._target, bundle_name, field_type)
             self._target.createProjectCustomFieldDetailed(
                 project_id, field_name, 'No ' + field_name, {'bundle': bundle_name})
Exemple #8
0
 def _create_field(self, project_id, field_name, field_type):
     project_fields = self._target.getProjectCustomFields(project_id)
     if field_name.lower() not in [f.name.lower() for f in project_fields]:
         all_fields = self._target.getCustomFields()
         if field_name.lower() not in [f.name.lower() for f in all_fields]:
             self._target.createCustomFieldDetailed(
                 field_name, field_type, False, True, False, {})
         if field_type in ('string', 'date', 'integer', 'float', 'period'):
             self._target.createProjectCustomFieldDetailed(
                 project_id, field_name, 'No ' + field_name)
         else:
             bundle_name = field_name + ' bundle'
             create_bundle_safe(self._target, bundle_name, field_type)
             self._target.createProjectCustomFieldDetailed(
                 project_id, field_name, 'No ' + field_name, {'bundle': bundle_name})
    def create_fields(self, fields):
        project_fields = None
        custom_fields = None
        for field in fields:
            # optimization
            if field.lower() in self.known_fields:
                continue
            self.known_fields.append(field.lower())

            field_name, field_type = self.describe_field(field)
            if field_type is None or field_name is None:
                continue

            # case sensitive
            if field_name in jira.EXISTING_FIELDS:
                continue

            if project_fields is None:
                project_fields = self.get_pcf()
            if custom_fields is None:
                custom_fields = self.get_cf()

            if field_name.lower() in project_fields:
                continue

            if field_name.lower() not in custom_fields:
                self.create_cf(field_name, field_type)

            if field_type in ['string', 'date', 'integer', 'period']:
                try:
                    self.create_pcf(field_name, "No " + field_name)
                except YouTrackException, e:
                    if e.response.status == 409:
                        print e
                    else:
                        raise e
            else:
                bundle_name = "%s: %s" % (self.id, field_name)
                create_bundle_safe(self.target, bundle_name, field_type)
                try:
                    self.create_pcf(field_name, "No " + field_name,
                                    {'bundle': bundle_name})
                except YouTrackException, e:
                    if e.response.status == 409:
                        print e
                    else:
                        raise e