Added Endpoints and DB model to README.md
This commit is contained in:
parent
38f66a2584
commit
79711f1423
3 changed files with 39 additions and 3 deletions
35
README.md
35
README.md
|
@ -3,3 +3,38 @@
|
|||
Zoals besproken op de eerste bestuursvergadering.
|
||||
|
||||
! Work in progress, dingen zijn nog shit en moeten nog gefixed worden, beware
|
||||
|
||||
## Endpoints
|
||||
|
||||
### Geen authenticatie
|
||||
|
||||
- `/users`: Alle users en hun achievements, volledig
|
||||
- `/users/<username>`: Alle data over de user `username`
|
||||
- `/login` en `/logout`: Laat de user aan- en afmelden
|
||||
- `/achievement/<id>`: Alle data over die specifieke achievement
|
||||
|
||||
### Enkel bereikbaar na aanmelden
|
||||
|
||||
- `/users/<username>/addachievement?name=XYZ`: Maakt een nieuw achievement aan bij `username` met naam `XYZ` en laat de ingelogde persoon endorsen
|
||||
- `/achievement/<id>/endorse`: Voegt de ingelogde persoon toe aan `endorsed_by` van achievement `id`
|
||||
- `/achievement/<id>/unendorse`: Verwijdert de ingelogde persoon van `endorsed_by` van achievement `id`
|
||||
|
||||
## DB model
|
||||
|
||||
### User
|
||||
|
||||
| name | type | nullable | uniek | beschrijving |
|
||||
|--------|------------|----------|-------|--------------|
|
||||
| **id** | String(80) | False | True | de username |
|
||||
|
||||
### Achievement
|
||||
|
||||
| name | type | nullable | uniek | beschrijving |
|
||||
|-------------|---------------|----------|-------|----------------------------------|
|
||||
| **id** | Integer | False | True | unieke id |
|
||||
| name | String(128) | False | False | beschrijving van de achievement |
|
||||
| achieved_by | FK -> user.id | False | False | wie de achievement gehaald heeft |
|
||||
|
||||
### Endorses
|
||||
|
||||
Relatie tussen `User` en `Achievement`
|
|
@ -41,7 +41,8 @@ class Achievement(db.Model):
|
|||
return {
|
||||
"id": self.id,
|
||||
"name": self.name,
|
||||
"endorsed_by": [x.id for x in self.endorsed_by], # Don't show full user object to avoid infinite loops
|
||||
"endorsed_by": ([x.id for x in self.endorsed_by]), # Don't show full user object to avoid infinite loops
|
||||
"achieved_by": self.achieved_by
|
||||
}
|
||||
|
||||
def __repr__(self):
|
||||
|
|
2
user.py
2
user.py
|
@ -6,7 +6,7 @@ from flask_login import current_user, login_required
|
|||
|
||||
import json
|
||||
|
||||
@app.route("/users/<id>/add_achievement")
|
||||
@app.route("/users/<id>/addachievement")
|
||||
@login_required
|
||||
def add_achievement(id):
|
||||
name = request.args.get("name")
|
||||
|
|
Loading…
Reference in a new issue