Skip to content

Conversation

@silvasilas99
Copy link
Contributor

No description provided.

- Building routes to create, list, update, delete and approve namespaces;
- Building interface to consume Namespace CRUD API
Copy link
Contributor

@italovalcy italovalcy left a 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!

Comment on lines +241 to +242
members = db.Column(db.String)
owners = db.Column(db.String)
Copy link
Contributor

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?

Comment on lines +246 to +247
user_id = db.Column(db.Integer, db.ForeignKey("users.id"), nullable=False)
user = db.relationship('Users', backref='namespaces', foreign_keys=[user_id])
Copy link
Contributor

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)
Copy link
Contributor

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():
Copy link
Contributor

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?

Comment on lines +560 to +561
if current_user.category not in ["admin", "teacher"]:
return {"status": "fail", "result": "Unauthorized access"}, 401
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants