Fakultas Ilmu Komputer UI

Commit e9528fcd authored by ISNAINI NURUL KHASANAH's avatar ISNAINI NURUL KHASANAH
Browse files

Merge branch 'master' of gitlab.cs.ui.ac.id:pmpl/class-project/kape

parents 4c993190 4da38667
Pipeline #25259 passed with stages
in 6 minutes and 15 seconds
nilai_mahasiswa = 3.4 3.5 3.6
descending = "".join(sorted(str(nilai_mahasiswa), reverse = True))
print descending
\ No newline at end of file
......@@ -205,7 +205,7 @@ class UserSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = User
fields = ('url', 'username', 'email', 'is_staff',
'company', 'supervisor', 'student')
'company', 'supervisor', 'student', 'last_login')
class RegisterSerializer(serializers.HyperlinkedModelSerializer):
......
......@@ -435,3 +435,25 @@ class ProfileUpdateTests(APITestCase):
response = self.client.patch(url, {'linkedin_url': 'this is not valid url'}, format='multipart')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
class ResponseApiLoginCompany(APITestCase):
def setUp(self):
self.username = "fesbuk"
self.password = "mo12ni34"
self.user = User(username=self.username)
self.user.set_password(self.password)
self.user.save()
def test_field_last_login_exists(self):
response = self.client.post(
'/api/login/',
{
"login-type" : "company",
"password" : self.password,
"username": self.username,
},
format="json"
)
self.assertTrue("last_login" in response.data.keys())
......@@ -84,20 +84,16 @@ class StudentViewSet(viewsets.ModelViewSet):
else:
return Response({}, status=status.HTTP_415_UNSUPPORTED_MEDIA_TYPE)
if 'github_url' in request.data.keys():
if not re.search(github_url_pattern, request.data['github_url']):
return Response({'Error': "Pastikan link github yang anda tulis benar. (Berpola : https://github.com/<username>"}, status=status.HTTP_400_BAD_REQUEST)
if 'github_url' in request.data.keys() and not re.search(github_url_pattern, request.data['github_url']):
return Response({'Error': "Pastikan link github yang anda tulis benar. (Berpola : https://github.com/<username>"}, status=status.HTTP_400_BAD_REQUEST)
if 'linkedin_url' in request.data.keys():
if not re.search(linkedin_url_pattern, request.data['linkedin_url']):
return Response({'Error': "Pastikan link linkedin yang anda tulis benar. (Berpola : https://linkedin.com/in/<username>"}, status=status.HTTP_400_BAD_REQUEST)
if 'linkedin_url' in request.data.keys() and not re.search(linkedin_url_pattern, request.data['linkedin_url']):
return Response({'Error': "Pastikan link linkedin yang anda tulis benar. (Berpola : https://linkedin.com/in/<username>"}, status=status.HTTP_400_BAD_REQUEST)
if 'hackerrank_url' in request.data.keys():
if not re.search(hackerrank_url_pattern, request.data['hackerrank_url']):
return Response({'Error': "Pastikan link hackerrank yang anda tulis benar. (Berpola : https://hackerrank.com/<username>"}, status=status.HTTP_400_BAD_REQUEST)
if 'hackerrank_url' in request.data.keys() and not re.search(hackerrank_url_pattern, request.data['hackerrank_url']):
return Response({'Error': "Pastikan link hackerrank yang anda tulis benar. (Berpola : https://hackerrank.com/<username>"}, status=status.HTTP_400_BAD_REQUEST)
serializer = self.serializer_class(
user, data=request.data, partial=True)
serializer = self.serializer_class(user, data=request.data, partial=True)
if serializer.is_valid():
if serializer.validated_data.get('skills') is not None and serializer.validated_data.get('skills').isdigit():
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
......
import requests
from django.conf import settings
API_MAHASISWA = "https://api.cs.ui.ac.id/siakngcs/mahasiswa/"
API_RIWAYAT_MAHASISWA = API_MAHASISWA+'{npm}/riwayat/'
API_VERIFY_USER = "https://akun.cs.ui.ac.id/oauth/token/verify/"
def get_access_token(username, password):
try:
url = "https://akun.cs.ui.ac.id/oauth/token/"
......@@ -26,14 +24,14 @@ def get_client_id():
def verify_user(access_token):
print ("#get identity number")
parameters = {"access_token": access_token, "client_id": get_client_id()}
response = requests.get(API_VERIFY_USER, params=parameters)
response = requests.get(settings.API_VERIFY_USER, params=parameters)
print ("response => ", response.json())
return response.json()
def get_summary_user(access_token, npm):
print ("#get summary user => ", npm)
parameters = {"access_token": access_token, "client_id": get_client_id()}
response = requests.get(API_MAHASISWA+str(npm), params=parameters)
response = requests.get(settings.API_MAHASISWA+str(npm), params=parameters)
print ("response => ", response.text)
print ("response => ", response.json())
return response.json()
......@@ -41,7 +39,7 @@ def get_summary_user(access_token, npm):
def get_riwayat_user(access_token, npm):
print ("#get riwayat user => ", npm)
parameters = {"access_token": access_token, "client_id": get_client_id()}
response = requests.get(API_RIWAYAT_MAHASISWA.format(npm=npm), params=parameters)
response = requests.get(settings.API_RIWAYAT_MAHASISWA.format(npm=npm), params=parameters)
print ("response => ", response.text)
print ("response => ", response.json())
return response.json()
......@@ -197,4 +197,8 @@ API_CS_CREDENTIALS = {'user': 'kape', 'password': 'yukcarikape'}
# 250MB - 214958080
# 500MB - 429916160
# 10MB - 10485760
MAX_UPLOAD_SIZE = 5242880
\ No newline at end of file
MAX_UPLOAD_SIZE = 5242880
API_MAHASISWA = "https://api.cs.ui.ac.id/siakngcs/mahasiswa/"
API_RIWAYAT_MAHASISWA = API_MAHASISWA+'{npm}/riwayat/'
API_VERIFY_USER = "https://akun.cs.ui.ac.id/oauth/token/verify/"
\ No newline at end of file
Markdown is supported
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