Skip to content
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

#181 handling owner location access #304

Merged
merged 4 commits into from
Feb 20, 2019
Merged

Conversation

krzyk
Copy link
Contributor

@krzyk krzyk commented Feb 19, 2019

#181

  • added handling of company with location access
  • test to cover the cases

@0crat
Copy link

0crat commented Feb 19, 2019

Job #304 is now in scope, role is REV

@codecov
Copy link

codecov bot commented Feb 19, 2019

Codecov Report

Merging #304 into master will increase coverage by 0.47%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #304      +/-   ##
==========================================
+ Coverage   81.39%   81.87%   +0.47%     
==========================================
  Files          42       42              
  Lines         758      756       -2     
  Branches       48       49       +1     
==========================================
+ Hits          617      619       +2     
+ Misses        122      118       -4     
  Partials       19       19
Impacted Files Coverage Δ
timeless/access_control/owner_privileges.py 100% <100%> (+5.55%) ⬆️
timeless/access_control/authorization.py 85.71% <0%> (-14.29%) ⬇️
timeless/reservations/views.py 64.28% <0%> (-10.72%) ⬇️
timeless/templates/views.py 100% <0%> (ø) ⬆️
timeless/auth/views.py 53.12% <0%> (+3.12%) ⬆️
timeless/items/models.py 86.84% <0%> (+3.5%) ⬆️
timeless/restaurants/table_shapes/views.py 55.26% <0%> (+3.83%) ⬆️
timeless/restaurants/floors/views.py 60% <0%> (+14.54%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 743f3de...3bf62ed. Read the comment docs.

@codecov
Copy link

codecov bot commented Feb 19, 2019

Codecov Report

Merging #304 into master will increase coverage by 0.18%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #304      +/-   ##
==========================================
+ Coverage   81.39%   81.57%   +0.18%     
==========================================
  Files          42       42              
  Lines         758      760       +2     
  Branches       48       48              
==========================================
+ Hits          617      620       +3     
  Misses        122      122              
+ Partials       19       18       -1
Impacted Files Coverage Δ
timeless/access_control/owner_privileges.py 100% <100%> (+5.55%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 743f3de...16cb60a. Read the comment docs.

@0crat
Copy link

0crat commented Feb 19, 2019

This pull request #304 is assigned to @vryazanov/z, here is why; the budget is 15 minutes, see §4; please, read §27 and when you decide to accept the changes, inform @emilianodellacasa/z (the architect) right in this ticket; if you decide that this PR should not be accepted ever, also inform the architect; this blog post will help you understand what is expected from a code reviewer; there will be a monetary reward for this job

Copy link
Contributor

@vryazanov vryazanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@krzyk I left a few comments, pls have a look

status="status"
)
db_session.add(location)
db_session.commit()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@krzyk let's add instances to session and then make one db_session.commit(), instead of multiple commits

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@krzyk and the same in the second test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vryazanov not quite, I get id's only after I do commit, so e.g. if I want to use my_company.id, I need to commit it first

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@krzyk Actually to get instance id need to execute db_session.flush(), it will interact with database, but transaction will not be commited. but anyway, I think we can leave it as it is

# @todo #181:30min This test stopped working because it was not working
# according to requirements.
# Write new tests that validate 'is_allowed' according to specifications in #22
@pytest.mark.skip("fix me")
def test_owner_can_access_location():
assert (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@krzyk let's make it simpler:

assert is_allowed(method=Method.DELETE, resource="location")

Copy link
Contributor Author

@krzyk krzyk Feb 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vryazanov is it really necessary? I didn't touch this test and this whole test should be removed altogether, because it doesn't make sense after the changes. We should write new ones

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@krzyk ah, got it. ok

return permitted
user_company = flask.g.get("user").company_id
location_company = Location.query.get(kwargs.get("id")).company_id
if method in (Method.READ, Method.CREATE, Method.UPDATE, Method.DELETE) \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@krzyk you listed all possible methods here :)
Seems this code does the same:

    user_company = flask.g.get("user").company_id
    location_company = Location.query.get(kwargs.get("id")).company_id
    return user_company == location_company

@krzyk
Copy link
Contributor Author

krzyk commented Feb 19, 2019

@vryazanov updated and replied

@vryazanov
Copy link
Contributor

@rultor merge

@rultor
Copy link
Contributor

rultor commented Feb 19, 2019

@rultor merge

@vryazanov Thanks for your request. @emilianodellacasa Please confirm this.

@emilianodellacasa
Copy link
Contributor

@rultor merge

@rultor
Copy link
Contributor

rultor commented Feb 20, 2019

@rultor merge

@emilianodellacasa OK, I'll try to merge now. You can check the progress of the merge here

@rultor rultor merged commit 3bf62ed into timelesslounge:master Feb 20, 2019
@rultor
Copy link
Contributor

rultor commented Feb 20, 2019

@rultor merge

@emilianodellacasa Done! FYI, the full log is here (took me 7min)

@0crat
Copy link

0crat commented Feb 20, 2019

Job was finished in 16 hours, bonus for fast delivery is possible (see §36)

@0crat
Copy link

0crat commented Feb 20, 2019

@ypshenychka/z please review this job completed by @vryazanov/z, as in §30; the job will be fully closed and all payments will be made when the quality review is completed

@0crat 0crat removed the scope Issue is in scope label Feb 20, 2019
@0crat
Copy link

0crat commented Feb 20, 2019

The job #304 is now out of scope

@0crat
Copy link

0crat commented Feb 20, 2019

Payment to ARC for a closed pull request, as in §28: +10 point(s) just awarded to @emilianodellacasa/z

@ypshenychka
Copy link

@vryazanov According to our QA Rules:

The code reviewer found at least three problems in the code.
Comments were mostly about design problems, not cosmetic issues.

Only one issue was found during code review.
Please confirm that you'll try to find at least three major problems while future reviews.

@vryazanov
Copy link
Contributor

@ypshenychka I confirm

@ypshenychka
Copy link

@vryazanov thanks

@ypshenychka
Copy link

@0crat quality acceptable

@0crat
Copy link

0crat commented Feb 20, 2019

Order was finished, quality is "acceptable": +20 point(s) just awarded to @vryazanov/z

@0crat
Copy link

0crat commented Feb 20, 2019

Quality review completed: +8 point(s) just awarded to @ypshenychka/z

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.

6 participants