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
Updating create account text #514
Updating create account text #514
Conversation
912bc95
to
a0c5a3c
Compare
@@ -15,7 +15,7 @@ table class="data" id="buyer_accounts" | |||
|
|||
th class="actions" | |||
- if current_account.master? | |||
= link_to 'Create', new_provider_admin_account_path, title: 'Create new tenant account', class: 'action add' | |||
= link_to 'Create', new_provider_admin_account_path, title: 'Create new account', class: 'action add' |
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.
so lets move the if - else
inline as now the only difference is the path
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.
I agree 😄 It is simpler:
th class="actions"
- if can?(:create, Account)
= link_to 'Create', (current_account.master? ? new_provider_admin_account_path : new_admin_buyers_account_path), title: 'Create new account', class: 'action add'
And with this I am assuming that can?(:create, Account)
for a master is always true, which should be, otherwise what we currently have here is already wrong 😄
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.
@Martouta @thomasmaas , I simplified it, can you check?
Codecov Report
@@ Coverage Diff @@
## master #514 +/- ##
==========================================
+ Coverage 92.69% 92.69% +<.01%
==========================================
Files 2344 2344
Lines 75748 75764 +16
==========================================
+ Hits 70213 70231 +18
+ Misses 5535 5533 -2
Continue to review full report at Codecov.
|
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.
This changes the behaviour in a risky way because right now we are not checking the case of not being a master and can?(:create, Account)
being false 😞
|
= link_to 'Create', new_provider_admin_account_path, title: 'Create new tenant account', class: 'action add' | ||
- elsif can?(:create, Account) | ||
= link_to 'Create', new_admin_buyers_account_path, title: 'Create new account', class: 'action add' | ||
- if can?(:create, current_account) |
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.
- if can?(:create, current_account) | |
- if can?(:create, Account) |
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.
I tried that @thomasmaas @Martouta , it works for a provider, but not for master
= link_to 'Create', new_provider_admin_account_path, title: 'Create new tenant account', class: 'action add' | ||
- elsif can?(:create, Account) | ||
= link_to 'Create', new_admin_buyers_account_path, title: 'Create new account', class: 'action add' | ||
- if can?(:create, current_account) |
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.
- if can?(:create, Account)
😄
This means if the current_user
can create from the model Account
, while what there is currently in the code here means if the current_user
can create the current_account
😂
@@ -16,6 +16,7 @@ | |||
end | |||
end | |||
|
|||
can(:create, Account, &:signup_provider_possible?) |
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.
What the controller is doing is:
before_action :check_provider_signup_possible, :only => %i[new create] |
porta/app/controllers/provider/admin/accounts_controller.rb
Lines 65 to 67 in c865ad5
def check_provider_signup_possible | |
redirect_to admin_buyers_accounts_path, alert: 'Please, create an Account Plan and a Service Plan first' unless current_account.signup_provider_possible? | |
end |
porta/app/lib/logic/provider_signup.rb
Lines 9 to 12 in c865ad5
def signup_provider_possible? | |
ensure_master | |
!!(services.default && account_plans.default && services.default.service_plans.default) | |
end |
Imo in the case of member users we should check also user.has_permission?(:partners)
but that would be changing the current behaviour so that's why I didn't do it 🤔
What this PR does / why we need it:
Update the page to create accounts in the Master Admin Portal to: Create new account
Which issue(s) this PR fixes
https://issues.jboss.org/browse/THREESCALE-1782
Special notes for your reviewer:
@thomasmaas , please review locally with Master account
Before:
After: