Пример #1
0
    def new(self, received_dict):

        store = self.getStore()

        self.files = []
        self.receivers = []
        self.mark = self._marker[0] # 'incomplete'

        self.creation_time = gltime.utcDateNow()
        # TODO with gltimes completed, just gltime.utcTimeNow(associated_c.submission_expire)
        self.expiration_time = gltime.utcFutureDate(seconds=1, minutes=1, hours=1)

        try:
            self._import_dict(received_dict)
        except KeyError, e:
            raise InvalidInputFormat("Submission initialization failed (missing %s)" % e)
Пример #2
0
    def force_execution(self, aps=None, seconds=0):
        """
        @aps: Advanced Python Scheduler object
        seconds: number of seconds to await before operation start
        """

        if not seconds:
            self.operation()
        else:
            # this hours=1 need to be managed with CEST/CET timezone checks
            plan_exec = gltime.utcFutureDate(hours=1, seconds=seconds)

            print "Stored execution of %s postpone to %s" % \
                  (self.__class__.__name__, gltime.prettyDateTime(plan_exec) )

            aps.add_date_job(self.operation, plan_exec)
Пример #3
0
    def new(self, context_gus):

        store = self.getStore('new submission')

        try:
            associated_c = store.find(Context, Context.context_gus == context_gus).one()
        except NotOneError:
            store.close()
            raise ContextGusNotFound
        if associated_c is None:
            store.close()
            raise ContextGusNotFound

        submission = Submission()
        submission.submission_gus = idops.random_submission_gus(False)

        submission.context_gus = context_gus
        submission.context = associated_c

        # XXX this was important and actually IS bugged -- review that /me vecna
        # submission.receivers = associated_c.get_receivers('public')
        submission.receivers = associated_c.receivers
        # XXX this was important and actually IS bugged -- review that /me vecna

        submission.files = {}

        # TODO submission.context.update_stats()

        submission.creation_time = gltime.utcDateNow()
        submission.expiration_time = gltime.utcFutureDate(seconds=1, minutes=1, hours=1)

        store.add(submission)
        store.commit()

        submissionDesc = submission._description_dict()
        log.debug("[D] submission created", submission._description_dict())

        store.close()

        return submissionDesc
Пример #4
0
        except KeyError, e:
            raise InvalidInputFormat("InternalTip initialization failed (missing %s)" % e)
        except TypeError, e:
            raise InvalidInputFormat("InternalTip initialization failed (wrong %s)" % e)

        # Align the References
        self.context = self.store.find(Context, Context.context_gus == self.context_gus).one()

        # these value are copied from self.context, and are the only of internaltip
        # that can be changed (by the admin them using update_inner_values() )
        self.escalation_threshold = self.context.escalation_threshold
        self.access_limit = self.context.tip_max_access
        self.download_limit = self.context.file_max_download

        self.expiration_date = gltime.utcFutureDate(hours=(self.context.tip_timetolive * 24))
        # self.expiration_date = gltime.utcFutureDate(self.context.tip_timetolive)
        # TODO issue #36: https://github.com/globaleaks/GLBackend/issues/36

        # Initialization values
        self.pertinence_counter = 0
        self.mark = self._marker[0] # new

        self.store.add(self)
        return self._description_dict()


    # And "update" ? NO! no one can update an InternalTip - NEVER!!1!
    # http://i61.photobucket.com/albums/h63/freecodesource/funny/pictures/funny_signs_6.jpg