zenodo_accessrequests/models.py
def create(cls, title, owner, extra_data, description="", expires_at=None):
        """Create a new secret link."""
        if isinstance(expires_at, date):
            expires_at = datetime.combine(expires_at, datetime.min.time())

        with db.session.begin_nested():
            obj = cls(
                owner=owner,
                title=title,
                description=description,
                expires_at=expires_at,
                token='',
            )
            db.session.add(obj)

        with db.session.begin_nested():
            # Create token (dependent on obj.id and recid)
            obj.token = SecretLinkFactory.create_token(
                obj.id, extra_data, expires_at=expires_at
            ).decode('utf8')

        link_created.send(obj)
        return obj
def create(cls, title, owner, extra_data, description="", expires_at=None):
        if isinstance(expires_at, date):
            expires_at = datetime.combine(expires_at, datetime.min.time())

        with db.session.begin_nested():
            obj = cls(
                owner=owner,
                title=title,
                description=description,
                expires_at=expires_at,
                token='',
            )
            db.session.add(obj)

        with db.session.begin_nested():
            # Create token (dependent on obj.id and recid)
            obj.token = SecretLinkFactory.create_token(
                obj.id, extra_data, expires_at=expires_at
            ).decode('utf8')

        link_created.send(obj)
        return obj
def create ( cls , title , owner , extra_data , description = "" , expires_at = None ) : if isinstance ( expires_at , date ) : expires_at = datetime . combine ( expires_at , datetime . min . time ( ) ) with db . session . begin_nested ( ) : obj = cls ( owner = owner , title = title , description = description , expires_at = expires_at , token = '' , ) db . session . add ( obj ) with db . session . begin_nested ( ) : # Create token (dependent on obj.id and recid) obj . token = SecretLinkFactory . create_token ( obj . id , extra_data , expires_at = expires_at ) . decode ( 'utf8' ) link_created . send ( obj ) return obj
Create a new secret link.
Create a new secret link .