Skip to content

imrosun/event-scheduler-django-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prerequistes

Python should be installed

Steps to setup django app locally

Open any newly created folder using vs code or any other IDE. folder name ex: event-schedular-python Go to terminal and follow below steps.

  1. First create virtual environment
python -m venv myenv
  1. To activate venv
.\myenv\Scripts\activate
  1. Install django
pip install django
  1. To create project
git clone https://github.com/imrosun/online-code-editor-python.git

OR

django-admin startproject event_scheduler

Skip if cloned

  1. To create app inside project
cd event_scheduler
python manage.py startapp api

After this add app {'codeeditor'} inside INSTALLED_APPS on settings.py file

  1. Create superuser for database if not created
python manage.py createsuperuser
  1. Not needed if you clone, this is used to see if there has been made changes and it migrates
python manage.py makemigrations
python manage.py migrate

AND

python manage.py makemigrations api  # for api app
python manage.py migrate
  1. To run server
python manage.py runserver
  1. To host on vercel

Step 1: Go to /event_scheduler/settings.py - Update ALLOWED_HOSTS = ['.vercel.app']

    • means all and specified .vercel.app ex: ['*', '.vercel.app']

Step 2: Generate requirments.txt using command

pip freeze > requirements.txt

Step 3: Create vercel.json file in app folder or manage.py path and copy the code

API DOCUMENTATION

url: http://127.0.0.1:8000

AUTHENTICATION

  1. Register
{
  "username": "alice",
  "email": "[email protected]",
  "password": "password123"
}
  • Response: Returns username and email.
  1. Login (JWT)
  • POST /api/auth/login/
  • Body:
{
  "username": "alice",
  "password": "password123"
}
  • Response: Returns access_token: {access} and refresh_token: {refresh}. Use access as Bearer token for all further requests.
  1. Refresh Token
  • POST /api/auth/refresh/
  • Body:
{
  "refresh": "<refresh_token>"
}
  • Response: Returns refreshed access_token
  1. Logout
  • POST /api/auth/logout/
  • Headers: Authorization: Bearer <access_token>
  • Body:
{
  "refresh": "<refresh_token>"
}
  • Response: Returns successful message

EVENT MANAGEMENT

  1. Create Event
  • POST /api/events/
  • Headers: Authorization: Bearer <access_token>
  • Body:
{
  "title": "Team Meeting",
  "description": "Discuss project roadmap",
  "start_time": "2025-05-24T10:00:00Z",
  "end_time": "2025-05-24T11:00:00Z",
  "location": "Conference Room",
  "is_recurring": false,
  "recurrence_pattern": ""
}
  • Response: Returns success message
  1. List Events
  • GET /api/events/
  • Headers: Authorization: Bearer <access_token>
  • Response: Returns all events associated with the access_token
  1. Get Specific Event
  • GET /api/events/<event_id>/
  • example: http://127.0.0.1:8000/api/events/1/
  • Headers: Authorization: Bearer <access_token>
  • Response: Returns particular event associated with the access_token
  1. Update Event
  • PUT /api/events/<event_id>/
  • Headers: Authorization: Bearer <access_token>
  • Body: (any fields to update)
{
  "title": "Updated Meeting",
  "description": "Updated description"
}
  • Response: Returns successfully updated message
  1. Delete Event
  • DELETE /api/events/<event_id>/
  • Headers: Authorization: Bearer <access_token>
  • Response: Returns successfully deleted message
  1. Batch Create Events
  • POST /api/events/batch/
  • Headers: Authorization: Bearer <access_token>
  • Body:
[
  {
    "title": "Event 1",
    "description": "First event",
    "start_time": "2025-05-24T12:00:00Z",
    "end_time": "2025-05-24T13:00:00Z",
    "location": "",
    "is_recurring": false,
    "recurrence_pattern": ""
  },
  {
    "title": "Event 2",
    "description": "Second event",
    "start_time": "2025-05-25T12:00:00Z",
    "end_time": "2025-05-25T13:00:00Z",
    "location": "",
    "is_recurring": false,
    "recurrence_pattern": ""
  }
]
  • Response: Returns successfully event added message

COLLABORATION

  1. Share Event
  • POST /api/events/<event_id>/share/
  • Headers: Authorization: Bearer <access_token>
  • Body:
{
  "users": [
    {"user_id": 2, "role": "editor"},
    {"user_id": 3, "role": "viewer"}
  ]
}
  • Response: Returns list along with role and user_id
  1. List Permissions
  • GET /api/events/<event_id>/permissions/
  • Headers: Authorization: Bearer <access_token>
  • Response: Returns the permission role
  1. Update Permission
  • PUT /api/events/<event_id>/permissions/<user_id>/
  • Headers: Authorization: Bearer <access_token>
  • Body:
{
  "role": "editor"
}
  • Response: Returns permission updated
  1. Remove Permission
  • DELETE /api/events/<event_id>/permissions/<user_id>/
  • Headers: Authorization: Bearer <access_token>
  • Response: Returns permission removed

VERSION HISTORY

  1. Get Specific Version
  • GET /api/events/<event_id>/history/<version_id>/
  • Headers: Authorization: Bearer <access_token>
  • Response: Returns version history
  1. Rollback to Version
  • POST /api/events/<event_id>/rollback/<version_id>/
  • Headers: Authorization: Bearer <access_token>
  • Response: Returns rollback version

CHANGELOG AND DIFF

  1. Get Changelog
  • GET /api/events/<event_id>/changelog/
  • Headers: Authorization: Bearer <access_token>
  • Response: Returns changlog
  1. Get Diff Between Versions
  • GET /api/events/<event_id>/diff///
  • Headers: Authorization: Bearer <access_token>
  • Response: Returns version diff

About

A django based application for creating role-based access control (RBAC): Owner, Editor, and Viewer

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages