tech-with-tim / api Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
whoops
User Permission: NaN
Model To Be Fetched: Challenge Model
Some Challenges Will Not Be Public, only people with the View Upcoming Challenges Permission Can View the Challenge...
For this we have created the ChallengeLanguage
model.
https://github.com/Tech-With-Tim/models/blob/main/challenges/language.py#L7-L27
All endpoints require
ManageWeeklyChallengeLanguages
permission.
GET @ /challenges/languages
Fetches all all languages rows.
Alphabetically sorted.
POST @ /challenges/languages
Creates a new ChallengeLanguage row.
GET @ /challenges/languages/{id}
Fetches this specific language and the active challenges that are using it.
Challenges are a minimized version (id, title, description, released_at, deleted, slug)
and should be ordered by released_at descending.
PATCH @ /challenges/languages/{id}
Updates only the provided portion of the object.
DELETE @ /challenges/languages/{id}
If the language is used in any challenge, do not delete the language.
This would delete any submissions using it.
If the language has never been used you can delete it.
Make sure to also remove it from any languages: Array[bigint]
columns on the Challenge
model.
The UpdateRoleBody
and NewRoleBody
have some issues and need some updates, here are the needed updates:
The UpdateRoleBody.name
has a max_length
of 64 instead of the 32 in NewRoleBody.name
.
The NewRoleBody.color
and UpdateRoleBody.color
could use a pydantic.Color
field instead of the current int
field.
GET @ /challenges
Fetches all challenges which are not deleted and released. Deleted challenges will have deleted
set to true, and released challenges will have a date in released_at
. Only users with ViewUpcomingWeeklyChallenge
permission should be able to see unreleased challenges.
If the user can see deleted challenges,
deleted
should be added in the challenge response
Challenge Object should look something like this:
{
"id": "string",
"title": "string",
"description": "string",
"author_id": "string",
"language_ids": ["string"],
"released_at": "date/null",
"slug": "string"
}
if the user has any WeeklyChallenges
permission, they should be able to see deleted challenges.
This endpoint needs pagination
POST @ /challenges
Creates a new Challenge. If the challenge is created successfully should return 201 Created
with the challenge data.
Needs
CreateWeeklyChallenge
permission
{
"title": "string",
"description": "string",
"example_in": ["string"],
"example_out": ["string"],
"language_ids": ["string"]
}
GET @ /challenges/{id/slug}
Fetch said challenge by id or slug.
Challenge object should something similar to this:
{
"id": "string",
"title": "string",
"description": "string",
"author_id": "string",
"author": {
"id": "string",
"name": "string",
"avatar": "string",
"discriminator": "string"
},
"example_in": ["string"],
"example_out": ["string"],
"languages": [
{
"id": "string",
"name": "string",
"download_url": "string"
}
],
"released_at": "date/null",
"slug": "string",
"submissions": "integer"
}
The checks done on
GET @ /challenges
should be done here too (deleted and unreleased)
PATCH @ /challenges/{id}
Updates said challenge. Should return 200 OK
with the new challenge data.
Needs
EditWeeklyChallenge
permission
{
"title": "string",
"description": "string",
"example_in": ["string"],
"example_out": ["string"],
"language_ids": ["string"]
}
All fields should be optional
PUT @ /challenges/{id}/release
Releases/Unreleases said challenge. Should return 204 No Content
if executed successfully.
Needs
EditWeeklyChallenge
permission
DELETE @ /challenges/{id}
Update said challenge and set deleted
to true. If executed successfully 204 No Content
should be returned.
Needs
DeleteWeeklyChallenge
permission
User Permissions: DeleteChallenge
Challenge Model To Be Deleted: Challenge Model
Further Info To Be Updated @SylteA @mohamed040406
User Permissions: Create Challenge
Challenge Model To Be Created : Challenge Model
Further Info To Be Updated @SylteA @mohamed040406
Lines 53 to 59 in 261ecd3
break out of the for loop if we successfully connect.
Is your feature request related to a problem? Please describe.
I have to restart the app every time I make a change which is very time consuming. Doing this with hypercorn's default config.use_reloader
and watchdog don't work that is why I added this here so if someone would know how to do this.
Describe the solution you'd like
The app should reload when I make a change in any of the directories. Similar to what happens in Django, Flask and the default way to run quart.
Describe alternatives you've considered
Using quarts default runner using app.run
or adding the QUART_APP
and other quart variable to the .env variables.
Additional context
I know this will take time to implement as the above solutions may give errors too.
The User model username and discrim are unique but they shouldn't be. So, takos#0001
and takos#6969
would conflict and even worse, Biz#6969
and takos#6969
would also conflict.
Create 2 users with the same username or discrim.
One of the users isn't created because it conflicts with the other user.
None
User Permissions: EditChallenge
Challenge Model To Be Edited : Challenge Model
Further Info To Be Updated @SylteA @mohamed040406
GET @ /challenges/{id}/submissions
Gets a list of submitted solutions for said challenge.
Only available if the challenge has ended (now() >= released_at + interval '7' days
) or if the user has ManageSubmissions
permission.
Submission Object should be something like this:
{
"id": "string",
"challenge_id": "string",
"author_id": "string",
"author": {
"id": "string",
"name": "string",
"avatar": "string",
"discriminator": "string"
},
"language": {
"id": "string",
"name": "string"
},
"code": "string"
}
Pagination Required
GET @ /challenges/{id}/submissions/{user_id/submission_id}
GET @ /challenges/{id}/submissions/@me
should also be available
Gets a submission for said user by their user id or submission id.
Submission Object should be the same as the one in GET @ /challenges/{id}/submissions
One of the following conditions should be true for this endpoint to be available:
ManageSubmissions
permissionPOST @ /challenges/{id}/submissions
Creates a new submission for said challenge. Returns 201 Created
on success and return id in Location
header.
{
"language": "string",
"code": "string"
}
DELETE @ /challenges/{challenge_id}/submissions/{id}
Deletes said submission from said challenge. Returns 204 No Content
on success.
Needs
ManageSubmissions
Permission
This is merely a test.
Add a querystring parsing for requests
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.