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

Feature: Renting manager role #916

Open
wants to merge 20 commits into
base: staging
Choose a base branch
from
Open

Conversation

Ellen-Wittingen
Copy link
Contributor

@Ellen-Wittingen Ellen-Wittingen commented Mar 18, 2024

Added a role for renting managers with which they have the following permissions:

  • Activities
    • See a list of all activities, also the ones that are locked
    • Create, edit, and delete activities
    • View an activity, including the tabs "Samenvatting", "Bestellingen", and "Producttotalen"
    • Access the order screen and place orders with it, but credit mutations (Geld inleggen)
  • Invoices
    • See a list of all invoices
    • View an invoice, but not edit or send it
  • Pricelists
    • See a list of all unarchived pricelists and the prices for each product, but not edit
  • Users
    • See a list of all manually added users, but not from AMBER except for themselves
    • View a manually added user and their credit, orders, and credit mutations

The following permissions were changed for main bartenders (after talking to Soccie):

  • Activities: In the activity view, only the tabs "Samenvatting" and "Producttotalen" can be viewed now.

I also added tests for the new renting-manager role and added some tests that were missing for some controllers. The syntax used is a bit inconsistent across tests (also in the already existing tests), I will fix this in some another pull request in the future.

To easily log in as the different roles, I added new users to the seeding of AMBER-API which are linked to SOFIA roles in the seeding of SOFIA, see #412

@Ellen-Wittingen Ellen-Wittingen marked this pull request as ready for review March 18, 2024 16:14
@@ -63,7 +63,7 @@
</tbody>
</table>

<% unless @invoice.paid? %>
<% unless !policy(Invoice).send_invoice? || @invoice.paid? %>
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this mean?
and why is the change needed?

Copy link
Contributor Author

@Ellen-Wittingen Ellen-Wittingen Aug 17, 2024

Choose a reason for hiding this comment

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

A user with the renting manager role can also access this page. However, they are not allowed to send an invoice, so for them the url should not appear on the page. So we check here with the policy for invoices (described in app/policies/invoice_policy.rb) whether the person accessing the page is allowed to send an invoice

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before this there was no renting manager role, so the check was unnecessary as only treasurers (who are allowed to send invoice) could access this page

Copy link
Contributor

Choose a reason for hiding this comment

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

could this be rewrite so it is not a "unless not"statement to improve readabilty

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<% unless !policy(Invoice).send_invoice? || @invoice.paid? %>
<% if policy(Invoice).send_invoice? && !@invoice.paid? %>

Copy link
Contributor

@lodewiges lodewiges left a comment

Choose a reason for hiding this comment

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

I tested and it looks good, you said in the description that test are not written in a consistent way. Could you elaborate on that so it can be fixed in the future? Sorry, it took so long to review it hopefully things improve in the future. for now Good Work Ellen.

app/policies/activity_policy.rb Outdated Show resolved Hide resolved
app/policies/price_list_policy.rb Outdated Show resolved Hide resolved
app/policies/user_policy.rb Outdated Show resolved Hide resolved
app/views/index/index.html.erb Outdated Show resolved Hide resolved
@@ -47,7 +47,11 @@
<%= activity.price_list.name %>
</td>
<td>
<%= link_to activity.created_by.name, activity.created_by %>
<% if policy(activity.created_by).show? %>
Copy link
Contributor

@lodewiges lodewiges Nov 15, 2024

Choose a reason for hiding this comment

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

I don't completely understand how this request works?

spec/controllers/price_lists_controller/create_spec.rb Outdated Show resolved Hide resolved
Copy link

codecov bot commented Dec 14, 2024

Codecov Report

Attention: Patch coverage is 90.62500% with 6 lines in your changes missing coverage. Please review.

Please upload report for BASE (staging@465dc99). Learn more about missing BASE report.

Files with missing lines Patch % Lines
app/policies/activity_policy.rb 69.23% 4 Missing ⚠️
app/policies/price_list_policy.rb 87.50% 1 Missing ⚠️
app/policies/user_policy.rb 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             staging     #916   +/-   ##
==========================================
  Coverage           ?   75.15%           
==========================================
  Files              ?       55           
  Lines              ?     1115           
  Branches           ?        0           
==========================================
  Hits               ?      838           
  Misses             ?      277           
  Partials           ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

lodewiges
lodewiges previously approved these changes Dec 15, 2024
@lodewiges
Copy link
Contributor

lodewiges commented Dec 15, 2024

nevermind my bug fix broke the tests

@lodewiges lodewiges dismissed their stale review December 15, 2024 22:22

i broke tests

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

Successfully merging this pull request may close these issues.

2 participants