bounswe / 2021SpringGroup4

This is the project repository of Group 4 for Boğaziçi University's Fundamentals of Software Engineering course.
2 stars 1 forks source link

Backend: Implementing badges #184

Closed kerimoglutolga closed 2 years ago

kerimoglutolga commented 2 years ago

Description

Badges are a central feature of our application as users can reflect their opinion of other players they have played with by granting them badges after participating in events together. They can be used to evaluate both other players and the event organizer. A baseline set of badges must be decided upon and the relevant endpoints for granting badges must be created.

Files The badges functionality should live under backend/api/badges.

kerimoglutolga commented 2 years ago

Done! Find the pull request here: https://github.com/bounswe/2021SpringGroup4/pull/181

Initially, 8 badges are decided upon and tagged with Wikidata.

Endpoint for granting badges: /api/badges/ [POST]

{
    "owner": "tolga",
    "event": "1",
    "type": "Gentleman"
}

You can access a user's badges by the "badges" field on his/her profile object.

{
    "id": 1,
    "username": "tolga",
    "email": "tolga@gmail.com",
    "first_name": null,
    "last_name": null,
    "age": null,
    "about": null,
    "location": null,
    "going": [
        3
    ],
    "applied": [
        2
    ],
    "profile_picture": null,
    "badges": [
        {
            "id": 1,
            "giver": "tolga",
            "owner": "tolga",
            "event": {
                "type": "Event",
                "id": 1,
                "created": "2021-11-30T12:10:22.134589+03:00",
                "owner": "tolga",
                "content": {
                    "title": "TestEvent1",
                    "description": "This is a test event.",
                    "date": "2021-10-21",
                    "time": "21:00:00",
                    "duration": "02:00:00",
                    "location": "Istanbul",
                    "sportType": "",
                    "maxPlayers": 10,
                    "applicants": [],
                    "participants": [],
                    "comments": [
                        {
                            "id": 6,
                            "owner": "tolga",
                            "parent": 1,
                            "body": "This even is amazing!"
                        }
                    ],
                    "skill_level": "Beginner",
                    "lat": null,
                    "long": null
                }
            },
            "type": "Gentleman"
        },

    ]
}

The design choices for each badge is left to the frontend teams.