Fakultas Ilmu Komputer UI

Commit 51ab2d3e authored by Reyhan Alhafizal Hamidi's avatar Reyhan Alhafizal Hamidi
Browse files

Merge branch '1706040082-50' into 'master'

[#50] Fix codesmell from Share Materi via Google Drive

See merge request !44
parents 70f3b991 5fb92e5b
Pipeline #58170 passed with stages
in 24 minutes and 8 seconds
......@@ -13,7 +13,8 @@ from django.core.files import File
from django.core.exceptions import PermissionDenied, ValidationError
from django.core.files.uploadedfile import SimpleUploadedFile
from django.core.management import call_command
from django.urls import resolve, reverse
from django.test import Client, TestCase, TransactionTestCase
from django.urls import resolve
from django.db.utils import IntegrityError
from django.test import Client, RequestFactory, TestCase, TransactionTestCase
from pytz import timezone
......@@ -479,7 +480,6 @@ class DetailMateriTest(TestCase):
self.assertEqual(last_url, "/materi/%d/" % self.materi1.id)
self.assertEqual(status_code, 302)
class PostsViewTest(TestCase):
@classmethod
def generate_posts_data(cls, user):
......
......@@ -7,7 +7,8 @@ from django.contrib import messages
from django.contrib.auth.models import AnonymousUser
from django.core.exceptions import PermissionDenied, ValidationError
from django.db.models import Q, Count
from django.http import Http404, HttpResponse, HttpResponseRedirect, JsonResponse
from django.http import (Http404, HttpResponse, HttpResponseRedirect,
JsonResponse)
from django.urls import reverse
from django.shortcuts import get_object_or_404, redirect
from django.template import loader
......@@ -32,11 +33,11 @@ from authentication.models import User
import django
import pandas as pd
from io import BytesIO
from django.contrib import messages
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from pydrive.auth import AuthenticationRejected
def permission_denied(request, exception, template_name="error_403.html"):
return defaults.permission_denied(request, exception, template_name)
......@@ -858,10 +859,8 @@ def save_to_gdrive(request, pk):
path = materi.content.path
file_path = os.path.join(settings.MEDIA_ROOT, path)
if os.path.exists(file_path):
with open(file_path, "rb") as fh:
upload_to_gdrive(file_path, materi.title)
else:
raise Http404("File tidak dapat ditemukan.")
return HttpResponseRedirect(reverse("detail-materi", kwargs={"pk": pk}))
return HttpResponseRedirect(reverse('detail-materi', kwargs={'pk': pk}))
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment