Skip to content

Commit

Permalink
Develop (#46)
Browse files Browse the repository at this point in the history
* ✨ add: users CRUD

* ✨ add: buildings CRUD and user relation

* Update README.md

* ✨ auth: created auth middleware

* authentication canvas

* 🔒 auth middleware: implemented on buildings

* 🔒 auth middleware on all endpoints

* 🐛 misstyping on auth_middleware invoking

* 📝 doc: authentication

* Feature: Create class route

* Update event schema, professors is now a vector

* ✨ feat: add users

* 🩹 fix: buildings ids list on user insertion

* ✨ users: user listing with building relations

* Update preferences schema

* Update edit class route

* Change update preferences route

* 🔒 boto config on .env

* 🛂 users: admin authorization middleware

* ✨ users: user edition

* ✨ add: delete users

* 🩹 edit user: admins has their buildings removed

* ♻️ admin middleware: refactored to use less code

* 🐛 dotenv: dotenv refreshing on repositories

* Fix class id missing prettify_id

* Change update class route

* 📝 added pendencies file

* ✨ users: introduced name and error treatment

* Fix auth middleware error

* Update auth_middleware.py

* ✨ self: created self route

* 🩹 user repository: get_by_username now with relations

* ♻️ reafactor: database name as env

* ♻️ refactor: port as enviroment

* Create new route for getting events by class

* Fix a auth middlaware bug from OPTIONS method

* 🔧 config: added .env.example

To simplify the configuration without having a dotenv

* Update auth_middleware.py

* Create new route for getting events by class

* 🔧 config: added .env.example

To simplify the configuration without having a dotenv

* 🔨 FIX: database default value

* 🩹 FIX: Removed Conflict check on getting available classes

* Create classes mappers and sorter

* Create classroom mappers and sorter

* Create event sorter

* Create vanilla allocation algorithm

* Create days map

* Create event sorter

* Create reverse days indexer

* Create new events sorter and a new event mapper

* Change allocation algorithm

* 🔥 Removed useless comments

* FIX: Organized buildings imports

* ADD: get conflicts endpoint

* FIX: conflict detecting logic

* ADD: grouped the conflicts response

* FIX: grouped the conflict response

* FIX: prettified conflicts ids

* FIX: init resets conflicts calculator

* Upgrades in allocation algorithm

* Fix a error in allocation route

* Create new get route in classrooms

* Create new route for delete single event allocation and format the code

* ADD: conflict week_day sorting

* 💩 quickfix to allocate with jupiterweb

* Add new field in classroom schema

* Create new feature to load and save a allocation

* ADD: new jupiter crawler

* ADD: crawler breakpoint safety

* FIX: id comparring issue

* DEL: removed leagacy crawler

* ADD: grouped conflicts

* REFACTOR: jupiter crawler and conflict checker

* FIX: jupiter crawler now with subject info

* FIX: subscribers property name

* FIX: added default value if classroom is null

* ADD: route to get classrooms with conflict indication

* FIX: removed conflict with self

* ADD: check lots of events

* ADD: refactor event edit and allocations

* REFACTOR: edit many allocation

* ADD: classes now return the array of events_ids that built it

* Fix mobile blueprint

* FIX: connections

* repositories singleton fix

---------

Co-authored-by: Gabriel Di Vanna Camargo <109106987+FastShowDev@users.noreply.github.com>
Co-authored-by: FastShowDev <zlFastShow@hotmail.com>
  • Loading branch information
3 people authored Feb 21, 2024
1 parent 9c9f1f6 commit 14dbe3b
Show file tree
Hide file tree
Showing 59 changed files with 2,602 additions and 455 deletions.
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
AWS_REGION=""
AWS_ACCESS_KEY_ID=""
AWS_SECRET_ACCESS_KEY=""
CONN_STR=""
USER_POOL_ID=""
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ env_uspolis

# solver generated data
*.lp

canvas/
39 changes: 37 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This is the repo for the backend of the USPolis Admin application
## Running

```bash
pip install requirements.txt
pip install -r requirements.txt
python3 wsgi.py
```

Expand Down Expand Up @@ -66,4 +66,39 @@ In this folder, we encounter some utilities for our server.

### Database

File inside Common folder, it contains the connection instantiation for ```mongodb``` database.
File inside Common folder, it contains the connection instantiation for ```mongodb``` database.

## Guides

This section aims to give the developer some usefull info about how to do some things in the stack being used.

### Schemas

#### Nesting schemas

You might want to use an existing schema as a part of a new schema. For this task, you can use ```fields.Nested(YourSchema)```, like this:

```python
class AllocatorInputSchema(Schema):
# [...]
preferences = fields.Nested(PreferencesSchema)
# [...]
```

## Authentication

### Packages

The API authentication is made through the Cognito service of AWS, using the ```boto3``` python package.

The configuration to connect to the AWS is **not** made on code, but instead on the hosting machine. The machine will need to have the AWS program installed and then connect using secrets.

[This guide](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/quickstart.html) shows how to install both ```boto3``` and ```aws``` packages.

We are using **the regular boto3 package, not the** ```boto3[crt]```, so **do not** install anything on pip, the boto3 is already on ```requirements.tx```

### Auth Middleware

In code, the Authentication is fully implemented on ```auth_middleware```. This middleware ensures the ```Authentication``` header have a valid token, and if so, it sets the ```request.user``` as the user who made the request. Worth noting that the header follow the formatting like ```Bearer {token}```.

It's needed to call the middleware function with the ```before_request``` decorator on each blueprint to be authenticated.
Loading

0 comments on commit 14dbe3b

Please sign in to comment.