예제 #1
0
파일: forms.py 프로젝트: fatimahseraj/lore
    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
        })
예제 #2
0
파일: forms.py 프로젝트: dreganism/lore
    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
        })
예제 #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)
예제 #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)