コード例 #1
0
ファイル: globaleaks.py プロジェクト: hellais/GlobaLeaks
 def create_tulip(self, leak_id, target):
     """
     Creates a tulip for the target and inserts it into the db
     """
     tulip = self._db.tulip.insert(
         url=randomizer.generate_tulip_url(),
         leak_id=leak_id,
         target_id=target.id, #FIXME get target_id_properly
         allowed_accesses=0, # inf
         accesses_counter=0,
         allowed_downloads=5,
         downloads_counter=0,
         expiry_time=0)
     self._db.commit()
     return tulip
コード例 #2
0
    def create_tulip(self, leak_id, target_id, hardcoded_url=None):
        """
        Creates a tulip for the target, and inserts it into the db
        (when target is 0, is the whitleblower and hardcoded_url is set by the caller)
        """
        if hardcoded_url and target_id:
            logger.error("Invalid usage of create_tulip: url and target specifyed")
            return NoneType

        tulip = self._db.tulip.insert(
            url= hardcoded_url if hardcoded_url else randomizer.generate_tulip_url(),
            leak_id=leak_id,
            target_id=target_id,
            allowed_accesses=settings.tulip.max_access,
            accesses_counter=0,
            allowed_downloads=0 if not target_id else settings.tulip.max_download,
            downloads_counter=0,
            expiry_time=settings.tulip.expire_days)
        self._db.commit()
        return tulip