-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/crud for namespaces #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Building routes to create, list, update, delete and approve namespaces; - Building interface to consume Namespace CRUD API
italovalcy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great progress, @silvasilas99 ! Left a few comments to you!
| members = db.Column(db.String) | ||
| owners = db.Column(db.String) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
members and owners should be association tables, like what we have for group membership. Can you please check this?
| user_id = db.Column(db.Integer, db.ForeignKey("users.id"), nullable=False) | ||
| user = db.relationship('Users', backref='namespaces', foreign_keys=[user_id]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please clarify why we need those two fields (user being a relationship)?
| if not content: | ||
| return {"status": "fail", "result": "Invalid content."}, 400 | ||
|
|
||
| print(content) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left over?
|
|
||
| @blueprint.route("/namespaces", methods=["POST"]) | ||
| @login_required | ||
| def create_namespace(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of one function to insert and another one to update, where the actual difference between them is minimal (object loading, which can abstracted into a if statement), we could have one function called "upset_namespace()" (this naming convention is used across other projects) that does both tasks. Can you please refactor?
| if current_user.category not in ["admin", "teacher"]: | ||
| return {"status": "fail", "result": "Unauthorized access"}, 401 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have a decorator called "check_user_category()" that can be used to reduce code duplicated like this validation.
No description provided.