The backend admin page can be visited on https://nus-scheduler-backend.herokuapp.com/admin/, but requires a superuser or admin account to access.
If you are on windows, the following commands may not be compatible with Windows PowerShell or Command Prompt. We recommend to use WSL2.
-
Follow these guides for installation:
-
Type these step-by-step instructions into your terminal.
-
Clone the repository
https://github.com/GoneWildOrbital2020/NUS-scheduler-backend.git
-
Create virtual environment
cd NUS-scheduler-backend virtualenv venv
-
Install dependencies
source venv/bin/activate cd scheduler pip3 install -r requirements.txt
-
Create database
Openpsql
terminal:sudo su postgres psql
Create user:
CREATE USER [your username] WITH PASSWORD [your user's password];
Create database:
CREATE DATABASE [database name] WITH OWNER [your username];
-
-
-
Run the frontend locally
Follow this guide:
https://github.com/GoneWildOrbital2020/nus-scheduler-frontend -
Configure the database
FromNUS-scheduler-backend
, go toscheduler/scheduler/settings.py
and search forDATABASES
. Edit according to your created database.DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': [your database name], 'USER': [owner of database], 'PASSWORD': [user password], 'HOST': 'localhost', 'PORT': '5432' } }
-
Run the backend
FromNUS-scheduler-backend
cd scheduler python3 manage.py migrate python3 manage.py runserver
-
-
Get, create or update events in a specific day.
Request
{ method: 'GET', headers: { "Authorization": `Bearer ${token}`, }, }
Response
[ { "model": ..., "pk": ..., "fields": { "index": ..., "title": ..., "description": ..., "start": ..., "end": ..., "location": ..., "color": ..., "day": ..., "group": ..., "repeated_event": ... } } ]
Request
{ method: "POST", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${token}`, }, body: [{ "index": ..., "color": ..., "title": ..., "description": ..., "start": ..., "end": ..., "location": ..., }] }
Response
{}
-
Get events in a specific month.
Request
{ method: "GET", headers: { "Authorization": `Bearer ${token}`, }, }
Response
[ { "id": ..., "day": ..., "index": ..., "title": ..., "description": ..., "start": ..., "end": ..., "location": ..., "color": ..., "group": ..., "repeated_event": ... }, ]
-
Delete a specific year.
Request
{ method: "POST", headers: { "Authorization": `Bearer ${token}`, }, }
Response
{}
-
Delete a specific year.
Request
{ method: "POST", headers: { "Authorization": `Bearer ${token}`, }, }
Response
{}
-
Check if a year is a leap year.
Request
{ method: "GET", headers: { "Authorization": `Bearer ${token}`, }, }
Response
{ "leap": ... }
-
Get all years that have been created.
Request
{ method: "GET", headers: { "Authorization": `Bearer ${token}`, }, }
Response
[ { "model": ..., "pk": ..., "fields": { "index": ..., "user": ..., "is_leap": ... } } ]
-
Get the number of events in a specific year.
Request
{ method: "GET", headers: { "Authorization": `Bearer ${token}`, }, }
Response
{ "count": ... }
-
Create a new repeated event.
Request
{ method: "POST", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${token}`, }, body: { "name": ..., } }
Response
{ "id": ... }
-
Parse .ics file from NUSMods and update the scheduler.
Request
{ method: "POST", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${token}`, }, body: { "ics": ..., } }
Response
{}
-
Get or delete an event group.
Request
{ method: "GET", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${token}`, }, body: { "name": ..., } }
Response
{ "name": ..., "rep": [ { "name": ..., "events": [ { "index": ..., "title": ..., "description": ..., "start": ..., "end": ..., "location": ..., "color": ..., "day": ..., "month": ..., "year": ..., "id": ... } ] } ] }
Request
{ method: "DELETE", headers: { "Authorization": `Bearer ${token}`, }, }
Response
{}
-
Update or delete a specific event.
Request
{ method: "PUT", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${token}`, }, body: { "title": ..., "description": ..., "start": ..., "end": ..., "location": ..., "color": ..., } }
Response
{}
Request
{ method: "DELETE", headers: { "Authorization": `Bearer ${token}`, }, }
Response
{}
-
Get all event group or create a new one.
Request
{ method: "POST", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${token}`, }, body: { "name": ..., } }
Response
{}
Request
{ method: "GET", headers: { "Authorization": `Bearer ${token}`, }, }
Response
[ { "model": ..., "pk": ..., "fields": { "name": ... } } ]
-
Delete all a specific event group.
Request
{ method: "DELETE", headers: { "Authorization": `Bearer ${token}`, }, }
Response
{}
-
Delete or update all events in an activity or create a new event in an activity.
Request
{ method: "DELETE", headers: { "Authorization": `Bearer ${token}`, }, }
Response
{}
Request
{ method: "PUT", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${token}`, }, body: { "data": { "title": ..., "description": ..., "start": ..., "end": ..., "location": ..., "color": ..., }, }, }
Response
{}
Request
{ method: "POST", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${token}`, }, body: { "data": { "title": ..., "description": ..., "start": ..., "end": ..., "location": ..., "color": ..., }, "day": ..., "month": ..., "year": ..., }, }
Response
{ "color": ..., "day": ..., "description": ..., "end": ..., "id": ..., "index": ..., "location": ..., "month": ..., "start": ..., "title": ..., "year": ... }
-
Delete or update a task.
Request
{ method: "DELETE", headers: { "Authorization": `Bearer ${token}`, }, }
Response
{}
Request
{ method: "PUT", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${token}`, }, body: { "data": { "index": ..., "column_id": ..., }, }, }
Response
{}
-
Get all tasks or create a new task.
Request
{ method: "POST", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${token}`, }, body: { "data": { "title": ..., "description": ..., "due_date": ..., "column_id": ..., "index": ..., }, }, }
Response
{ "id": ... }
Request
{ method: "GET", headers: { "Authorization": `Bearer ${token}`, }, }
Response
[ { "model": ..., "pk": ..., "fields": { "title": ..., "description": ..., "due_date": ..., "column_id": ..., "index": ..., "event_group": ... } } ]
-
Upload file to database.
Request
FormData keys: "identifier", "name", "file" { method: "POST", headers: { "Authorization": `Bearer ${token}`, }, body: FormData() }
Response
{ "identifier": ..., "file": ..., "name": ... }
-
Upload image to database.
Request
FormData keys: "identifier", "name", "image" { method: "POST", headers: { "Authorization": `Bearer ${token}`, }, body: FormData() }
Response
{ "identifier": ..., "image": ..., "name": ... }
-
Upload note to database.
Request
{ method: "POST", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${token}`, }, body: { "identifier": ..., "total": ..., "title": ..., "text": ..., }, }
Response
{ "identifier": ..., "title": ..., "text": ... }
-
Get all files for a specific event group.
Request
{ method: "GET", headers: { "Authorization": `Bearer ${token}`, }, }
Response
[ { "model": ..., "pk": ..., "fields": { "identifier": ..., "name": ..., "file": ..., "group": ..., "created_date": ... } } ]
-
Get all images for a specific event group.
Request
{ method: "GET", headers: { "Authorization": `Bearer ${token}`, }, }
Response
[ { "model": ..., "pk": ..., "fields": { "identifier": ..., "name": ..., "image": ..., "group": ..., "created_date": ... } } ]
-
Get all notes for a specific event group.
Request
{ method: "GET", headers: { "Authorization": `Bearer ${token}`, }, }
Response
[ { "model": ..., "pk": ..., "fields": { "identifier": ..., "title": ..., "text": ..., "group": ..., } } ]
-
Delete a note.
Request
{ method: "POST", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${token}`, }, body: { "identifier": ..., }, }
Response
{}
-
Delete a file or image.
Request
{ method: "POST", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${token}`, }, body: { "identifier": ..., }, }
Response
{}
-
Get the number of notes a user has created.
Request
{ method: "GET", headers: { "Authorization": `Bearer ${token}`, }, }
Response
{ "total": ... }
-
Get the number of files and images a user has created.
Request
{ method: "GET", headers: { "Authorization": `Bearer ${token}`, }, }
Response
{ "total": ... }
-
Create a new account.
Request
{ method: "POST", headers: { "Content-Type": "application/json", }, body: { "email": ..., "username": ..., "password": ..., }, }
Response
{ "email": ..., "username": ..., "date_joined": ... }
-
Login to an account.
Request
{ method: "POST", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${token}`, }, body: { "email": ..., "password": ..., }, }
Response
{ "email": ..., "username": ..., "token": ..., "logout_time": ..., "avatar": ... }
-
Update user credentials.
Request
FormData keys: "email", "username", "avatar", "password" { method: "POST", headers: { "Authorization": `Bearer ${token}`, }, body: FormData(), }
Response
{ "username": ..., "avatar": ... }
-
Activate an account.
Request
{ method: "POST", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${token}`, }, body: { "email": ..., }, }
Response
{ "email": ..., "username": ..., "token": ..., "logout_time": ..., "avatar": ... }
-
Create reset password link.
Request
{ method: "POST", headers: { "Content-Type": "application/json", }, body: { "email": ..., }, }
Response
{}
-
Reset password of an account.
Request
{ method: "POST", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${token}`, }, body: { "email": ..., "password": ..., }, }
Response
{}