Exemple #1
0
    def save(self, user_id, repo_id, session):
        """
        Receives the request.FILES from the view.

        Args:
            user_id (int): primary key of the user uploading the course.
            repo_id (int): primary key of repository we're uploading to.
            session (SessionStore): User's session to store task data.
        """
        # Assumes a single file, because we only accept
        # one at a time.
        uploaded_file = self.cleaned_data["course_file"]

        # Save the uploaded file into a temp file.
        path = default_storage.save(
            '{prefix}/{random}{ext}'.format(prefix=settings.IMPORT_PATH_PREFIX,
                                            random=str(uuid.uuid4()),
                                            ext=uploaded_file.ext),
            uploaded_file)
        task = import_file.delay(path, repo_id, user_id)

        repo_slug = Repository.objects.get(id=repo_id).slug
        # Save task data in session so we can keep track of it.
        track_task(session, task, IMPORT_TASK_TYPE, {
            "repo_slug": repo_slug,
            "path": path
        })
Exemple #2
0
    def save(self, user_id, repo_id, session):
        """
        Receives the request.FILES from the view.

        Args:
            user_id (int): primary key of the user uploading the course.
            repo_id (int): primary key of repository we're uploading to.
            session (SessionStore): User's session to store task data.
        """
        # Assumes a single file, because we only accept
        # one at a time.
        uploaded_file = self.cleaned_data["course_file"]

        # Save the uploaded file into a temp file.
        path = default_storage.save(
            '{prefix}/{random}{ext}'.format(
                prefix=settings.IMPORT_PATH_PREFIX,
                random=str(uuid.uuid4()),
                ext=uploaded_file.ext
            ),
            uploaded_file
        )
        task = import_file.delay(path, repo_id, user_id)

        repo_slug = Repository.objects.get(id=repo_id).slug
        # Save task data in session so we can keep track of it.
        track_task(session, task, IMPORT_TASK_TYPE, {
            "repo_slug": repo_slug,
            "path": path
        })
Exemple #3
0
    def save(self, user_id, repo_id):
        """
        Receives the request.FILES from the view.

        Args:
            user_id (int): primary key of the user uploading the course.
            repo_id (int): primary key of repository we're uploading to
        """
        # Assumes a single file, because we only accept
        # one at a time.
        uploaded_file = self.cleaned_data["course_file"]

        # Save the uploaded file into a temp file.
        path = default_storage.save(
            '{prefix}/{random}{ext}'.format(
                prefix=settings.IMPORT_PATH_PREFIX,
                random=str(uuid.uuid4()),
                ext=uploaded_file.ext
            ),
            uploaded_file
        )
        import_file.delay(path, repo_id, user_id)
Exemple #4
0
    def save(self, user_id, repo_id):
        """
        Receives the request.FILES from the view.

        Args:
            user_id (int): primary key of the user uploading the course.
            repo_id (int): primary key of repository we're uploading to
        """
        # Assumes a single file, because we only accept
        # one at a time.
        uploaded_file = self.cleaned_data["course_file"]

        # Save the uploaded file into a temp file.
        path = default_storage.save(
            '{prefix}/{random}{ext}'.format(
                prefix=settings.IMPORT_PATH_PREFIX,
                random=str(uuid.uuid4()),
                ext=uploaded_file.ext
            ),
            uploaded_file
        )
        import_file.delay(path, repo_id, user_id)