-
Notifications
You must be signed in to change notification settings - Fork 55
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
Adding UserMachineModel #58
Adding UserMachineModel #58
Conversation
@@ -43,7 +43,7 @@ $ black . | |||
``` | |||
|
|||
```bash | |||
$ flake8 src/ ---max-line-length=88 --show-source --statistics | |||
$ flake8 src/ --max-line-length=88 --show-source --statistics |
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.
thankyou!
src/FlaskRTBCTF/ctf/models.py
Outdated
@@ -15,8 +16,20 @@ class Machine(db.Model): | |||
ip = db.Column(db.String(64), nullable=False) | |||
hardness = db.Column(db.String, nullable=False, default="Easy") | |||
|
|||
users = db.relationship( |
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.
don't need this. It should be a one way relationship.
src/FlaskRTBCTF/ctf/routes.py
Outdated
@@ -128,6 +124,18 @@ def new_machine(): | |||
new_machine = Machine() | |||
form.populate_obj(new_machine) | |||
db.session.add(new_machine) | |||
db.session.flush() | |||
|
|||
Users = User.query.all() |
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.
don't need to create this here.
src/FlaskRTBCTF/users/routes.py
Outdated
db.session.flush() | ||
|
||
Machines = Machine.query.all() | ||
for machine in Machines: |
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 don't need to initialize rows for every User & Machine. It would be created only when user submits flag, right or wrong.
src/FlaskRTBCTF/users/routes.py
Outdated
|
||
Machines = Machine.query.all() | ||
for machine in Machines: | ||
user_machine = UserMachine( |
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.
same as stated above.
src/create_db.dev.py
Outdated
@@ -56,6 +58,12 @@ | |||
isAdmin=True, | |||
) | |||
db.session.add(admin_user) | |||
db.session.flush() | |||
|
|||
admin_userMachine = UserMachine( |
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.
same as stated above. No need to initialize.
71be3f7
to
ce5e9c5
Compare
Closes: #17
Changes Made
src/FlaskRTBCTF/ctf/routes.py
Other Information
flake8 src/ --max-line-length=88 --show-source --statistics
is throwing errors for src/FlaskRTBCTF/utils/init.py, which I assume can be ignoredflake8 src/ --max-line-length=88 --show-source --statistics
in CONTRIBUTING.md, I have corrected it for this branch atleastLet me know what you think @eshaan7