Fakultas Ilmu Komputer UI

Commit c9659bf3 authored by Ilham Darmawan Candra Purnama's avatar Ilham Darmawan Candra Purnama
Browse files

1606882351-171

parent 06a236cf
import requests
from django.conf import settings
import views_constants
def get_access_token(username, password):
try:
url = "https://akun.cs.ui.ac.id/oauth/token/"
url = views_constants.URL_AKUN_CS_UI
payload = "username=" + username + "&password=" + password + "&grant_type=password"
payload = views_constants.PARAM_USERNAME + username + "&" + views_constants.PARAM_PASSWORD + password + "&" + \
views_constants.PARAM_GRANT_TYPE + views_constants.PASSWORD
headers = {
'authorization': "Basic WDN6TmtGbWVwa2RBNDdBU05NRFpSWDNaOWdxU1UxTHd5d3U1V2VwRzpCRVFXQW43RDl6a2k3NEZ0bkNpWVhIRk50Ymg3eXlNWmFuNnlvMU1uaUdSVWNGWnhkQnBobUU5TUxuVHZiTTEzM1dsUnBwTHJoTXBkYktqTjBxcU9OaHlTNGl2Z0doczB0OVhlQ3M0Ym1JeUJLMldwbnZYTXE4VU5yTEFEMDNZeA==",
'cache-control': "no-cache",
'content-type': "application/x-www-form-urlencoded"
'authorization': views_constants.HEADER_AUTH,
'cache-control': views_constants.HEADER_NO_CACHE,
'content-type': views_constants.HEADER_CONTENT_TYPE
}
response = requests.request("POST", url, data=payload, headers=headers)
response = requests.request(views_constants.METHOD_POST, url, data=payload, headers=headers)
return response.json()["access_token"]
return response.json()[views_constants.ACCESS_TOKEN]
except Exception as e:
return None
def get_client_id():
client_id = 'X3zNkFmepkdA47ASNMDZRX3Z9gqSU1Lwywu5WepG'
return client_id
return views_constants.CLIENT_ID_VALUE
def verify_user(access_token):
print ("#get identity number")
parameters = {"access_token": access_token, "client_id": get_client_id()}
parameters = {views_constants.ACCESS_TOKEN: access_token, views_constants.CLIENT_ID: get_client_id()}
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()}
parameters = {views_constants.ACCESS_TOKEN: access_token, views_constants.CLIENT_ID: get_client_id()}
response = requests.get(settings.API_MAHASISWA + str(npm), params=parameters)
print ("response => ", response.text)
print ("response => ", response.json())
return response.json()
def get_riwayat_user(access_token, npm):
print ("#get riwayat user => ", npm)
parameters = {"access_token": access_token, "client_id": get_client_id()}
parameters = {views_constants.ACCESS_TOKEN: access_token, views_constants.CLIENT_ID: get_client_id()}
response = requests.get(settings.API_RIWAYAT_MAHASISWA.format(npm=npm), params=parameters)
print ("response => ", response.text)
print ("response => ", response.json())
return response.json()
This diff is collapsed.
ERROR_OPEN_TIME_GREATER_THAN_CURRENT_TIME = 'Waktu buka lowongan harus lebih dari hari ini!'
ERROR_OPEN_TIME_GREATER_THAN_CLOSE_TIME = 'Waktu tutup lowongan harus lebih dari waktu buka lowongan!'
ERROR_OPEN_TIME_EQUALS_CLOSE_TIME = 'Waktu tutup dan buka lowongan tidak boleh sama!'
ERROR_NAME_MUST_ALPHABET = 'Name must alphabets only'
ERROR_SALARY_MUST_NUMBER = 'Salary must number only'
ERROR_AMOUNT_MUST_NUMBER = 'Amount must number only'
ERROR_RESPONSIBILITIES_MUST_STRING = 'Responsibilities must be string'
ERROR_INVALID_RECRUITER_RESPONSE = 'Tingkat Respons Perekrut harus salah satu dari Selalu, Sering, Kadang, Jarang, ' \
'dan Tidak Pernah!'
ERROR_VACANCY_ALREADY_APPLIED = 'You have already applied for the vacancy'
ERROR_COMPANY_DOES_NOT_EXIST = 'No company exists with that ID'
ERROR_VACANCY_CLOSED = 'vacancy is closed'
ERROR_INVALID_STATUS_CODE = 'status must be an integer between 0 and 4'
ERROR_FORBIDDEN = 'forbidden'
ERROR_BAD_REQUEST = 'bad request'
ACTION_LIST = 'list'
ACTION_PARTIAL_UPDATE = 'partial_update'
ACTION_RETRIEVE = 'retrieve'
ACTION_UPDATE = 'update'
HEADER_AUTH = 'Basic WDN6TmtGbWVwa2RBNDdBU05NRFpSWDNaOWdxU1UxTHd5d3U1V2VwRzpCRVFXQW43RDl6a2k3NEZ0bkNpWVhIRk50Ymg3eXlNWmFuNnlvMU1uaUdSVWNGWnhkQnBobUU5TUxuVHZiTTEzM1dsUnBwTHJoTXBkYktqTjBxcU9OaHlTNGl2Z0doczB0OVhlQ3M0Ym1JeUJLMldwbnZYTXE4VU5yTEFEMDNZeA=='
HEADER_CONTENT_TYPE = 'application/x-www-form-urlencoded'
HEADER_NO_CACHE = 'no-cache'
CLIENT_ID_VALUE = 'X3zNkFmepkdA47ASNMDZRX3Z9gqSU1Lwywu5WepG'
URL_AKUN_CS_UI = 'https://akun.cs.ui.ac.id/oauth/token/'
METHOD_GET = 'get'
METHOD_PATCH = 'patch'
METHOD_POST = 'POST'
ORDER_ASCENDING = 'ascending'
ORDER_DESCENDING = 'descending'
ORDER_STUDENT = 'student'
ORDER_UPDATED = '-updated'
PARAM_GRANT_TYPE = 'grant_type='
PARAM_PASSWORD = 'password='
PARAM_USERNAME = 'username='
ACCESS_TOKEN = 'access_token'
AMOUNT = 'amount'
BENEFITS = 'benefits'
CLIENT_ID = 'client_id'
CLOSE_TIME = 'close_time'
COMPANY = 'company'
COUNT = 'count'
COUNT_NEW = 'count_new'
COVER_LETTER = 'cover_letter'
DESCRIPTION = 'description'
ERROR = 'error'
IS_VALID = 'is_valid'
MAX_ACCEPTED_APPLICANTS = 'max_accepted_applicants'
NAME = 'name'
OPEN_TIME = 'open_time'
OPENED_ONLY = 'opened_only'
ORDERING = 'order'
PASSWORD = 'password'
REASON = 'reason'
RECRUITER_ACTIVITY = 'recruiter_activity'
REQUEST = 'request'
REQUIREMENTS = 'requirements'
RESPONSIBILITIES = 'responsibilities'
SALARY = 'salary'
SEARCH = 'search'
SORT = 'sort'
STATUS = 'status'
TAG = 'tag'
VACANCY = 'vacancy'
VACANCY_ID = 'vacancy_id'
VERIFIED = 'verified'
WORKING_PERIOD = 'working_period'
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