Exemplo n.º 1
0
    def create(cls, issue_id, *, properties=None, auto_commit=False):
        """Creates a new Issue object with the properties and tags provided

        Attributes:
            issue_id (str): Unique identifier for the issue object
            account (:obj:`Account`): Account which owns the issue
            properties (dict): Dictionary of properties for the issue object.
        """
        if cls.get(issue_id):
            raise IssueException('Issue {} already exists'.format(issue_id))

        res = Issue()
        res.issue_id = issue_id
        res.issue_type_id = IssueType.get(cls.issue_type).issue_type_id

        if properties:
            for name, value in properties.items():
                prop = IssueProperty()
                prop.issue_id = res.issue_id
                prop.name = name
                prop.value = value.isoformat() if type(value) == datetime else value
                res.properties.append(prop)
                db.session.add(prop)

        db.session.add(res)
        if auto_commit:
            db.session.commit()

        return cls.get(res.issue_id)
Exemplo n.º 2
0
    def set_property(self, name, value):
        if type(value) == datetime:
            value = value.isoformat()
        else:
            value = value

        try:
            prop = self.get_property(name)
            if prop.value == value:
                return False

            prop.value = value

        except AttributeError:
            prop = IssueProperty()
            prop.issue_id = self.id
            prop.name = name
            prop.value = value

        db.session.add(prop)

        return True